battery.h 875 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. #define BATTERY_THRESHOLD (50)
  7. typedef enum{
  8. STATE_EMPTY= 0x01,
  9. STATE_BATTERY_DETECTED= 0x02,
  10. STATE_MEASUREMENT_IN_PROGRESS= 0x03,
  11. STATE_MEASUREMENT_DONE= 0x04,
  12. STATE_OVERCHARGING= 0x05
  13. } BatteryState;
  14. //Battery Structure
  15. typedef struct{
  16. uint8_t slot_id;
  17. BatteryState state;
  18. uint16_t voltage;
  19. int16_t current;
  20. uint16_t temperature;
  21. uint16_t min_voltage;
  22. uint16_t max_voltage;
  23. uint16_t cut_off_current;
  24. uint16_t capacitance;
  25. } Battery;
  26. //global battery array declaration: extending visiblity of the variable to multiple source files
  27. extern Battery batteries[NUM_SLOTS];
  28. void Battery_Init();
  29. void Battery_SafetyCheck(uint8_t slot);
  30. #endif