|
|
@@ -6,7 +6,7 @@
|
|
|
#define BATTERY_H
|
|
|
|
|
|
|
|
|
-//Battery states
|
|
|
+//Battery states read by Pi
|
|
|
typedef enum{
|
|
|
STATE_EMPTY= 0x01,
|
|
|
STATE_BATTERY_DETECTED= 0x02,
|
|
|
@@ -17,13 +17,39 @@ typedef enum{
|
|
|
|
|
|
} BatteryState;
|
|
|
|
|
|
-typedef struct{
|
|
|
+//Battery Discharge Safety Check
|
|
|
+typedef enum __attribute((packed))__{
|
|
|
+ SLOT_STATE_OK= 0x00,
|
|
|
+ SLOT_STATE_SOV= 0x01,
|
|
|
+ SLOT_ERR_HOV= (0x02 | 0x80),
|
|
|
+
|
|
|
+ SLOT_ERR_OVERTEMPERATURE= (0x03 | 0x80), // first bit indicates complete error
|
|
|
+
|
|
|
+ // Control error states
|
|
|
+ SLOT_WARN_LOWER_DAC_NOT_POSSIBLE=0x10,
|
|
|
+ SLOT_WARN_HIGHER_DAC_NOT_POSSIBLE=0x11,
|
|
|
+ SLOT_WARN_DAC_INVALID_VALUE=0x12,
|
|
|
+ SLOT_WARN_LOWER_PWM_NOT_POSSIBLE=0x13,
|
|
|
+ SLOT_WARN_HIGHER_PWM_NOT_POSSIBLE=0x14,
|
|
|
+
|
|
|
+ // I2C Slave Error states
|
|
|
+ SLOT_ERR_NO_DAC = (0x20 | 0x80),
|
|
|
+ SLOT_ERR_NO_ADC1 = (0x21 | 0x80),
|
|
|
+ SLOT_ERR_NO_ADC2 = (0x22 | 0x80),
|
|
|
+ SLOT_ERR_NO_ADC3 = (0x23 | 0x80),
|
|
|
+ SLOT_ERR_NO_ADC4 = (0x24 | 0x80),
|
|
|
+ SLOT_ERR_CONFIGBYTE = (0x25 | 0x80),
|
|
|
+ SLOT_ERR_DAC_WRITE_FAILED= (0x26 | 0x80)
|
|
|
+} SlotState;
|
|
|
+
|
|
|
+typedef struct __attribute__((packed)){
|
|
|
uint16_t voltage;
|
|
|
int16_t current;
|
|
|
uint16_t temperature;
|
|
|
+ SlotState slot_state;
|
|
|
}BatteryMeasurement;
|
|
|
|
|
|
-typedef struct __attribute((packed))__{
|
|
|
+typedef struct __attribute__((packed)){
|
|
|
uint16_t min_voltage;
|
|
|
uint16_t max_voltage;
|
|
|
uint8_t cut_off_current;
|