summaryrefslogtreecommitdiff
path: root/keyboard/hhkb/rn42/battery.h
diff options
context:
space:
mode:
authortmk <hasu@tmk-kbd.com>2015-01-16 11:51:34 +0900
committertmk <hasu@tmk-kbd.com>2015-01-16 11:51:34 +0900
commitc610bae63197482bf323fbd63475dd4dba71ed46 (patch)
tree3624044b5dede28f377e262f66d4f90963e0870d /keyboard/hhkb/rn42/battery.h
parent3e88e8b761f8f8d8c5155fed3f064cc1bf207dab (diff)
parent099701dd3130d433244b3a4102f36f547aec25ae (diff)
downloadqmk_firmware-c610bae63197482bf323fbd63475dd4dba71ed46.tar.gz
qmk_firmware-c610bae63197482bf323fbd63475dd4dba71ed46.zip
Merge branch 'rn42_integrate'
Diffstat (limited to 'keyboard/hhkb/rn42/battery.h')
-rw-r--r--keyboard/hhkb/rn42/battery.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/keyboard/hhkb/rn42/battery.h b/keyboard/hhkb/rn42/battery.h
new file mode 100644
index 0000000000..180d4dcfaa
--- /dev/null
+++ b/keyboard/hhkb/rn42/battery.h
@@ -0,0 +1,35 @@
+#ifndef POWER_H
+#define POWER_H
+
+#include <stdint.h>
+#include <stdbool.h>
+
+typedef enum {
+ FULL_CHARGED,
+ CHARGING,
+ DISCHARGING,
+ LOW_VOLTAGE,
+ UNKNOWN,
+} battery_status_t;
+
+typedef enum {
+ LED_CHARGER = 0,
+ LED_ON,
+ LED_OFF,
+ LED_TOGGLE,
+} battery_led_t;
+
+/* Battery API */
+void battery_init(void);
+void battery_led(battery_led_t val);
+bool battery_charging(void);
+uint16_t battery_voltage(void);
+battery_status_t battery_status(void);
+
+#define BATTERY_VOLTAGE_LOW_LIMIT 3500
+#define BATTERY_VOLTAGE_LOW_RECOVERY 3700
+// ADC offset:16, resolution:5mV
+#define BATTERY_ADC_OFFSET 16
+#define BATTERY_ADC_RESOLUTION 5
+
+#endif