|
@@ -1,4 +1,5 @@
|
|
|
#include "shark_charge.h"
|
|
#include "shark_charge.h"
|
|
|
|
|
+#include "measure_vol.h"
|
|
|
#include "app_rs485_1.h"
|
|
#include "app_rs485_1.h"
|
|
|
#include "shark_xl.h"
|
|
#include "shark_xl.h"
|
|
|
#include "app.h"
|
|
#include "app.h"
|
|
@@ -69,32 +70,42 @@ shark_bool shark_charger_is_normal(void)
|
|
|
return shark_charger_enabled && (shark_battery_charge_in1() || shark_battery_charge_in2());
|
|
return shark_charger_enabled && (shark_battery_charge_in1() || shark_battery_charge_in2());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void shark_charger_set_enable(shark_bool enable)
|
|
|
|
|
|
|
+shark_bool shark_charger_is_allow(void)
|
|
|
{
|
|
{
|
|
|
if (shark_battery_charge_full()) {
|
|
if (shark_battery_charge_full()) {
|
|
|
shark_charger_set_poll();
|
|
shark_charger_set_poll();
|
|
|
- enable = shark_false;
|
|
|
|
|
|
|
+ return shark_false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (cb_operate_state == CB_BAT1_BAT2_SERIES) {
|
|
|
|
|
- enable = shark_false;
|
|
|
|
|
|
|
+ if (cb_operate_state == CB_BAT1_BAT2_SERIES || cb_operate_state == CB_BAT_NO) {
|
|
|
|
|
+ return shark_false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (shark_charger_state != SHARK_CHG_INSERT) {
|
|
if (shark_charger_state != SHARK_CHG_INSERT) {
|
|
|
- enable = shark_false;
|
|
|
|
|
|
|
+ return shark_false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (Measure_Vol() > SHARK_CHARGER_VOLTAGE_MAX) {
|
|
|
|
|
+ return shark_false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (enable) {
|
|
|
|
|
|
|
+ return shark_true;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void shark_charger_set_enable(shark_bool enable)
|
|
|
|
|
+{
|
|
|
|
|
+ if (enable && shark_charger_is_allow()) {
|
|
|
println("charger enable");
|
|
println("charger enable");
|
|
|
shark_charge_time = shark_get_seconds();
|
|
shark_charge_time = shark_get_seconds();
|
|
|
gpio_bit_set(GPIO_PORT_CHG_EN, GPIO_PIN_CHG_EN);
|
|
gpio_bit_set(GPIO_PORT_CHG_EN, GPIO_PIN_CHG_EN);
|
|
|
|
|
+ shark_charger_enabled = shark_true;
|
|
|
} else {
|
|
} else {
|
|
|
println("charger disable");
|
|
println("charger disable");
|
|
|
gpio_bit_reset(GPIO_PORT_CHG_EN, GPIO_PIN_CHG_EN);
|
|
gpio_bit_reset(GPIO_PORT_CHG_EN, GPIO_PIN_CHG_EN);
|
|
|
|
|
+ shark_charger_enabled = shark_false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
shark_charger_valid = shark_false;
|
|
shark_charger_valid = shark_false;
|
|
|
- shark_charger_enabled = enable;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void shark_charger_disable(void)
|
|
void shark_charger_disable(void)
|