]> git.donarmstrong.com Git - tmk_firmware.git/blob - keyboard/hhkb_rn42/rn42/battery.h
60fc8adfcb17c814bc25406e155604d179ce8977
[tmk_firmware.git] / keyboard / hhkb_rn42 / rn42 / battery.h
1 #ifndef POWER_H
2 #define POWER_H
3
4 #include <stdint.h>
5 #include <stdbool.h>
6
7 typedef enum {
8     FULL_CHARGED,
9     CHARGING,
10     DISCHARGING,
11     LOW_VOLTAGE,
12 } battery_status_t;
13
14 typedef enum {
15     LED_CHARGER = 0,
16     LED_ON,
17     LED_OFF,
18     LED_TOGGLE,
19 } battery_led_t;
20
21 /* Battery API */
22 void battery_init(void);
23 void battery_led(battery_led_t val);
24 bool battery_charging(void);
25 uint16_t battery_voltage(void);
26 battery_status_t battery_status(void);
27
28 #define BATTERY_VOLTAGE_LOW_LIMIT       3500
29 #define BATTERY_VOLTAGE_LOW_RECOVERY    3700
30 // ADC offset:16, resolution:5mV
31 #define BATTERY_ADC_OFFSET              16
32 #define BATTERY_ADC_RESOLUTION          5
33
34 #endif