Просмотр исходного кода

for enum it takes now 1 byte after defining it with uint8_t

namrota ghosh 7 месяцев назад
Родитель
Сommit
e4b99a844e
2 измененных файлов с 3 добавлено и 2 удалено
  1. 1 0
      src/battery_data/battery.c
  2. 2 2
      src/battery_data/battery.h

+ 1 - 0
src/battery_data/battery.c

@@ -28,6 +28,7 @@ void Battery_ReadState(uint8_t slot_id){
        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_state = STATE_EMPTY;

+ 2 - 2
src/battery_data/battery.h

@@ -21,8 +21,8 @@ typedef enum{
 
 } BatteryState;
 
-//Battery Discharge Safety Check: it is unpacked on the target side making a difference in the size of the struct, changing it to unpacked
-typedef enum __attribute__((packed)){
+//Battery Discharge Safety Check: when defined with type uint8_t takes only 1 byte otherwise takes 4 byte
+typedef enum: uint8_t{
     SLOT_STATE_OK= 0x00,
     SLOT_STATE_SOV= 0x01,
     SLOT_ERR_HOV= (0x02 | 0x80),