|
|
@@ -26,15 +26,19 @@ |
|
|
|
|
|
|
|
#include <usbd_cdc_if.h> |
|
|
|
|
|
|
|
#include <strobe_rng_init.h> |
|
|
|
|
|
|
|
#include <string.h> |
|
|
|
|
|
|
|
/* LoRaMac headers */ |
|
|
|
#include <board.h> |
|
|
|
#include <misc.h> |
|
|
|
#include <adc.h> |
|
|
|
#include <radio.h> |
|
|
|
#include <delay.h> |
|
|
|
|
|
|
|
/* lora-irr headers */ |
|
|
|
#include <misc.h> |
|
|
|
#include <strobe_rng_init.h> |
|
|
|
|
|
|
|
|
|
|
|
char * |
|
|
|
findeol(char *pos, size_t len) |
|
|
|
{ |
|
|
@@ -202,6 +206,27 @@ radio_seed_rng(void) |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
static void |
|
|
|
analog_seed_rng(void) |
|
|
|
{ |
|
|
|
#if 1 |
|
|
|
uint16_t v; |
|
|
|
int i; |
|
|
|
|
|
|
|
for (i = 0; i < 256 / 2; i++) { |
|
|
|
/* |
|
|
|
* Capture some ADC data. If pin is floating, 0xfff |
|
|
|
* happens frequently, if pin is grounded, 0 happens |
|
|
|
* frequently, filter these values out. |
|
|
|
*/ |
|
|
|
do { |
|
|
|
v = AdcReadChannel(&Adc, ADC_CHANNEL_21); |
|
|
|
} while (v == 0 || v == 0xfff); |
|
|
|
strobe_seed_prng((uint8_t *)&v, sizeof v); |
|
|
|
} |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
int |
|
|
|
main(void) |
|
|
|
{ |
|
|
@@ -213,6 +238,8 @@ main(void) |
|
|
|
|
|
|
|
Radio.Init(&revents); |
|
|
|
|
|
|
|
analog_seed_rng(); |
|
|
|
|
|
|
|
radio_seed_rng(); |
|
|
|
|
|
|
|
strobe_rng_save(); |
|
|
|