|
|
@@ -36,7 +36,6 @@ |
|
|
|
|
|
|
|
/* lora-irr headers */ |
|
|
|
#include <misc.h> |
|
|
|
#include <strobe_rng_init.h> |
|
|
|
|
|
|
|
|
|
|
|
char * |
|
|
@@ -67,6 +66,7 @@ txdone(void) |
|
|
|
{ |
|
|
|
|
|
|
|
usb_printf("txdone\r\n"); |
|
|
|
Radio.Rx(0); |
|
|
|
} |
|
|
|
|
|
|
|
void |
|
|
@@ -186,64 +186,14 @@ process_line(char *start, char *end) |
|
|
|
usb_printf("line: %.*s", end - start, start); |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
* Seed the randomness from the radio. This is not a great |
|
|
|
* seed, and is hard to gauge how much randomness is really |
|
|
|
* there. Assuming about 1 bit per 8 bits looks pretty safe, |
|
|
|
* so add 256 * 8 / 32 words. |
|
|
|
*/ |
|
|
|
static void |
|
|
|
radio_seed_rng(void) |
|
|
|
{ |
|
|
|
#if 1 |
|
|
|
uint32_t v; |
|
|
|
int i; |
|
|
|
|
|
|
|
for (i = 0; i < 256 * 8 / 32; i++) { |
|
|
|
v = Radio.Random(); |
|
|
|
strobe_seed_prng((uint8_t *)&v, sizeof v); |
|
|
|
} |
|
|
|
#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) |
|
|
|
{ |
|
|
|
uint8_t bytes[8]; |
|
|
|
|
|
|
|
strobe_rng_init(); |
|
|
|
|
|
|
|
BoardInitMcu(); |
|
|
|
|
|
|
|
Radio.Init(&revents); |
|
|
|
|
|
|
|
analog_seed_rng(); |
|
|
|
|
|
|
|
radio_seed_rng(); |
|
|
|
|
|
|
|
strobe_rng_save(); |
|
|
|
|
|
|
|
/* turn on LED */ |
|
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8, GPIO_PIN_SET); |
|
|
|
|
|
|
@@ -252,9 +202,6 @@ main(void) |
|
|
|
|
|
|
|
usb_printf("starting...\r\n"); |
|
|
|
|
|
|
|
bare_strobe_randomize(bytes, sizeof bytes); |
|
|
|
hexdump(bytes, sizeof bytes); |
|
|
|
usb_printf("\r\n"); |
|
|
|
#endif |
|
|
|
|
|
|
|
uint32_t v; |
|
|
|