فهرست منبع

CC CV Charging validation, check first if the slot is EMPTY or if the BATTERY_LIMIT for the slot is false

namrota ghosh 6 ماه پیش
والد
کامیت
563ed7522a
1فایلهای تغییر یافته به همراه6 افزوده شده و 7 حذف شده
  1. 6 7
      src/cc_cv_charging.c

+ 6 - 7
src/cc_cv_charging.c

@@ -31,6 +31,12 @@ void CC_CV_UpdateChargingState(uint8_t slot_id) {
     uint8_t *previous_count= &battery->previous_cycle_number;
     battery->battery_charging_state= charging_state;
 
+    //Validate if the battery state is empty or battery limit received is false then:
+    if(battery_data[slot_id].battery_state == STATE_EMPTY || battery_data[slot_id].batteryLimitReceived==0){
+      battery->battery_charging_state= STATE_IDLE;
+      cv_charging_started= false;
+      return;
+    }
 
     //Added condition to support the edge case when the voltage drops unexpectedly to 0 during the cycle making the relays to clear
     if(batt_voltage== 0){
@@ -43,13 +49,6 @@ void CC_CV_UpdateChargingState(uint8_t slot_id) {
         return;
     }
 
-
-    if(battery_data[slot_id].battery_state == STATE_EMPTY || battery_data[slot_id].batteryLimitReceived==0){
-      battery->battery_charging_state= STATE_IDLE;
-      cv_charging_started= false;
-      return;
-    }
-
     // Once the battery limits are received then start with the charging
     if(battery_data[slot_id].batteryLimitReceived == 1){
         printf("Battery Limit %d received for Slot ID %d\n", battery_data[slot_id].batteryLimitReceived, slot_id);