diff options
| author | Scott Shawcroft <scott@tannewt.org> | 2020-04-07 17:15:18 -0700 |
|---|---|---|
| committer | Scott Shawcroft <scott@tannewt.org> | 2020-04-07 17:15:18 -0700 |
| commit | 6544bf52fb87fd47c234a8ab3fc26865b124c039 (patch) | |
| tree | 95abc4a6e0c10fbcdbf0973059fdd15829bc9480 | |
| parent | aae0ce6badacf07a07d9ac4badb8e312e26e50fb (diff) | |
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.
| -rw-r--r-- | ports/mimxrt10xx/supervisor/port.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/ports/mimxrt10xx/supervisor/port.c b/ports/mimxrt10xx/supervisor/port.c index 242b0592e..1a4f9520b 100644 --- a/ports/mimxrt10xx/supervisor/port.c +++ b/ports/mimxrt10xx/supervisor/port.c @@ -252,6 +252,10 @@ safe_mode_t port_init(void) { rtc_init(); #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_port(); @@ -365,7 +369,6 @@ void SNVS_HP_WRAPPER_IRQHandler(void) { // Enable 1/1024 second tick. void port_enable_tick(void) { - NVIC_EnableIRQ(SNVS_HP_WRAPPER_IRQn); uint32_t hpcr = SNVS->HPCR; hpcr &= ~SNVS_HPCR_PI_FREQ_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. void port_disable_tick(void) { SNVS->HPCR &= ~SNVS_HPCR_PI_EN_MASK; - NVIC_DisableIRQ(SNVS_HP_WRAPPER_IRQn); } void port_interrupt_after_ticks(uint32_t ticks) { |
