| 123456789101112131415161718192021222324252627282930313233343536373839 |
- #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
- #define NUM_SLOTS (1)
- #define BATTERY_THRESHOLD (50)
- 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;
- 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
|