drivers: entropy: nrf5: Fix ENTROPY_BUSYWAIT implementation

Fixed the ENTROPY_BUSYWAIT implementation from vectoring to
RNG ISR which was preventing the busywait loop to hang
waiting on the VALRDY event which was getting cleared in the
ISR.

Fixes #9356.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
Vinayak Kariappa Chettimada 2018-08-10 13:14:25 +02:00 committed by Carles Cufí
parent 68bde79ee5
commit ddb7f88f9e

View file

@ -276,15 +276,40 @@ static int entropy_nrf5_get_entropy_isr(struct device *dev, u8_t *buf, u16_t len
return get((struct rand *)dev_data->isr, len, buf);
}
while (len) {
if (len) {
u32_t intenset;
irq_disable(RNG_IRQn);
NRF_RNG->EVENTS_VALRDY = 0;
intenset = NRF_RNG->INTENSET;
nrf_rng_int_enable(NRF_RNG_INT_VALRDY_MASK);
nrf_rng_task_trigger(NRF_RNG_TASK_START);
do {
while (NRF_RNG->EVENTS_VALRDY == 0) {
__WFE();
__SEV();
__WFE();
}
buf[--len] = NRF_RNG->VALUE;
}
NRF_RNG->EVENTS_VALRDY = 0;
} while (len);
nrf_rng_task_trigger(NRF_RNG_TASK_STOP);
if (!(intenset & RNG_INTENSET_VALRDY_Msk)) {
nrf_rng_int_disable(NRF_RNG_INT_VALRDY_MASK);
}
NVIC_ClearPendingIRQ(RNG_IRQn);
irq_enable(RNG_IRQn);
}
return cnt;
}