diff options
author | Joey Castillo <jose.castillo@gmail.com> | 2021-08-31 18:47:35 -0400 |
---|---|---|
committer | Joey Castillo <jose.castillo@gmail.com> | 2021-08-31 19:02:44 -0400 |
commit | b22915431babce4264a2e3d333939894e5a60c0f (patch) | |
tree | a282ba38122400ce0c2bf9f946a179790ea8d9ff /watch-library/watch/watch.c | |
parent | 36322fd737f0988d00a5ea36b4536c6596937534 (diff) | |
download | Sensor-Watch-b22915431babce4264a2e3d333939894e5a60c0f.tar.gz Sensor-Watch-b22915431babce4264a2e3d333939894e5a60c0f.tar.bz2 Sensor-Watch-b22915431babce4264a2e3d333939894e5a60c0f.zip |
add method for detecting low battery
Diffstat (limited to 'watch-library/watch/watch.c')
-rw-r--r-- | watch-library/watch/watch.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/watch-library/watch/watch.c b/watch-library/watch/watch.c index 059c2a93..6196b1f3 100644 --- a/watch-library/watch/watch.c +++ b/watch-library/watch/watch.c @@ -35,3 +35,18 @@ #include "watch_uart.c" #include "watch_deepsleep.c" #include "watch_private.c" + +bool battery_is_low = false; + +// receives interrupts from MCLK, OSC32KCTRL, OSCCTRL, PAC, PM, SUPC and TAL, whatever that is. +void SYSTEM_Handler(void) { + if (SUPC->INTFLAG.bit.BOD33DET) { + battery_is_low = true; + SUPC->INTENCLR.bit.BOD33DET = 1; + SUPC->INTFLAG.reg &= ~SUPC_INTFLAG_BOD33DET; + } +} + +bool watch_is_battery_low() { + return battery_is_low; +} |