From 80b14c0a6fc4cc04240dac80f701624e82a19f8c Mon Sep 17 00:00:00 2001 From: geeksville Date: Thu, 9 Jul 2020 21:27:34 -0700 Subject: [PATCH] add support for adafruit feather nrf52832 - which is close to a RAK815 --- platformio.ini | 7 ++++++- src/configuration.h | 10 +++++++++- src/gps/GPS.cpp | 8 +++++--- src/gps/GPS.h | 2 +- src/gps/NEMAGPS.cpp | 5 ++--- src/gps/UBloxGPS.cpp | 10 +++++----- src/main.cpp | 2 +- src/nrf52/main-nrf52.cpp | 5 ++++- 8 files changed, 33 insertions(+), 16 deletions(-) diff --git a/platformio.ini b/platformio.ini index 91274a30b..ae32dba12 100644 --- a/platformio.ini +++ b/platformio.ini @@ -9,7 +9,7 @@ ; https://docs.platformio.org/page/projectconf.html [platformio] -default_envs = nrf52840dk ; Note: the github actions CI test build can't yet build NRF52 targets +default_envs = feather_nrf52832 ; Note: the github actions CI test build can't yet build NRF52 targets [common] ; common is not currently used @@ -178,6 +178,11 @@ board = nrf52840_dk extends = nrf52_base board = nrf52840_dk_modified +; Note: By default no lora device is created for this build - it uses a simulated interface +[env:feather_nrf52832] +extends = nrf52_base +board = adafruit_feather_nrf52832 + # For experimenting with RAM sizes # board_build.ldscript = linker/nrf52840_s140_sim832.ld diff --git a/src/configuration.h b/src/configuration.h index c36d4a18f..14894298f 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -55,7 +55,7 @@ along with this program. If not, see . /// Convert a preprocessor name into a quoted string and if that string is empty use "unset" #define optstr(s) (xstr(s)[0] ? xstr(s) : "unset") -#ifdef NRF52840_XXAA // All of the NRF52 targets are configured using variant.h, so this section shouldn't need to be +#ifdef NRF52_SERIES // All of the NRF52 targets are configured using variant.h, so this section shouldn't need to be // board specific // @@ -74,7 +74,11 @@ along with this program. If not, see . #define RTC_DATA_ATTR #define LED_PIN PIN_LED1 // LED1 on nrf52840-DK + +// If the variant filed defines as standard button +#ifdef PIN_BUTTON1 #define BUTTON_PIN PIN_BUTTON1 +#endif // FIXME, use variant.h defs for all of this!!! (even on the ESP32 targets) #elif defined(CubeCell_BoardPlus) @@ -283,6 +287,10 @@ along with this program. If not, see . #define HW_VENDOR "ppr" +#elif NRF52_SERIES + +#define HW_VENDOR "nrf52unknown" // FIXME - unknown nrf52 board + #endif // ----------------------------------------------------------------------------- diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index e4f187c05..b72d27d74 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -7,10 +7,12 @@ #ifdef GPS_RX_PIN HardwareSerial _serial_gps_real(GPS_SERIAL_NUM); -HardwareSerial &GPS::_serial_gps = _serial_gps_real; +HardwareSerial *GPS::_serial_gps = &_serial_gps_real; +#elif defined(NRF52840_XXAA) +// Assume NRF52840 +HardwareSerial *GPS::_serial_gps = &Serial1; #else -// Assume NRF52 -HardwareSerial &GPS::_serial_gps = Serial1; +HardwareSerial *GPS::_serial_gps = NULL; #endif bool timeSetFromGPS; // We try to set our time from GPS each time we wake from sleep diff --git a/src/gps/GPS.h b/src/gps/GPS.h index 14e6c9dfe..cd6629995 100644 --- a/src/gps/GPS.h +++ b/src/gps/GPS.h @@ -30,7 +30,7 @@ class GPS : public Observable protected: bool hasValidLocation = false; // default to false, until we complete our first read - static HardwareSerial &_serial_gps; + static HardwareSerial *_serial_gps; public: int32_t latitude = 0, longitude = 0; // as an int mult by 1e-7 to get value as double diff --git a/src/gps/NEMAGPS.cpp b/src/gps/NEMAGPS.cpp index 144b5e6b5..1645a1656 100644 --- a/src/gps/NEMAGPS.cpp +++ b/src/gps/NEMAGPS.cpp @@ -13,9 +13,8 @@ static int32_t toDegInt(RawDegrees d) void NEMAGPS::loop() { - - while (_serial_gps.available() > 0) { - int c = _serial_gps.read(); + while (_serial_gps->available() > 0) { + int c = _serial_gps->read(); // Serial.write(c); reader.encode(c); } diff --git a/src/gps/UBloxGPS.cpp b/src/gps/UBloxGPS.cpp index 8c3bb9bac..8f52ace35 100644 --- a/src/gps/UBloxGPS.cpp +++ b/src/gps/UBloxGPS.cpp @@ -10,20 +10,20 @@ UBloxGPS::UBloxGPS() : concurrency::PeriodicTask() bool UBloxGPS::setup() { #ifdef GPS_RX_PIN - _serial_gps.begin(GPS_BAUDRATE, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN); + _serial_gps->begin(GPS_BAUDRATE, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN); #else - _serial_gps.begin(GPS_BAUDRATE); + _serial_gps->begin(GPS_BAUDRATE); #endif // _serial_gps.setRxBufferSize(1024); // the default is 256 // ublox.enableDebugging(Serial); // note: the lib's implementation has the wrong docs for what the return val is // it is not a bool, it returns zero for success - isConnected = ublox.begin(_serial_gps); + isConnected = ublox.begin(*_serial_gps); // try a second time, the ublox lib serial parsing is buggy? if (!isConnected) - isConnected = ublox.begin(_serial_gps); + isConnected = ublox.begin(*_serial_gps); if (isConnected) { DEBUG_MSG("Connected to UBLOX GPS successfully\n"); @@ -35,7 +35,7 @@ bool UBloxGPS::setup() // GPS_TX connected) ublox.factoryReset(); delay(3000); - isConnected = ublox.begin(_serial_gps); + isConnected = ublox.begin(*_serial_gps); DEBUG_MSG("Factory reset success=%d\n", isConnected); ok = ublox.saveConfiguration(3000); assert(ok); diff --git a/src/main.cpp b/src/main.cpp index 8e6864bed..fcedb3d82 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -172,7 +172,7 @@ void initWifi() } } } - } else + } else DEBUG_MSG("Not using WIFI\n"); #endif } diff --git a/src/nrf52/main-nrf52.cpp b/src/nrf52/main-nrf52.cpp index 93798462a..af50753a9 100644 --- a/src/nrf52/main-nrf52.cpp +++ b/src/nrf52/main-nrf52.cpp @@ -3,7 +3,10 @@ #include #include #include -#include + +#ifdef NRF52840_XXAA +// #include +#endif // #define USE_SOFTDEVICE