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