| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- #ifndef BATTERY_H
- #define BATTERY_H
- #include <stdint.h>
- //define macro to be used by multiple files in the program witout the variable being overwritten
- //for testing
- #define NUM_SLOTS (1)
- #define BATTERY_THRESHOLD (50)
- #define ADC_CHANNEL_NUM (2)
- //Battery states
- typedef enum{
- STATE_EMPTY= 0x01,
- STATE_BATTERY_DETECTED= 0x02,
- STATE_MEASUREMENT_IN_PROGRESS= 0x03,
- STATE_MEASUREMENT_DONE= 0x04,
- STATE_OVERCHARGING= 0x05
- } BatteryState;
- //Battery Structure
- typedef struct{
- uint8_t slot_id;
- BatteryState state;
- uint8_t channel;
- uint16_t voltage;
- int16_t current;
- uint16_t temperature;
- uint16_t min_voltage;
- uint16_t max_voltage;
- uint16_t cut_off_current;
- uint16_t capacitance;
- uint16_t charge_fraction;
- } Battery;
- //global battery array declaration: extending visiblity of the variable to multiple source files
- extern Battery batteries[NUM_SLOTS];
- void Battery_Init();
- void Battery_SafetyCheck(uint8_t slot);
- #endif
|