Get random seed from noisy ADC conversion at startup.
This commit is contained in:
parent
40bf585af8
commit
f36c97a9a4
|
@ -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
|
||||
{
|
||||
|
|
|
@ -208,6 +208,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
|
||||
PRINTFD("ADC=%d\n",ADC);
|
||||
random_init(ADC);
|
||||
ADCSRA=0; //Disable ADC
|
||||
|
||||
#define CONF_CALIBRATE_OSCCAL 0
|
||||
#if CONF_CALIBRATE_OSCCAL
|
||||
{
|
||||
|
|
|
@ -423,6 +423,18 @@ uint16_t p=(uint16_t)&__bss_end;
|
|||
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 */
|
||||
rs232_init(RS232_PORT_0, USART_BAUD_57600,USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);
|
||||
|
|
Loading…
Reference in a new issue