@@ -65,3 +65,13 @@ command: | |||||
``` | ``` | ||||
sudo openocd -f interface/ftdi/digilent-hs1.cfg -f interface/ftdi/swd-resistor-hack.cfg -f target/stm32l1.cfg -c "init" -c "reset init" -c "program build/lora.irr.elf verify reset exit" | sudo openocd -f interface/ftdi/digilent-hs1.cfg -f interface/ftdi/swd-resistor-hack.cfg -f target/stm32l1.cfg -c "init" -c "reset init" -c "program build/lora.irr.elf verify reset exit" | ||||
``` | ``` | ||||
Pins | |||||
---- | |||||
The [pinout guide for the Node151](http://resource.heltec.cn/download/LoRa_Node_151/LoRa_Node_151_Pinout_Diagram.pdf). | |||||
The pins PB5-7,9 are used as active low controls for the relays. | |||||
The pin PB15 is used as an analog input for an RNG source. This pin | |||||
should be grounded. |
@@ -195,7 +195,7 @@ void BoardInitMcu( void ) | |||||
MX_USB_DEVICE_Init(); | MX_USB_DEVICE_Init(); | ||||
AdcInit( &Adc, NC ); // Just initialize ADC | |||||
AdcInit( &Adc, PB_15 ); // Just initialize ADC | |||||
#if defined( SX1261MBXBAS ) || defined( SX1262MBXCAS ) || defined( SX1262MBXDAS ) | #if defined( SX1261MBXBAS ) || defined( SX1262MBXCAS ) || defined( SX1262MBXDAS ) | ||||
SpiInit( &SX126x.Spi, SPI_1, RADIO_MOSI, RADIO_MISO, RADIO_SCLK, NC ); | SpiInit( &SX126x.Spi, SPI_1, RADIO_MOSI, RADIO_MISO, RADIO_SCLK, NC ); | ||||
@@ -23,6 +23,8 @@ | |||||
#ifndef __BOARD_H__ | #ifndef __BOARD_H__ | ||||
#define __BOARD_H__ | #define __BOARD_H__ | ||||
#include <adc.h> | |||||
#ifdef __cplusplus | #ifdef __cplusplus | ||||
extern "C" | extern "C" | ||||
{ | { | ||||
@@ -125,6 +127,8 @@ uint8_t GetBoardPowerSource( void ); | |||||
*/ | */ | ||||
Version_t BoardGetVersion( void ); | Version_t BoardGetVersion( void ); | ||||
extern Adc_t Adc; | |||||
#ifdef __cplusplus | #ifdef __cplusplus | ||||
} | } | ||||
#endif | #endif | ||||
@@ -26,15 +26,19 @@ | |||||
#include <usbd_cdc_if.h> | #include <usbd_cdc_if.h> | ||||
#include <strobe_rng_init.h> | |||||
#include <string.h> | #include <string.h> | ||||
/* LoRaMac headers */ | |||||
#include <board.h> | #include <board.h> | ||||
#include <misc.h> | |||||
#include <adc.h> | |||||
#include <radio.h> | #include <radio.h> | ||||
#include <delay.h> | #include <delay.h> | ||||
/* lora-irr headers */ | |||||
#include <misc.h> | |||||
#include <strobe_rng_init.h> | |||||
char * | char * | ||||
findeol(char *pos, size_t len) | findeol(char *pos, size_t len) | ||||
{ | { | ||||
@@ -202,6 +206,27 @@ radio_seed_rng(void) | |||||
#endif | #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 | int | ||||
main(void) | main(void) | ||||
{ | { | ||||
@@ -213,6 +238,8 @@ main(void) | |||||
Radio.Init(&revents); | Radio.Init(&revents); | ||||
analog_seed_rng(); | |||||
radio_seed_rng(); | radio_seed_rng(); | ||||
strobe_rng_save(); | strobe_rng_save(); | ||||