Keyboard firmwares for Atmel AVR and Cortex-M
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.

battery.h 682B

1234567891011121314151617181920212223242526272829303132333435
  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. UNKNOWN,
  11. } battery_status_t;
  12. typedef enum {
  13. LED_CHARGER = 0,
  14. LED_ON,
  15. LED_OFF,
  16. LED_TOGGLE,
  17. } battery_led_t;
  18. /* Battery API */
  19. void battery_init(void);
  20. void battery_led(battery_led_t val);
  21. bool battery_charging(void);
  22. uint16_t battery_voltage(void);
  23. battery_status_t battery_status(void);
  24. #define BATTERY_VOLTAGE_LOW_LIMIT 3500
  25. #define BATTERY_VOLTAGE_LOW_RECOVERY 3700
  26. // ADC offset:16, resolution:5mV
  27. #define BATTERY_ADC_OFFSET 16
  28. #define BATTERY_ADC_RESOLUTION 5
  29. #endif