rng: fix clock error handling, based on RM.
According to L4/L0/G0 RM, in case of clock error, interrupt flag must be cleared, and CECS flag should be cleared as soon as clock meets requirement. Reviewed-on: https://github.com/libopencm3/libopencm3/pull/1062
This commit is contained in:
parent
5866852a90
commit
a8a92b4c11
@ -87,6 +87,9 @@ bool rng_get_random(uint32_t *rand_nr)
|
||||
* Get a random number and block until it works.
|
||||
* Unless you have a clock problem, this should always return "promptly"
|
||||
* If you have a clock problem, you will wait here forever!
|
||||
* Check device RM for clock requirements (usually fRNGCLK > fHCLK/16 or
|
||||
* fRNGCLK > fHCLK/32
|
||||
|
||||
* @returns a random 32bit number
|
||||
*/
|
||||
uint32_t rng_get_random_blocking(void)
|
||||
@ -104,6 +107,10 @@ uint32_t rng_get_random_blocking(void)
|
||||
RNG_CR |= RNG_CR_RNGEN;
|
||||
}
|
||||
|
||||
if (RNG_SR & RNG_SR_CEIS) {
|
||||
RNG_SR = RNG_SR & ~RNG_SR_CEIS;
|
||||
}
|
||||
|
||||
done = rng_get_random(&rv);
|
||||
} while (!done);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user