| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- #include <stdint.h>
- #include <stdbool.h>
- #include "src/config.h"
- #ifndef BATTERY_H
- #define BATTERY_H
- //Battery states
- typedef enum{
- STATE_EMPTY= 0x01,
- STATE_BATTERY_DETECTED= 0x02,
- STATE_WAITING_FOR_LIMITS= 0x03,
- STATE_MEASUREMENT_IN_PROGRESS= 0x04,
- STATE_MEASUREMENT_DONE= 0x04,
- STATE_OVERHEATING= 0x05,
- } BatteryState;
- typedef struct{
- uint16_t voltage;
- int16_t current;
- uint16_t temperature;
- }BatteryMeasurement;
- typedef struct __attribute((packed))__{
- uint16_t min_voltage;
- uint16_t max_voltage;
- uint8_t cut_off_current;
- uint16_t capacitance;
- uint8_t charge_fraction;
- } BatteryLimits;
- typedef struct{
- uint8_t slot_id;
- int16_t charge_discharge;
- BatteryState battery_state;
- BatteryMeasurement battery_measurement;
- BatteryLimits battery_limits;
- bool batteryLimitRecieved;
- } BatteryInfo;
- extern BatteryInfo battery_data[NUM_SLOTS];
- void Battery_Init();
- void Battery_ReadState(uint8_t slot_id);
- #endif
|