rng: add irq enable/disable helper.

This commit is contained in:
Guillaume Revaillot 2019-02-05 14:34:08 +01:00 committed by Karl Palsson
parent e2ac1a6358
commit 64baacfbbf
2 changed files with 16 additions and 0 deletions

View File

@ -75,6 +75,8 @@ BEGIN_DECLS
void rng_enable(void);
void rng_disable(void);
void rng_interrupt_enable(void);
void rng_interrupt_disable(void);
bool rng_get_random(uint32_t *rand_nr);
uint32_t rng_get_random_blocking(void);

View File

@ -44,6 +44,20 @@ void rng_enable(void)
RNG_CR |= RNG_CR_RNGEN;
}
/** Enable the Random Number Generator error interrupt.
*/
void rng_interrupt_enable(void)
{
RNG_CR |= RNG_CR_IE;
}
/** Disable the Random Number Generator error interrupt.
*/
void rng_interrupt_disable(void)
{
RNG_CR &= ~RNG_CR_IE;
}
/** Randomizes a number (non-blocking).
* Can fail if a clock error or seed error is detected. Consult the Reference
* Manual, but "try again", potentially after resetting the peripheral