浏览代码

解决cs1180可能出错,导致误判充电,离仓后无法休眠

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 5 年之前
父节点
当前提交
9da904c2cc
共有 1 个文件被更改,包括 10 次插入0 次删除
  1. 10 0
      Application/app/sox/state.c

+ 10 - 0
Application/app/sox/state.c

@@ -411,6 +411,16 @@ static u32 _bms_main_task_handler(void){
 extern void show_leds_for_charging(uint8_t charging);
 static debounce_t _charging_detect = {.count = 0, .max_count = 10, .init_count = 0};
 static void check_charging(){
+	/* 解决cs1180可能出错,导致误判充电,离仓后无法休眠 */
+	if (measure_value()->load_current >= MIN_START_CHARGER_CURRENT) {
+		if (measure_value()->load_current != measure_value()->current_5238) {
+			if (measure_value()->current_5238 < 0.0f) { //cs1180检测到充电电流,5238检测到负电流
+				if (!io_state()->hall_detect) {
+					measure_value()->load_current = measure_value()->current_5238;
+				}
+			}
+		}
+	}
 	if ((measure_value()->load_current >= MIN_START_CHARGER_CURRENT)) {
 		if (!_bms_state.charging) {
 			debounce_inc(_charging_detect);