Class that provides a random number generator. The RNG can be seeded by reading noise from an unused ADC.
More...
#include <rng.h>
|
| RNG ()=default |
| Construct a new RNG object.
|
|
void | seed () |
| Seed the RNG by reading the ADC's LSB 8 times. More...
|
|
uint8_t | rand () |
| Create a pseudo-random number between 0 and 255. More...
|
|
|
static void | init () |
| Initialize the RNG & underlying ADC.
|
|
Class that provides a random number generator. The RNG can be seeded by reading noise from an unused ADC.
- Authors
- Philipp Karg (phili.nosp@m.pp.k.nosp@m.arg@t.nosp@m.um.d.nosp@m.e)
- Date
- 23.06.2022
- Copyright
- Philipp Karg 2022
◆ rand()
Create a pseudo-random number between 0 and 255.
Simple 8-bit adaption of the Xorshift PRNG.
- Returns
- (uint8_t): The pseudo-random number.
◆ readADC()
static bit_t RNG::readADC |
( |
| ) |
|
|
staticprivate |
Read the LSB from ADC0.
- Precondition
- Requires init() to be called before.
- Returns
- (bit_t): The read LSB.
◆ seed()
Seed the RNG by reading the ADC's LSB 8 times.
- Precondition
- Requires init() to be called before.
The documentation for this class was generated from the following file: