You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

12345678910111213141516171819202122232425262728293031323334
  1. #ifndef POWER_H
  2. #define POWER_H
  3. #include <stdint.h>
  4. #include <stdbool.h>
  5. typedef enum {
  6. FULL_CHARGED,
  7. CHARGING,
  8. DISCHARGING,
  9. LOW_VOLTAGE,
  10. } battery_status_t;
  11. typedef enum {
  12. LED_CHARGER = 0,
  13. LED_ON,
  14. LED_OFF,
  15. LED_TOGGLE,
  16. } battery_led_t;
  17. /* Battery API */
  18. void battery_init(void);
  19. void battery_led(battery_led_t val);
  20. bool battery_charging(void);
  21. uint16_t battery_voltage(void);
  22. battery_status_t battery_status(void);
  23. #define BATTERY_VOLTAGE_LOW_LIMIT 3500
  24. #define BATTERY_VOLTAGE_LOW_RECOVERY 3700
  25. // ADC offset:16, resolution:5mV
  26. #define BATTERY_ADC_OFFSET 16
  27. #define BATTERY_ADC_RESOLUTION 5
  28. #endif