summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Maestas <git@se30.xyz>2023-12-18 01:29:28 +0000
committerAlex Maestas <git@se30.xyz>2023-12-18 01:29:28 +0000
commitd10fa223b2fb85bbd79918ef6d19d16acb8e7af5 (patch)
tree22875b22a390f2f68a95f21e911d5cdaff15d11b
parent93d7f38d6797f3a145b87964f4c6aa522b513037 (diff)
downloadSensor-Watch-d10fa223b2fb85bbd79918ef6d19d16acb8e7af5.tar.gz
Sensor-Watch-d10fa223b2fb85bbd79918ef6d19d16acb8e7af5.tar.bz2
Sensor-Watch-d10fa223b2fb85bbd79918ef6d19d16acb8e7af5.zip
address SysTick erratum, which can hard-fault the chip
-rw-r--r--watch-library/hardware/watch/watch_deepsleep.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/watch-library/hardware/watch/watch_deepsleep.c b/watch-library/hardware/watch/watch_deepsleep.c
index ae2ad31d..2e7edd72 100644
--- a/watch-library/hardware/watch/watch_deepsleep.c
+++ b/watch-library/hardware/watch/watch_deepsleep.c
@@ -22,6 +22,8 @@
* SOFTWARE.
*/
+#include "hpl_systick_config.h"
+
#include "watch_extint.h"
// this warning only appears when you `make BOARD=OSO-SWAT-A1-02`. it's annoying,
@@ -158,14 +160,19 @@ void watch_enter_sleep_mode(void) {
// disable brownout detector interrupt, which could inadvertently wake us up.
SUPC->INTENCLR.bit.BOD33DET = 1;
+ // work around a silicon erratum by disabling the SysTick interrupt, which is
+ // enabled as part of driver init, before going to sleep.
+ SysTick->CTRL = SysTick->CTRL & ~(CONF_SYSTICK_TICKINT << SysTick_CTRL_TICKINT_Pos);
+
// disable all pins
_watch_disable_all_pins_except_rtc();
// enter standby (4); we basically hang out here until an interrupt wakes us.
sleep(4);
- // and we awake! re-enable the brownout detector
+ // and we awake! re-enable the brownout detector and SysTick interrupt
SUPC->INTENSET.bit.BOD33DET = 1;
+ SysTick->CTRL = SysTick->CTRL | (CONF_SYSTICK_TICKINT << SysTick_CTRL_TICKINT_Pos);
// call app_setup so the app can re-enable everything we disabled.
app_setup();