From fdb40488325c87822058ba695c853fa20e715a32 Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 3 Jun 2021 15:32:51 +0700 Subject: [PATCH] fix CRYPTOCELL_IRQn prevent go to sleep causing high power --- .../nRF5/freertos/portable/CMSIS/nrf52/port_cmsis_systick.c | 6 ++++++ cores/nRF5/wiring.c | 5 +++++ libraries/Adafruit_nRFCrypto | 2 +- libraries/Bluefruit52Lib/src/bluefruit.h | 2 +- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/cores/nRF5/freertos/portable/CMSIS/nrf52/port_cmsis_systick.c b/cores/nRF5/freertos/portable/CMSIS/nrf52/port_cmsis_systick.c index ad5c5c58..79440a95 100644 --- a/cores/nRF5/freertos/portable/CMSIS/nrf52/port_cmsis_systick.c +++ b/cores/nRF5/freertos/portable/CMSIS/nrf52/port_cmsis_systick.c @@ -189,6 +189,12 @@ void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime ) (void) __get_FPSCR(); NVIC_ClearPendingIRQ(FPU_IRQn); #endif + +#ifdef NRF_CRYPTOCELL + // manually clear CryptoCell else it could prevent low power mode + NVIC_ClearPendingIRQ(CRYPTOCELL_IRQn); +#endif + #ifdef SOFTDEVICE_PRESENT // TODO uint8_t sd_en = 0; (void) sd_softdevice_is_enabled(&sd_en); diff --git a/cores/nRF5/wiring.c b/cores/nRF5/wiring.c index 61dc56d5..134ee539 100644 --- a/cores/nRF5/wiring.c +++ b/cores/nRF5/wiring.c @@ -96,6 +96,11 @@ void waitForEvent(void) uint8_t sd_en = 0; (void) sd_softdevice_is_enabled(&sd_en); +#ifdef NRF_CRYPTOCELL + // manually clear CryptoCell else it could prevent low power mode + NVIC_ClearPendingIRQ(CRYPTOCELL_IRQn); +#endif + if ( sd_en ) { (void) sd_app_evt_wait(); diff --git a/libraries/Adafruit_nRFCrypto b/libraries/Adafruit_nRFCrypto index 01de30c8..3686f241 160000 --- a/libraries/Adafruit_nRFCrypto +++ b/libraries/Adafruit_nRFCrypto @@ -1 +1 @@ -Subproject commit 01de30c89bc2da783c77fda2a53f650e40fe541e +Subproject commit 3686f2413672ec72e8f8a163d6c69fe7faa0b743 diff --git a/libraries/Bluefruit52Lib/src/bluefruit.h b/libraries/Bluefruit52Lib/src/bluefruit.h index 982a6373..fda5ba0e 100644 --- a/libraries/Bluefruit52Lib/src/bluefruit.h +++ b/libraries/Bluefruit52Lib/src/bluefruit.h @@ -179,7 +179,7 @@ class AdafruitBluefruit *------------------------------------------------------------------*/ void setMultiprotocolSemaphore(SemaphoreHandle_t mprot_event_semaphore) { - _mprot_event_sem= mprot_event_semaphore; + _mprot_event_sem= mprot_event_semaphore; } #endif