From b413c8ddf8bfb730c74a06abf5a3e71f4c99494a Mon Sep 17 00:00:00 2001 From: Frank Leon Rose Date: Sun, 26 Jun 2016 10:23:28 -0400 Subject: [PATCH 1/2] Make default SPI freq 1MHz --- src/hal/hal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hal/hal.cpp b/src/hal/hal.cpp index 53bf359d..b86a341a 100644 --- a/src/hal/hal.cpp +++ b/src/hal/hal.cpp @@ -74,7 +74,7 @@ static void hal_io_check() { // ----------------------------------------------------------------------------- // SPI -static const SPISettings settings(10E6, MSBFIRST, SPI_MODE0); +static const SPISettings settings(1E6, MSBFIRST, SPI_MODE0); static void hal_spi_init () { SPI.begin(); From 375f3ec3dbe5b4b9f64334fb7b0545c4bbaf27e6 Mon Sep 17 00:00:00 2001 From: Frank Leon Rose Date: Mon, 27 Jun 2016 22:41:33 -0400 Subject: [PATCH 2/2] Move LMIC_SPI_FREQ to config.h --- src/hal/hal.cpp | 2 +- src/lmic/config.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/hal/hal.cpp b/src/hal/hal.cpp index b86a341a..327b3ce0 100644 --- a/src/hal/hal.cpp +++ b/src/hal/hal.cpp @@ -74,7 +74,7 @@ static void hal_io_check() { // ----------------------------------------------------------------------------- // SPI -static const SPISettings settings(1E6, MSBFIRST, SPI_MODE0); +static const SPISettings settings(LMIC_SPI_FREQ, MSBFIRST, SPI_MODE0); static void hal_spi_init () { SPI.begin(); diff --git a/src/lmic/config.h b/src/lmic/config.h index e3e4487d..1572e37e 100644 --- a/src/lmic/config.h +++ b/src/lmic/config.h @@ -20,6 +20,11 @@ #define US_PER_OSTICK (1 << US_PER_OSTICK_EXPONENT) #define OSTICKS_PER_SEC (1000000 / US_PER_OSTICK) +// Change the SPI clock speed if you encounter errors +// communicating with the radio. +// The standard range is 125kHz-8MHz, but some boards can go faster. +#define LMIC_SPI_FREQ 1E6 + // Enable this to allow using printf() to print to the given serial port // (or any other Print object). This can be easy for debugging. The // current implementation only works on AVR, though.