|
@@ -5,12 +5,11 @@
|
|
|
|
|
|
|
|
shark_bool shark_charger_detected;
|
|
shark_bool shark_charger_detected;
|
|
|
shark_bool shark_charger_enabled;
|
|
shark_bool shark_charger_enabled;
|
|
|
-
|
|
|
|
|
shark_u16 shark_charge_times;
|
|
shark_u16 shark_charge_times;
|
|
|
-shark_bool shark_battery_full;
|
|
|
|
|
|
|
|
|
|
static shark_u16 shark_charger_remove;
|
|
static shark_u16 shark_charger_remove;
|
|
|
static shark_u16 shark_charger_insert;
|
|
static shark_u16 shark_charger_insert;
|
|
|
|
|
+static shark_bool shark_battery_full;
|
|
|
|
|
|
|
|
void shark_charge_init(void)
|
|
void shark_charge_init(void)
|
|
|
{
|
|
{
|
|
@@ -32,28 +31,23 @@ void shark_charger_set_enable(shark_bool enable)
|
|
|
shark_battery_full = shark_false;
|
|
shark_battery_full = shark_false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (shark_battery_full || cb_operate_state == CB_BAT1_BAT2_SERIES || shark_charger_remove) {
|
|
|
|
|
|
|
+ if (shark_battery_full || cb_operate_state == CB_BAT1_BAT2_SERIES) {
|
|
|
enable = shark_false;
|
|
enable = shark_false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (shark_charger_enabled != enable) {
|
|
|
|
|
- shark_charger_enabled = enable;
|
|
|
|
|
- shark_charge_times = 0;
|
|
|
|
|
-
|
|
|
|
|
- if (enable) {
|
|
|
|
|
- gpio_bit_set(GPIO_PORT_CHG_EN, GPIO_PIN_CHG_EN);
|
|
|
|
|
- println("charger enabled");
|
|
|
|
|
- } else {
|
|
|
|
|
- gpio_bit_reset(GPIO_PORT_CHG_EN, GPIO_PIN_CHG_EN);
|
|
|
|
|
- shark_charger_remove = SHARK_CHG_DEBOUNCE;
|
|
|
|
|
- println("charger disabled");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (enable) {
|
|
|
|
|
+ gpio_bit_set(GPIO_PORT_CHG_EN, GPIO_PIN_CHG_EN);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ gpio_bit_reset(GPIO_PORT_CHG_EN, GPIO_PIN_CHG_EN);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ shark_charger_enabled = enable;
|
|
|
|
|
+ shark_charge_times = 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void shark_charger_disable(u16 times)
|
|
|
|
|
|
|
+void shark_charger_disable(void)
|
|
|
{
|
|
{
|
|
|
- if (shark_charge_times > times) {
|
|
|
|
|
|
|
+ if (shark_charge_times > SHARK_CHG_TIME_DETECT) {
|
|
|
shark_charger_set_enable(shark_false);
|
|
shark_charger_set_enable(shark_false);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -65,7 +59,7 @@ void shark_charge_tick(void)
|
|
|
|
|
|
|
|
if (shark_charger_insert < 50) {
|
|
if (shark_charger_insert < 50) {
|
|
|
shark_charger_insert++;
|
|
shark_charger_insert++;
|
|
|
- } else if (shark_xl_check() == shark_false) {
|
|
|
|
|
|
|
+ } else if (shark_xl_check_with_qd() == shark_false) {
|
|
|
shark_charger_detected = shark_true;
|
|
shark_charger_detected = shark_true;
|
|
|
|
|
|
|
|
if (shark_charger_enabled && shark_charge_times < SHARK_CHG_TIME_MAX) {
|
|
if (shark_charger_enabled && shark_charge_times < SHARK_CHG_TIME_MAX) {
|
|
@@ -90,27 +84,27 @@ void shark_charge_poll(void)
|
|
|
switch (cb_operate_state) {
|
|
switch (cb_operate_state) {
|
|
|
case CB_BAT1:
|
|
case CB_BAT1:
|
|
|
if (sub_bms_info_1.packet_common.charge_flag == 0) {
|
|
if (sub_bms_info_1.packet_common.charge_flag == 0) {
|
|
|
- shark_charger_disable(SHARK_CHG_TIME_MIN);
|
|
|
|
|
|
|
+ shark_charger_disable();
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
case CB_BAT2:
|
|
case CB_BAT2:
|
|
|
if (sub_bms_info_2.packet_common.charge_flag == 0) {
|
|
if (sub_bms_info_2.packet_common.charge_flag == 0) {
|
|
|
- shark_charger_disable(SHARK_CHG_TIME_MIN);
|
|
|
|
|
|
|
+ shark_charger_disable();
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
case CB_BAT1_BAT2_PARRALLEL:
|
|
case CB_BAT1_BAT2_PARRALLEL:
|
|
|
if (sub_bms_info_1.packet_common.charge_flag == 0) {
|
|
if (sub_bms_info_1.packet_common.charge_flag == 0) {
|
|
|
if (sub_bms_info_2.packet_common.charge_flag == 0) {
|
|
if (sub_bms_info_2.packet_common.charge_flag == 0) {
|
|
|
- shark_charger_disable(SHARK_CHG_TIME_MIN);
|
|
|
|
|
|
|
+ shark_charger_disable();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (shark_battery_get_current12() < 0) {
|
|
if (shark_battery_get_current12() < 0) {
|
|
|
- shark_charger_disable(SHARK_CHG_TIME_MIN);
|
|
|
|
|
|
|
+ shark_charger_disable();
|
|
|
}
|
|
}
|
|
|
} else if (sub_bms_info_2.packet_common.charge_flag == 0 && shark_battery_get_current12() < 0) {
|
|
} else if (sub_bms_info_2.packet_common.charge_flag == 0 && shark_battery_get_current12() < 0) {
|
|
|
- shark_charger_disable(SHARK_CHG_TIME_MIN);
|
|
|
|
|
|
|
+ shark_charger_disable();
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|