diff options
| author | Selene ToyKeeper | 2018-06-23 02:10:12 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2018-06-23 02:10:12 -0600 |
| commit | e2f73d62df6e7b79483b571cd744701e233cf94a (patch) | |
| tree | 9404bf0c3b815c333c06c73ec1f93c28a7a6ea57 /spaghetti-monster/fsm-adc.c | |
| parent | Don't auto-shutoff indicator LED when entering standby mode. (diff) | |
| download | anduril-e2f73d62df6e7b79483b571cd744701e233cf94a.tar.gz anduril-e2f73d62df6e7b79483b571cd744701e233cf94a.tar.bz2 anduril-e2f73d62df6e7b79483b571cd744701e233cf94a.zip | |
Moved pseudo_rand() into its own header, and made it gather entropy from ADC readings to improve randomness.
Adjusted candle mode to use lower bits instead of upper bits, because the lower bits are more random.
(also, the lower-bit method is slightly smaller in ROM)
Diffstat (limited to 'spaghetti-monster/fsm-adc.c')
| -rw-r--r-- | spaghetti-monster/fsm-adc.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/spaghetti-monster/fsm-adc.c b/spaghetti-monster/fsm-adc.c index 6e9f19b..2ec630c 100644 --- a/spaghetti-monster/fsm-adc.c +++ b/spaghetti-monster/fsm-adc.c @@ -109,6 +109,11 @@ ISR(ADC_vect) { uint16_t measurement = ADC; // latest 10-bit ADC reading + #ifdef USE_PSEUDO_RAND + // real-world entropy makes this a true random, not pseudo + pseudo_rand_seed += measurement; + #endif + adc_step = (adc_step + 1) & (ADC_STEPS-1); #ifdef USE_LVP |
