ATmega644 Smart-Card
rng.h
1 
11 #ifndef RNG_H
12 #define RNG_H
13 
14 #include "defs.h"
15 #define MAX_RAND 255
16 
26 class RNG
27 {
28 public:
32  RNG() = default;
33 
37  static void init();
38 
43  void seed();
44 
51  uint8_t rand();
52 
53 private:
54  uint8_t mRand = 0;
55 
61  static bit_t readADC();
62 };
63 
64 #endif // RNG_H
RNG::readADC
static bit_t readADC()
Read the LSB from ADC0.
RNG::rand
uint8_t rand()
Create a pseudo-random number between 0 and 255.
RNG
Class that provides a random number generator. The RNG can be seeded by reading noise from an unused ...
Definition: rng.h:26
RNG::RNG
RNG()=default
Construct a new RNG object.
RNG::mRand
uint8_t mRand
The RNG's state.
Definition: rng.h:54
RNG::seed
void seed()
Seed the RNG by reading the ADC's LSB 8 times.
RNG::init
static void init()
Initialize the RNG & underlying ADC.