Sfoglia il codice sorgente

config file and battery file working for CC CV charging

namrota ghosh 6 mesi fa
parent
commit
b0832d116d
2 ha cambiato i file con 6 aggiunte e 14 eliminazioni
  1. 5 13
      src/battery_data/battery.c
  2. 1 1
      src/config.h

+ 5 - 13
src/battery_data/battery.c

@@ -31,21 +31,13 @@ void Battery_StateCondition(uint8_t slot_id){
     
     if(battery_data[slot_id].battery_measurement.voltage < BATTERY_THRESHOLD){
         battery_data[slot_id].battery_state = STATE_EMPTY;
-    }
-    else if(battery_data[slot_id].min_voltage==0 &&
-       battery_data[slot_id].max_voltage==0 &&
-       battery_data[slot_id].cut_off_current==0){
-        battery_data[slot_id].battery_state = STATE_WAITING_FOR_LIMITS;
-        //printf("Waiting to receive battery limits to start charging/discharging\n");
-    }
-    else if((battery_data[slot_id].battery_measurement.voltage >= BATTERY_THRESHOLD) &&
-            (battery_data[slot_id].battery_measurement.voltage < battery_data[slot_id].min_voltage)){
+    }else if((battery_data[slot_id].battery_measurement.voltage >= BATTERY_THRESHOLD) && battery_data[slot_id].batteryLimitReceived==false){
         battery_data[slot_id].battery_state = STATE_BATTERY_DETECTED;
-    }
-    else if(battery_data[slot_id].battery_measurement.temperature > TEMPERATURE_MAX_C){
+    }else if(battery_data[slot_id].min_voltage==0 && battery_data[slot_id].max_voltage==0 && battery_data[slot_id].cut_off_current==0){
+        battery_data[slot_id].battery_state = STATE_WAITING_FOR_LIMITS;
+    }else if(battery_data[slot_id].battery_measurement.temperature > TEMPERATURE_MAX_C){
         battery_data[slot_id].battery_state = STATE_OVERHEATING;
-    }
-    else{
+    }else{
         battery_data[slot_id].battery_state = STATE_MEASUREMENT_IN_PROGRESS;
     }
 }

+ 1 - 1
src/config.h

@@ -4,7 +4,7 @@
 #define CONFIG_H_
 #define I2C_TX_MAX_PACKET_SIZE  (8)
 #define I2C_RX_MAX_PACKET_SIZE  (12)
-#define BATTERY_THRESHOLD (50)
+#define BATTERY_THRESHOLD (20)
 #define TEMPERATURE_MAX_C (60)
 #define MAX_CYCLES (2)
 #define TARGET_BASE_ADDRESS (0x48)