Get random seed from noisy ADC conversion at startup.
This commit is contained in:
parent
40bf585af8
commit
f36c97a9a4
3 changed files with 36 additions and 0 deletions
|
@ -225,6 +225,18 @@ uint16_t p=(uint16_t)&__bss_end;
|
|||
}
|
||||
#endif
|
||||
|
||||
/* Get a random (or probably different) seed for the 802.15.4 packet sequence number.
|
||||
* Some layers will ignore duplicates found in a history (e.g. Contikimac)
|
||||
* causing the initial packets to be ignored after a short-cycle restart.
|
||||
*/
|
||||
ADMUX =0x1E; //Select AREF as reference, measure 1.1 volt bandgap reference.
|
||||
ADCSRA=1<<ADEN; //Enable ADC, not free running, interrupt disabled, fastest clock
|
||||
ADCSRA|=1<<ADSC; //Start conversion
|
||||
while (ADCSRA&(1<<ADSC)); //Wait till done
|
||||
PRINTF("ADC=%d\n",ADC);
|
||||
random_init(ADC);
|
||||
ADCSRA=0; //Disable ADC
|
||||
|
||||
#define CONF_CALIBRATE_OSCCAL 0
|
||||
#if CONF_CALIBRATE_OSCCAL
|
||||
{
|
||||
|
|
|
@ -207,6 +207,18 @@ uint16_t p=(uint16_t)&__bss_end;
|
|||
} while (p<SP-10); //don't overwrite our own stack
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Get a random (or probably different) seed for the 802.15.4 packet sequence number.
|
||||
* Some layers will ignore duplicates found in a history (e.g. Contikimac)
|
||||
* causing the initial packets to be ignored after a short-cycle restart.
|
||||
*/
|
||||
ADMUX =0x1E; //Select AREF as reference, measure 1.1 volt bandgap reference.
|
||||
ADCSRA=1<<ADEN; //Enable ADC, not free running, interrupt disabled, fastest clock
|
||||
ADCSRA|=1<<ADSC; //Start conversion
|
||||
while (ADCSRA&(1<<ADSC)); //Wait till done
|
||||
PRINTFD("ADC=%d\n",ADC);
|
||||
random_init(ADC);
|
||||
ADCSRA=0; //Disable ADC
|
||||
|
||||
#define CONF_CALIBRATE_OSCCAL 0
|
||||
#if CONF_CALIBRATE_OSCCAL
|
||||
|
|
|
@ -422,6 +422,18 @@ uint16_t p=(uint16_t)&__bss_end;
|
|||
/* Led0 Blue Led1 Red Led2 Green Led3 Yellow */
|
||||
Leds_init();
|
||||
Led1_on();
|
||||
|
||||
/* Get a random (or probably different) seed for the 802.15.4 packet sequence number.
|
||||
* Some layers will ignore duplicates found in a history (e.g. Contikimac)
|
||||
* causing the initial packets to be ignored after a short-cycle restart.
|
||||
*/
|
||||
ADMUX =0x1E; //Select AREF as reference, measure 1.1 volt bandgap reference.
|
||||
ADCSRA=1<<ADEN; //Enable ADC, not free running, interrupt disabled, fastest clock
|
||||
ADCSRA|=1<<ADSC; //Start conversion
|
||||
while (ADCSRA&(1<<ADSC)); //Wait till done
|
||||
PRINTD("ADC=%d\n",ADC);
|
||||
random_init(ADC);
|
||||
ADCSRA=0; //Disable ADC
|
||||
|
||||
#if USB_CONF_RS232
|
||||
/* Use rs232 port for serial out (tx, rx, gnd are the three pads behind jackdaw leds */
|
||||
|
|
Loading…
Reference in a new issue