Minor fixes to settings faces to work with the new rtc mode

This commit is contained in:
Alessandro Genova
2025-07-26 21:42:31 -04:00
parent eb9ec8659c
commit e942f67685
6 changed files with 18 additions and 21 deletions
+11 -11
View File
@@ -41,7 +41,7 @@ void sleep(const uint8_t mode) {
}
void watch_register_extwake_callback(uint8_t pin, watch_cb_t callback, bool level) {
uint32_t config = RTC->MODE2.TAMPCTRL.reg;
uint32_t config = RTC->MODE0.TAMPCTRL.reg;
if (pin == HAL_GPIO_BTN_ALARM_pin()) {
HAL_GPIO_BTN_ALARM_in();
@@ -71,22 +71,22 @@ void watch_register_extwake_callback(uint8_t pin, watch_cb_t callback, bool leve
}
// disable the RTC
RTC->MODE2.CTRLA.bit.ENABLE = 0;
while (RTC->MODE2.SYNCBUSY.bit.ENABLE); // wait for RTC to be disabled
RTC->MODE0.CTRLA.bit.ENABLE = 0;
while (RTC->MODE0.SYNCBUSY.bit.ENABLE); // wait for RTC to be disabled
// update the configuration
RTC->MODE2.TAMPCTRL.reg = config;
RTC->MODE0.TAMPCTRL.reg = config;
// re-enable the RTC
RTC->MODE2.CTRLA.bit.ENABLE = 1;
RTC->MODE0.CTRLA.bit.ENABLE = 1;
NVIC_ClearPendingIRQ(RTC_IRQn);
NVIC_EnableIRQ(RTC_IRQn);
RTC->MODE2.INTENSET.reg = RTC_MODE2_INTENSET_TAMPER;
RTC->MODE0.INTENSET.reg = RTC_MODE0_INTENSET_TAMPER;
}
void watch_disable_extwake_interrupt(uint8_t pin) {
uint32_t config = RTC->MODE2.TAMPCTRL.reg;
uint32_t config = RTC->MODE0.TAMPCTRL.reg;
if (pin == HAL_GPIO_BTN_ALARM_pin()) {
btn_alarm_callback = NULL;
@@ -101,14 +101,14 @@ void watch_disable_extwake_interrupt(uint8_t pin) {
}
// disable the RTC
RTC->MODE2.CTRLA.bit.ENABLE = 0;
while (RTC->MODE2.SYNCBUSY.bit.ENABLE); // wait for RTC to be disabled
RTC->MODE0.CTRLA.bit.ENABLE = 0;
while (RTC->MODE0.SYNCBUSY.bit.ENABLE); // wait for RTC to be disabled
// update the configuration
RTC->MODE2.TAMPCTRL.reg = config;
RTC->MODE0.TAMPCTRL.reg = config;
// re-enable the RTC
RTC->MODE2.CTRLA.bit.ENABLE = 1;
RTC->MODE0.CTRLA.bit.ENABLE = 1;
}
void watch_store_backup_data(uint32_t data, uint8_t reg) {
+2 -1
View File
@@ -64,6 +64,7 @@ watch_cb_t a4_callback;
static void _watch_increase_counter(void *userData);
static void _watch_process_periodic_callbacks(void);
static void _watch_process_comp_callbacks(void);
static void _watch_rtc_schedule_next_comp(void);
bool _watch_rtc_is_enabled(void) {
return counter_interval;
@@ -283,7 +284,7 @@ void watch_rtc_disable_comp_callback(uint8_t index) {
_watch_rtc_schedule_next_comp();
}
void _watch_rtc_schedule_next_comp(void) {
static void _watch_rtc_schedule_next_comp(void) {
scheduled_comp_counter = 0;
// The soonest we can schedule is the next tick