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:
parent
68bde79ee5
commit
ddb7f88f9e
1 changed files with 29 additions and 4 deletions
|
|
@ -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);
|
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;
|
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);
|
nrf_rng_task_trigger(NRF_RNG_TASK_START);
|
||||||
|
|
||||||
|
do {
|
||||||
while (NRF_RNG->EVENTS_VALRDY == 0) {
|
while (NRF_RNG->EVENTS_VALRDY == 0) {
|
||||||
|
__WFE();
|
||||||
|
__SEV();
|
||||||
|
__WFE();
|
||||||
}
|
}
|
||||||
|
|
||||||
buf[--len] = NRF_RNG->VALUE;
|
buf[--len] = NRF_RNG->VALUE;
|
||||||
}
|
|
||||||
|
NRF_RNG->EVENTS_VALRDY = 0;
|
||||||
|
} while (len);
|
||||||
|
|
||||||
nrf_rng_task_trigger(NRF_RNG_TASK_STOP);
|
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;
|
return cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue