Enable SNVS interrupt

The iMX RT has a separate wake up controller, the GPC, that replaces
the NVIC when asleep. It adds the ability to only wake up on certain
interrupts. It seems that it requires at least one enabled interrupt
in the NVIC to turn on it's wake up circuitry. It doesn't need to
be the same interrupt as the wake up signal. For example, the RTC
in the SNVS can wake us up if a USB interrupt is enabled. Before
then it won't work. So, we enable the SNVS interrupt on start up
so it can wake us up.
This commit is contained in:
Scott Shawcroft 2020-04-07 17:15:18 -07:00
parent aae0ce6bad
commit 6544bf52fb
No known key found for this signature in database
GPG Key ID: 9349BC7E64B1921E

View File

@ -252,6 +252,10 @@ safe_mode_t port_init(void) {
rtc_init(); rtc_init();
#endif #endif
// Always enable the SNVS interrupt. The GPC won't wake us up unless at least one interrupt is
// enabled. It won't occur very often so it'll be low overhead.
NVIC_EnableIRQ(SNVS_HP_WRAPPER_IRQn);
// Reset everything into a known state before board_init. // Reset everything into a known state before board_init.
reset_port(); reset_port();
@ -365,7 +369,6 @@ void SNVS_HP_WRAPPER_IRQHandler(void) {
// Enable 1/1024 second tick. // Enable 1/1024 second tick.
void port_enable_tick(void) { void port_enable_tick(void) {
NVIC_EnableIRQ(SNVS_HP_WRAPPER_IRQn);
uint32_t hpcr = SNVS->HPCR; uint32_t hpcr = SNVS->HPCR;
hpcr &= ~SNVS_HPCR_PI_FREQ_MASK; hpcr &= ~SNVS_HPCR_PI_FREQ_MASK;
SNVS->HPCR = hpcr | SNVS_HPCR_PI_FREQ(5) | SNVS_HPCR_PI_EN_MASK; SNVS->HPCR = hpcr | SNVS_HPCR_PI_FREQ(5) | SNVS_HPCR_PI_EN_MASK;
@ -374,7 +377,6 @@ void port_enable_tick(void) {
// Disable 1/1024 second tick. // Disable 1/1024 second tick.
void port_disable_tick(void) { void port_disable_tick(void) {
SNVS->HPCR &= ~SNVS_HPCR_PI_EN_MASK; SNVS->HPCR &= ~SNVS_HPCR_PI_EN_MASK;
NVIC_DisableIRQ(SNVS_HP_WRAPPER_IRQn);
} }
void port_interrupt_after_ticks(uint32_t ticks) { void port_interrupt_after_ticks(uint32_t ticks) {