|
|
@@ -52,33 +52,27 @@ shark_bool shark_battery_charge_full(void)
|
|
|
shark_battery_full = shark_false;
|
|
|
}
|
|
|
} else {
|
|
|
- return shark_false;
|
|
|
+ return shark_true;
|
|
|
}
|
|
|
|
|
|
return shark_battery_full;
|
|
|
}
|
|
|
|
|
|
-shark_bool shark_charger_is_normal(void)
|
|
|
+void shark_charger_set_poll(void)
|
|
|
{
|
|
|
- return shark_charger_enabled && (shark_battery_charge_in1() || shark_battery_charge_in2());
|
|
|
+ shark_charger_state = SHARK_CHG_REMOVE;
|
|
|
+ shark_charger_insert = 0;
|
|
|
}
|
|
|
|
|
|
-void shark_charger_set_state(shark_charger_state_t state)
|
|
|
+shark_bool shark_charger_is_normal(void)
|
|
|
{
|
|
|
- if (shark_battery_charge_full()) {
|
|
|
- state = SHARK_CHG_REMOVE;
|
|
|
- }
|
|
|
-
|
|
|
- if (shark_charger_state != state) {
|
|
|
- shark_charger_state = state;
|
|
|
- println("charger: state%d", state);
|
|
|
- }
|
|
|
+ return shark_charger_enabled && (shark_battery_charge_in1() || shark_battery_charge_in2());
|
|
|
}
|
|
|
|
|
|
void shark_charger_set_enable(shark_bool enable)
|
|
|
{
|
|
|
if (shark_battery_charge_full()) {
|
|
|
- shark_charger_set_state(SHARK_CHG_REMOVE);
|
|
|
+ shark_charger_set_poll();
|
|
|
enable = shark_false;
|
|
|
}
|
|
|
|
|
|
@@ -109,7 +103,7 @@ void shark_charger_disable(void)
|
|
|
println("charger detect");
|
|
|
shark_charger_insert = 0;
|
|
|
shark_charge_skip = 6000;
|
|
|
- shark_charger_set_state(SHARK_CHG_DETECT);
|
|
|
+ shark_charger_state = SHARK_CHG_DETECT;
|
|
|
shark_charger_set_enable(shark_false);
|
|
|
}
|
|
|
}
|
|
|
@@ -123,21 +117,26 @@ void shark_charge_tick(void)
|
|
|
if (shark_charger_enabled && shark_charge_times < SHARK_CHG_TIME_MAX) {
|
|
|
shark_charge_times++;
|
|
|
}
|
|
|
+
|
|
|
} else if (shark_charge_skip > 0) {
|
|
|
shark_charge_skip--;
|
|
|
} else {
|
|
|
- if (shark_charger_insert == SHARK_CHG_INSERT_MIN && shark_xl_check_with_qd() == shark_false) {
|
|
|
- shark_charger_set_state(SHARK_CHG_INSERT);
|
|
|
- }
|
|
|
-
|
|
|
shark_charger_insert++;
|
|
|
+
|
|
|
+ if (shark_charger_insert > SHARK_CHG_INSERT_MIN) {
|
|
|
+ if (shark_battery_charge_full() || shark_xl_check_with_qd()) {
|
|
|
+ shark_charger_set_poll();
|
|
|
+ } else {
|
|
|
+ shark_charger_state = SHARK_CHG_INSERT;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
shark_charger_insert = 0;
|
|
|
shark_charge_skip = 0;
|
|
|
|
|
|
if (shark_charger_remove > SHARK_CHG_REMOVE_MIN) {
|
|
|
- shark_charger_set_state(SHARK_CHG_REMOVE);
|
|
|
+ shark_charger_state = SHARK_CHG_REMOVE;
|
|
|
shark_battery_full = shark_false;
|
|
|
} else {
|
|
|
shark_charger_remove++;
|
|
|
@@ -150,27 +149,33 @@ void shark_charge_poll(void)
|
|
|
if (shark_charger_enabled) {
|
|
|
switch (cb_operate_state) {
|
|
|
case CB_BAT1:
|
|
|
- if (sub_bms_info_1.packet_common.charge_flag == 0) {
|
|
|
+ if (shark_battery_charge_in1()) {
|
|
|
+ shark_charger_valid = shark_true;
|
|
|
+ } else {
|
|
|
shark_charger_disable();
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case CB_BAT2:
|
|
|
- if (sub_bms_info_2.packet_common.charge_flag == 0) {
|
|
|
+ if (shark_battery_charge_in2()) {
|
|
|
+ shark_charger_valid = shark_true;
|
|
|
+ } else {
|
|
|
shark_charger_disable();
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case CB_BAT1_BAT2_PARRALLEL:
|
|
|
- if (sub_bms_info_1.packet_common.charge_flag == 0) {
|
|
|
- if (sub_bms_info_2.packet_common.charge_flag == 0) {
|
|
|
+ if (shark_battery_charge_in1()) {
|
|
|
+ if (shark_battery_charge_in2()) {
|
|
|
+ shark_charger_valid = shark_true;
|
|
|
+ } else if (shark_battery_get_current12() < 0) {
|
|
|
shark_charger_disable();
|
|
|
}
|
|
|
-
|
|
|
+ } else if (shark_battery_charge_in2()) {
|
|
|
if (shark_battery_get_current12() < 0) {
|
|
|
shark_charger_disable();
|
|
|
}
|
|
|
- } else if (sub_bms_info_2.packet_common.charge_flag == 0 && shark_battery_get_current12() < 0) {
|
|
|
+ } else {
|
|
|
shark_charger_disable();
|
|
|
}
|
|
|
break;
|