Here's the code that puts the MCU to sleep, as found here:
Code: Select all
wakeupspec.wutr = ((uint32_t)4) << 16;
wakeupspec.wutr |= 29;
rtcSTM32SetPeriodicWakeup(&RTCD1, &wakeupspec);
chSysLock();
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
PWR->CR |= (PWR_CR_PDDS | PWR_CR_LPDS | PWR_CR_CSBF | PWR_CR_CWUF);
RTC->ISR &= ~(RTC_ISR_ALRBF | RTC_ISR_ALRAF | RTC_ISR_WUTF | RTC_ISR_TAMP1F |
RTC_ISR_TSOVF | RTC_ISR_TSF);
__enable_irq();
__WFI();
This works OK, as in waking up every 30 seconds.
Additionally I would want to wake up whenever PC13 is falling.
I tried using palEnablePadEvent(), but that didn't' work. Is there a hal wrapper, or does this have to be done on a register level?