Browse Source

rng: add irq enable/disable helper.

pull/1167/head
Guillaume Revaillot 6 years ago
committed by Karl Palsson
parent
commit
64baacfbbf
  1. 2
      include/libopencm3/stm32/common/rng_common_v1.h
  2. 14
      lib/stm32/common/rng_common_v1.c

2
include/libopencm3/stm32/common/rng_common_v1.h

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

14
lib/stm32/common/rng_common_v1.c

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

Loading…
Cancel
Save