From a182f74de91c6a39394bd73f64f268307a0edf9c Mon Sep 17 00:00:00 2001 From: Ioannis Glaropoulos Date: Thu, 11 Jun 2020 18:01:58 +0200 Subject: [PATCH] drivers: entropy: nRF: clear NVIC pending before doing WFE on RNG IRQ We need to clear the NVIC Pending bit for the RNG IRQ before doing any WFEs and expect to wake up by RNG events. This is because the event register will be set only if NVIC status is changed from 0 to 1. Signed-off-by: Ioannis Glaropoulos --- drivers/entropy/entropy_nrf5.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/entropy/entropy_nrf5.c b/drivers/entropy/entropy_nrf5.c index fb3e9ce2061..a4f83bb369c 100644 --- a/drivers/entropy/entropy_nrf5.c +++ b/drivers/entropy/entropy_nrf5.c @@ -278,6 +278,13 @@ static int entropy_nrf5_get_entropy_isr(struct device *dev, uint8_t *buf, uint16 nrf_rng_event_clear(NRF_RNG, NRF_RNG_EVENT_VALRDY); nrf_rng_task_trigger(NRF_RNG, NRF_RNG_TASK_START); + /* Clear NVIC pending bit. This ensures that a subsequent + * RNG event will set the Cortex-M single-bit event register + * to 1 (the bit is set when NVIC pending IRQ status is + * changed from 0 to 1) + */ + NVIC_ClearPendingIRQ(IRQN); + do { int byte;