From ee3ef1927d310588e3a90af47d9834e589499793 Mon Sep 17 00:00:00 2001 From: Semjon Kerner Date: Wed, 14 Nov 2018 12:46:02 +0100 Subject: [PATCH] cpu/nrf5x: fix event hang --- cpu/nrf5x_common/periph/hwrng.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cpu/nrf5x_common/periph/hwrng.c b/cpu/nrf5x_common/periph/hwrng.c index 520d4572a0..5bdc6b8346 100644 --- a/cpu/nrf5x_common/periph/hwrng.c +++ b/cpu/nrf5x_common/periph/hwrng.c @@ -39,6 +39,7 @@ void hwrng_read(void *buf, unsigned int num) #ifdef CPU_FAM_NRF51 NRF_RNG->POWER = 1; #endif + NRF_RNG->INTENSET = RNG_INTENSET_VALRDY_Msk; NRF_RNG->TASKS_START = 1; /* read the actual random data */ @@ -51,9 +52,11 @@ void hwrng_read(void *buf, unsigned int num) b[count++] = (uint8_t)NRF_RNG->VALUE; /* NRF51 PAN #21 -> read value before clearing VALRDY */ NRF_RNG->EVENTS_VALRDY = 0; + NVIC_ClearPendingIRQ(RNG_IRQn); } /* power off RNG */ + NRF_RNG->INTENCLR = RNG_INTENSET_VALRDY_Msk; NRF_RNG->TASKS_STOP = 1; #ifdef CPU_FAM_NRF51 NRF_RNG->POWER = 0;