]> git.friedersdorff.com Git - max/tmk_keyboard.git/blob - keyboard/hhkb/rn42/battery.h
Merge pull request #148 from cub-uanic/patch-1
[max/tmk_keyboard.git] / keyboard / hhkb / 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     UNKNOWN,
13 } battery_status_t;
14
15 typedef enum {
16     LED_CHARGER = 0,
17     LED_ON,
18     LED_OFF,
19     LED_TOGGLE,
20 } battery_led_t;
21
22 /* Battery API */
23 void battery_init(void);
24 void battery_led(battery_led_t val);
25 bool battery_charging(void);
26 uint16_t battery_voltage(void);
27 battery_status_t battery_status(void);
28
29 #define BATTERY_VOLTAGE_LOW_LIMIT       3500
30 #define BATTERY_VOLTAGE_LOW_RECOVERY    3700
31 // ADC offset:16, resolution:5mV
32 #define BATTERY_ADC_OFFSET              16
33 #define BATTERY_ADC_RESOLUTION          5
34
35 #endif