Merge pull request #10387 from SemjonKerner/fix_nrf52_hwrng

cpu/nrf5x: fix hwrng hang
This commit is contained in:
Martine Lenders 2018-11-14 13:39:34 +01:00 committed by GitHub
commit a98edd33a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;