mirror of
https://github.com/taigrr/arduinolibs
synced 2025-01-18 04:33:12 -08:00
Noise source initialization that is post-RNG.begin()
This commit is contained in:
parent
1d89097948
commit
d50a7fed2d
@ -82,6 +82,21 @@ NoiseSource::~NoiseSource()
|
||||
* \sa calibrating(), output()
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Called when the noise source is added to RNG with
|
||||
* \link RNGClass::addNoiseSource() RNG.addNoiseSource()\endlink.
|
||||
*
|
||||
* This function is intended for noise source initialization tasks that
|
||||
* must be performed after \link RNGClass::begin() RNG.begin()\endlink
|
||||
* has been called to initialize the global random number pool.
|
||||
* For example, if the noise source has a unique identifier or serial
|
||||
* number then this function can stir it into the pool at startup time.
|
||||
*/
|
||||
void NoiseSource::added()
|
||||
{
|
||||
// Nothing to do here.
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Called from subclasses to output noise to the global random
|
||||
* number pool.
|
||||
|
@ -35,6 +35,8 @@ public:
|
||||
virtual bool calibrating() const = 0;
|
||||
virtual void stir() = 0;
|
||||
|
||||
virtual void added();
|
||||
|
||||
protected:
|
||||
virtual void output(const uint8_t *data, size_t len, unsigned int credit);
|
||||
};
|
||||
|
@ -249,8 +249,10 @@ void RNGClass::begin(const char *tag, int eepromAddress)
|
||||
void RNGClass::addNoiseSource(NoiseSource &source)
|
||||
{
|
||||
#define MAX_NOISE_SOURCES (sizeof(noiseSources) / sizeof(noiseSources[0]))
|
||||
if (count < MAX_NOISE_SOURCES)
|
||||
if (count < MAX_NOISE_SOURCES) {
|
||||
noiseSources[count++] = &source;
|
||||
source.added();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user