battery.h 857 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #ifndef BATTERY_H
  2. #define BATTERY_H
  3. #include <stdint.h>
  4. //define macro to be used by multiple files in the program witout the variable being overwritten
  5. #define NUM_SLOTS (1)
  6. typedef enum{
  7. STATE_EMPTY= 0x01,
  8. STATE_BATTERY_DETECTED= 0x02,
  9. STATE_MEASUREMENT_IN_PROGRESS= 0x03,
  10. STATE_MEASUREMENT_DONE= 0x04,
  11. STATE_OVERCHARGING= 0x05
  12. } BatteryState;
  13. //Battery Structure
  14. typedef struct{
  15. uint8_t slot_id;
  16. BatteryState state;
  17. uint16_t voltage;
  18. int16_t current;
  19. uint16_t temperature;
  20. uint16_t min_voltage;
  21. uint16_t max_voltage;
  22. uint16_t cut_off_current;
  23. uint16_t capacitance;
  24. } Battery;
  25. //global battery array declaration: extending visiblity of the variable to multiple source files
  26. extern Battery batteries[NUM_SLOTS];
  27. void Battery_Init();
  28. void Battery_SafetyCheck(uint8_t slot);
  29. #endif