add support for adafruit feather nrf52832 - which is close to a RAK815

This commit is contained in:
geeksville 2020-07-09 21:27:34 -07:00
parent 6954d0d5f4
commit 80b14c0a6f
8 changed files with 33 additions and 16 deletions

View File

@ -9,7 +9,7 @@
; https://docs.platformio.org/page/projectconf.html ; https://docs.platformio.org/page/projectconf.html
[platformio] [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]
; common is not currently used ; common is not currently used
@ -178,6 +178,11 @@ board = nrf52840_dk
extends = nrf52_base extends = nrf52_base
board = nrf52840_dk_modified 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 # For experimenting with RAM sizes
# board_build.ldscript = linker/nrf52840_s140_sim832.ld # board_build.ldscript = linker/nrf52840_s140_sim832.ld

View File

@ -55,7 +55,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/// Convert a preprocessor name into a quoted string and if that string is empty use "unset" /// 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") #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 // board specific
// //
@ -74,7 +74,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define RTC_DATA_ATTR #define RTC_DATA_ATTR
#define LED_PIN PIN_LED1 // LED1 on nrf52840-DK #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 #define BUTTON_PIN PIN_BUTTON1
#endif
// FIXME, use variant.h defs for all of this!!! (even on the ESP32 targets) // FIXME, use variant.h defs for all of this!!! (even on the ESP32 targets)
#elif defined(CubeCell_BoardPlus) #elif defined(CubeCell_BoardPlus)
@ -283,6 +287,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define HW_VENDOR "ppr" #define HW_VENDOR "ppr"
#elif NRF52_SERIES
#define HW_VENDOR "nrf52unknown" // FIXME - unknown nrf52 board
#endif #endif
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View File

@ -7,10 +7,12 @@
#ifdef GPS_RX_PIN #ifdef GPS_RX_PIN
HardwareSerial _serial_gps_real(GPS_SERIAL_NUM); 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 #else
// Assume NRF52 HardwareSerial *GPS::_serial_gps = NULL;
HardwareSerial &GPS::_serial_gps = Serial1;
#endif #endif
bool timeSetFromGPS; // We try to set our time from GPS each time we wake from sleep bool timeSetFromGPS; // We try to set our time from GPS each time we wake from sleep

View File

@ -30,7 +30,7 @@ class GPS : public Observable<void *>
protected: protected:
bool hasValidLocation = false; // default to false, until we complete our first read bool hasValidLocation = false; // default to false, until we complete our first read
static HardwareSerial &_serial_gps; static HardwareSerial *_serial_gps;
public: public:
int32_t latitude = 0, longitude = 0; // as an int mult by 1e-7 to get value as double int32_t latitude = 0, longitude = 0; // as an int mult by 1e-7 to get value as double

View File

@ -13,9 +13,8 @@ static int32_t toDegInt(RawDegrees d)
void NEMAGPS::loop() void NEMAGPS::loop()
{ {
while (_serial_gps->available() > 0) {
while (_serial_gps.available() > 0) { int c = _serial_gps->read();
int c = _serial_gps.read();
// Serial.write(c); // Serial.write(c);
reader.encode(c); reader.encode(c);
} }

View File

@ -10,20 +10,20 @@ UBloxGPS::UBloxGPS() : concurrency::PeriodicTask()
bool UBloxGPS::setup() bool UBloxGPS::setup()
{ {
#ifdef GPS_RX_PIN #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 #else
_serial_gps.begin(GPS_BAUDRATE); _serial_gps->begin(GPS_BAUDRATE);
#endif #endif
// _serial_gps.setRxBufferSize(1024); // the default is 256 // _serial_gps.setRxBufferSize(1024); // the default is 256
// ublox.enableDebugging(Serial); // ublox.enableDebugging(Serial);
// note: the lib's implementation has the wrong docs for what the return val is // 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 // 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? // try a second time, the ublox lib serial parsing is buggy?
if (!isConnected) if (!isConnected)
isConnected = ublox.begin(_serial_gps); isConnected = ublox.begin(*_serial_gps);
if (isConnected) { if (isConnected) {
DEBUG_MSG("Connected to UBLOX GPS successfully\n"); DEBUG_MSG("Connected to UBLOX GPS successfully\n");
@ -35,7 +35,7 @@ bool UBloxGPS::setup()
// GPS_TX connected) // GPS_TX connected)
ublox.factoryReset(); ublox.factoryReset();
delay(3000); delay(3000);
isConnected = ublox.begin(_serial_gps); isConnected = ublox.begin(*_serial_gps);
DEBUG_MSG("Factory reset success=%d\n", isConnected); DEBUG_MSG("Factory reset success=%d\n", isConnected);
ok = ublox.saveConfiguration(3000); ok = ublox.saveConfiguration(3000);
assert(ok); assert(ok);

View File

@ -172,7 +172,7 @@ void initWifi()
} }
} }
} }
} else } else
DEBUG_MSG("Not using WIFI\n"); DEBUG_MSG("Not using WIFI\n");
#endif #endif
} }

View File

@ -3,7 +3,10 @@
#include <assert.h> #include <assert.h>
#include <ble_gap.h> #include <ble_gap.h>
#include <memory.h> #include <memory.h>
#include <nrf52840.h>
#ifdef NRF52840_XXAA
// #include <nrf52840.h>
#endif
// #define USE_SOFTDEVICE // #define USE_SOFTDEVICE