diff --git a/boards/nrf52840_dk_modified.json b/boards/nrf52840_dk_modified.json
new file mode 100644
index 000000000..ce86e09f5
--- /dev/null
+++ b/boards/nrf52840_dk_modified.json
@@ -0,0 +1,46 @@
+{
+ "build": {
+ "arduino": {
+ "ldscript": "nrf52840_s140_v6.ld"
+ },
+ "core": "nRF5",
+ "cpu": "cortex-m4",
+ "extra_flags": "-DARDUINO_NRF52840_PCA10056 -DNRF52840_XXAA",
+ "f_cpu": "64000000L",
+ "hwids": [["0x239A", "0x4404"]],
+ "usb_product": "SimPPR",
+ "mcu": "nrf52840",
+ "variant": "pca10056-rc-clock",
+ "variants_dir": "variants",
+ "bsp": {
+ "name": "adafruit"
+ },
+ "softdevice": {
+ "sd_flags": "-DS140",
+ "sd_name": "s140",
+ "sd_version": "6.1.1",
+ "sd_fwid": "0x00B6"
+ },
+ "bootloader": {
+ "settings_addr": "0xFF000"
+ }
+ },
+ "connectivity": ["bluetooth"],
+ "debug": {
+ "jlink_device": "nRF52840_xxAA",
+ "onboard_tools": ["jlink"],
+ "svd_path": "nrf52840.svd"
+ },
+ "frameworks": ["arduino"],
+ "name": "A modified NRF52840-DK devboard (Adafruit BSP)",
+ "upload": {
+ "maximum_ram_size": 248832,
+ "maximum_size": 815104,
+ "require_upload_port": true,
+ "speed": 115200,
+ "protocol": "jlink",
+ "protocols": ["jlink", "nrfjprog", "stlink"]
+ },
+ "url": "https://meshtastic.org/",
+ "vendor": "Nordic Semi"
+}
diff --git a/boards/ppr.json b/boards/ppr.json
index 5050758f7..5283fdc4e 100644
--- a/boards/ppr.json
+++ b/boards/ppr.json
@@ -10,7 +10,7 @@
"hwids": [["0x239A", "0x4403"]],
"usb_product": "PPR",
"mcu": "nrf52840",
- "variant": "pca10056-rc-clock",
+ "variant": "ppr",
"variants_dir": "variants",
"bsp": {
"name": "adafruit"
diff --git a/docs/software/mesh-alg.md b/docs/software/mesh-alg.md
index d90d85c9c..48bc6721f 100644
--- a/docs/software/mesh-alg.md
+++ b/docs/software/mesh-alg.md
@@ -11,9 +11,9 @@ TODO:
- DONE read about mesh routing solutions (DSR and AODV)
- DONE read about general mesh flooding solutions (naive, MPR, geo assisted)
- DONE reread the disaster radio protocol docs - seems based on Babel (which is AODVish)
-- possibly dash7? https://www.slideshare.net/MaartenWeyn1/dash7-alliance-protocol-technical-presentation https://github.com/MOSAIC-LoPoW/dash7-ap-open-source-stack - does the opensource stack implement multihop routing? flooding? their discussion mailing list looks dead-dead
+- REJECTED - seems dying - possibly dash7? https://www.slideshare.net/MaartenWeyn1/dash7-alliance-protocol-technical-presentation https://github.com/MOSAIC-LoPoW/dash7-ap-open-source-stack - does the opensource stack implement multihop routing? flooding? their discussion mailing list looks dead-dead
- update duty cycle spreadsheet for our typical usecase
-- generalize naive flooding on top of radiohead or disaster.radio? (and fix radiohead to use my new driver)
+- DONE generalize naive flooding
a description of DSR: https://tools.ietf.org/html/rfc4728 good slides here: https://www.slideshare.net/ashrafmath/dynamic-source-routing
good description of batman protocol: https://www.open-mesh.org/projects/open-mesh/wiki/BATMANConcept
@@ -77,7 +77,6 @@ look into the literature for this idea specifically.
FIXME, merge into the above:
-
good description of batman protocol: https://www.open-mesh.org/projects/open-mesh/wiki/BATMANConcept
interesting paper on lora mesh: https://portal.research.lu.se/portal/files/45735775/paper.pdf
diff --git a/docs/software/nrf52-TODO.md b/docs/software/nrf52-TODO.md
index 4f4b6c409..69afcb946 100644
--- a/docs/software/nrf52-TODO.md
+++ b/docs/software/nrf52-TODO.md
@@ -5,8 +5,6 @@
Minimum items needed to make sure hardware is good.
- add a hard fault handler
-- use "variants" to get all gpio bindings
-- plug in correct variants for the real board
- Use the PMU driver on real hardware
- Use new radio driver on real hardware
- Use UC1701 LCD driver on real hardware. Still need to create at startup and probe on SPI
@@ -62,6 +60,8 @@ Needed to be fully functional at least at the same level of the ESP32 boards. At
Nice ideas worth considering someday...
+- Hook Segger RTT to the nordic logging framework. https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/debugging-with-real-time-terminal
+- Use nordic logging for DEBUG_MSG
- use the Jumper simulator to run meshes of simulated hardware: https://docs.jumper.io/docs/install.html
- make/find a multithread safe debug logging class (include remote logging and timestamps and levels). make each log event atomic.
- turn on freertos stack size checking
@@ -102,6 +102,8 @@ Nice ideas worth considering someday...
- DONE remove unused sx1262 lib from github
- at boot we are starting our message IDs at 1, rather we should start them at a random number. also, seed random based on timer. this could be the cause of our first message not seen bug.
- add a NEMA based GPS driver to test GPS
+- DONE use "variants" to get all gpio bindings
+- DONE plug in correct variants for the real board
```
diff --git a/platformio.ini b/platformio.ini
index 61b61d677..644195500 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -122,11 +122,9 @@ board = ttgo-lora32-v1
build_flags =
${esp32_base.build_flags} -D TTGO_LORA_V2
-
-; The NRF52840-dk development board
-[env:nrf52dk]
+; Common settings for NRF52 based targets
+[nrf52_base]
platform = nordicnrf52
-board = ppr
framework = arduino
debug_tool = jlink
build_type = debug ; I'm debugging with ICE a lot now
@@ -136,10 +134,6 @@ src_filter =
${env.src_filter} -
lib_ignore =
BluetoothOTA
-lib_deps =
- ${env.lib_deps}
- UC1701
- https://github.com/meshtastic/BQ25703A.git
monitor_port = /dev/ttyACM1
debug_extra_cmds =
@@ -150,3 +144,19 @@ debug_init_break =
;debug_init_break = tbreak loop
;debug_init_break = tbreak Reset_Handler
+; The NRF52840-dk development board
+[env:nrf52dk]
+extends = nrf52_base
+board = nrf52840_dk_modified
+
+; The PPR board
+[env:ppr]
+extends = nrf52_base
+board = ppr
+lib_deps =
+ ${env.lib_deps}
+ UC1701
+ https://github.com/meshtastic/BQ25703A.git
+
+
+
diff --git a/src/configuration.h b/src/configuration.h
index b02a1a00f..ca606c53a 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -51,27 +51,31 @@ along with this program. If not, see .
#define xstr(s) str(s)
#define str(s) #s
-// -----------------------------------------------------------------------------
-// OLED
-// -----------------------------------------------------------------------------
+#ifdef NRF52840_XXAA // All of the NRF52 targets are configured using variant.h, so this section shouldn't need to be
+ // board specific
-#define SSD1306_ADDRESS 0x3C
+//
+// Standard definitions for NRF52 targets
+//
-// Flip the screen upside down by default as it makes more sense on T-BEAM
-// devices. Comment this out to not rotate screen 180 degrees.
-#define FLIP_SCREEN_VERTICALLY
+#define NO_ESP32 // Don't use ESP32 libs (mainly bluetooth)
-// DEBUG LED
+// We bind to the GPS using variant.h instead for this platform (Serial1)
-#define LED_INVERTED 0 // define as 1 if LED is active low (on)
+// FIXME, not yet ready for NRF52
+#define RTC_DATA_ATTR
-// -----------------------------------------------------------------------------
-// GPS
-// -----------------------------------------------------------------------------
+#define LED_PIN PIN_LED1 // LED1 on nrf52840-DK
+#define BUTTON_PIN PIN_BUTTON1
+
+// FIXME, use variant.h defs for all of this!!! (even on the ESP32 targets)
+#else
+
+//
+// Standard definitions for ESP32 targets
+//
#define GPS_SERIAL_NUM 1
-#define GPS_BAUDRATE 9600
-
#define GPS_RX_PIN 34
#ifdef USE_JTAG
#define GPS_TX_PIN -1
@@ -88,6 +92,27 @@ along with this program. If not, see .
#define MOSI_GPIO 27
#define NSS_GPIO 18
+#endif
+
+// -----------------------------------------------------------------------------
+// OLED
+// -----------------------------------------------------------------------------
+
+#define SSD1306_ADDRESS 0x3C
+
+// Flip the screen upside down by default as it makes more sense on T-BEAM
+// devices. Comment this out to not rotate screen 180 degrees.
+#define FLIP_SCREEN_VERTICALLY
+
+// DEBUG LED
+#define LED_INVERTED 0 // define as 1 if LED is active low (on)
+
+// -----------------------------------------------------------------------------
+// GPS
+// -----------------------------------------------------------------------------
+
+#define GPS_BAUDRATE 9600
+
#if defined(TBEAM_V10)
// This string must exactly match the case used in release file names or the android updater won't work
#define HW_VENDOR "tbeam"
@@ -188,35 +213,22 @@ along with this program. If not, see .
0 // If defined, this will be used for user button presses, if your board doesn't have a physical switch, you can wire one
// between this pin and ground
-#define RESET_GPIO 14 // If defined, this pin will be used to reset the LORA radio
-#define RF95_IRQ_GPIO 26 // IRQ line for the LORA radio
-#define DIO1_GPIO 35 // DIO1 & DIO2 are not currently used, but they must be assigned to a pin number
-#define DIO2_GPIO 34 // DIO1 & DIO2 are not currently used, but they must be assigned to a pin number
-#elif defined(NRF52840_XXAA) // All of the NRF52 targets are configured using variant.h, so this section shouldn't need to be
- // board specific
+#define RESET_GPIO 14 // If defined, this pin will be used to reset the LORA radio
+#define RF95_IRQ_GPIO 26 // IRQ line for the LORA radio
+#define DIO1_GPIO 35 // DIO1 & DIO2 are not currently used, but they must be assigned to a pin number
+#define DIO2_GPIO 34 // DIO1 & DIO2 are not currently used, but they must be assigned to a pin number
+#endif
-// FIXME, use variant.h defs for all of this!!!
+#ifdef ARDUINO_NRF52840_PCA10056
// This string must exactly match the case used in release file names or the android updater won't work
-#define HW_VENDOR "nrf52"
-
-#define NO_ESP32 // Don't use ESP32 libs (mainly bluetooth)
-
-// We bind to the GPS using variant.h instead for this platform (Serial1)
-#undef GPS_RX_PIN
-#undef GPS_TX_PIN
-
-// FIXME, not yet ready for NRF52
-#define RTC_DATA_ATTR
-
-#define LED_PIN PIN_LED1 // LED1 on nrf52840-DK
-#define BUTTON_PIN PIN_BUTTON1
+#define HW_VENDOR "nrf52dk"
// This board uses 0 to be mean LED on
#undef LED_INVERTED
#define LED_INVERTED 1
-// Temporarily testing if we can build the RF95 driver for NRF52
+// Uncomment to confirm if we can build the RF95 driver for NRF52
#if 0
#define RESET_GPIO 14 // If defined, this pin will be used to reset the LORA radio
#define RF95_IRQ_GPIO 26 // IRQ line for the LORA radio
@@ -224,6 +236,10 @@ along with this program. If not, see .
#define DIO2_GPIO 34 // DIO1 & DIO2 are not currently used, but they must be assigned to a pin number
#endif
+#elif defined(ARDUINO_NRF52840_PPR)
+
+#define HW_VENDOR "ppr"
+
#endif
// -----------------------------------------------------------------------------
diff --git a/src/main.cpp b/src/main.cpp
index b6c03846f..a3c060b18 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -189,6 +189,8 @@ void setup()
readFromRTC(); // read the main CPU RTC at first (in case we can't get GPS time)
+// If we know we have a L80 GPS, don't try UBLOX
+#ifndef L80_RESET
// Init GPS - first try ublox
gps = new UBloxGPS();
if (!gps->setup()) {
@@ -199,6 +201,10 @@ void setup()
gps = new NEMAGPS();
gps->setup();
}
+#else
+ gps = new NEMAGPS();
+ gps->setup();
+#endif
service.init();
diff --git a/variants/ppr/variant.cpp b/variants/ppr/variant.cpp
index bd85e9713..f5f219e9b 100644
--- a/variants/ppr/variant.cpp
+++ b/variants/ppr/variant.cpp
@@ -19,31 +19,24 @@
*/
#include "variant.h"
+#include "nrf.h"
#include "wiring_constants.h"
#include "wiring_digital.h"
-#include "nrf.h"
-const uint32_t g_ADigitalPinMap[] =
-{
- // P0
- 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ,
- 8 , 9 , 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23,
- 24, 25, 26, 27, 28, 29, 30, 31,
-
- // P1
- 32, 33, 34, 35, 36, 37, 38, 39,
- 40, 41, 42, 43, 44, 45, 46, 47
-};
+const uint32_t g_ADigitalPinMap[] = {
+ // P0
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0xff, 12, 13, 0xff, 15, 0xff, 17, 18, 0xff, 20, 0xff, 22, 0xff, 24, 0xff, 26, 0xff, 28, 29,
+ 30, 31,
+ // P1
+ 32, 0xff, 34, 0xff, 36, 0xff, 38, 0xff, 0xff, 41, 42, 43, 0xff, 45};
void initVariant()
{
- // LED1 & LED2
- pinMode(PIN_LED1, OUTPUT);
- ledOff(PIN_LED1);
+ // LED1 & LED2
+ pinMode(PIN_LED1, OUTPUT);
+ ledOff(PIN_LED1);
- pinMode(PIN_LED2, OUTPUT);
- ledOff(PIN_LED2);;
+ pinMode(PIN_LED2, OUTPUT);
+ ledOff(PIN_LED2);
}
-
diff --git a/variants/ppr/variant.h b/variants/ppr/variant.h
index 5033a4ecc..b792172ee 100644
--- a/variants/ppr/variant.h
+++ b/variants/ppr/variant.h
@@ -39,40 +39,44 @@ extern "C" {
#endif // __cplusplus
// Number of pins defined in PinDescription array
-#define PINS_COUNT (48)
-#define NUM_DIGITAL_PINS (48)
-#define NUM_ANALOG_INPUTS (6)
+#define PINS_COUNT (46)
+#define NUM_DIGITAL_PINS (46)
+#define NUM_ANALOG_INPUTS (0)
#define NUM_ANALOG_OUTPUTS (0)
// LEDs
-#define PIN_LED1 (13)
-#define PIN_LED2 (14)
+#define PIN_LED1 (0)
+#define PIN_LED2 (1)
#define LED_BUILTIN PIN_LED1
#define LED_CONN PIN_LED2
#define LED_RED PIN_LED1
-#define LED_BLUE PIN_LED2
+#define LED_GREEN PIN_LED2
-#define LED_STATE_ON 0 // State when LED is litted
+// FIXME, bluefruit automatically blinks this led while connected. call AdafruitBluefruit::autoConnLed to change this.
+#define LED_BLUE LED_GREEN
+
+#define LED_STATE_ON 1 // State when LED is litted
/*
* Buttons
*/
-#define PIN_BUTTON1 11
-#define PIN_BUTTON2 12
-#define PIN_BUTTON3 24
-#define PIN_BUTTON4 25
+#define PIN_BUTTON1 4 // center
+#define PIN_BUTTON2 2
+#define PIN_BUTTON3 3
+#define PIN_BUTTON4 5
+#define PIN_BUTTON5 6
/*
* Analog pins
*/
-#define PIN_A0 (3)
-#define PIN_A1 (4)
-#define PIN_A2 (28)
-#define PIN_A3 (29)
-#define PIN_A4 (30)
-#define PIN_A5 (31)
+#define PIN_A0 (0xff)
+#define PIN_A1 (0xff)
+#define PIN_A2 (0xff)
+#define PIN_A3 (0xff)
+#define PIN_A4 (0xff)
+#define PIN_A5 (0xff)
#define PIN_A6 (0xff)
#define PIN_A7 (0xff)
@@ -87,9 +91,9 @@ static const uint8_t A7 = PIN_A7;
#define ADC_RESOLUTION 14
// Other pins
-#define PIN_AREF (2)
-#define PIN_NFC1 (9)
-#define PIN_NFC2 (10)
+#define PIN_AREF (0xff)
+//#define PIN_NFC1 (9)
+//#define PIN_NFC2 (10)
static const uint8_t AREF = PIN_AREF;
@@ -97,24 +101,24 @@ static const uint8_t AREF = PIN_AREF;
* Serial interfaces
*/
-// Arduino Header D0, D1
-#define PIN_SERIAL1_RX (33) // P1.01
-#define PIN_SERIAL1_TX (34) // P1.02
+// GPS is on Serial1
+#define PIN_SERIAL1_RX (8)
+#define PIN_SERIAL1_TX (9)
// Connected to Jlink CDC
-#define PIN_SERIAL2_RX (8)
-#define PIN_SERIAL2_TX (6)
+//#define PIN_SERIAL2_RX (8)
+//#define PIN_SERIAL2_TX (6)
/*
* SPI Interfaces
*/
#define SPI_INTERFACES_COUNT 1
-#define PIN_SPI_MISO (46)
-#define PIN_SPI_MOSI (45)
-#define PIN_SPI_SCK (47)
+#define PIN_SPI_MISO (15)
+#define PIN_SPI_MOSI (13)
+#define PIN_SPI_SCK (12)
-static const uint8_t SS = 44;
+// static const uint8_t SS = 44;
static const uint8_t MOSI = PIN_SPI_MOSI;
static const uint8_t MISO = PIN_SPI_MISO;
static const uint8_t SCK = PIN_SPI_SCK;
@@ -124,8 +128,27 @@ static const uint8_t SCK = PIN_SPI_SCK;
*/
#define WIRE_INTERFACES_COUNT 1
-#define PIN_WIRE_SDA (26)
-#define PIN_WIRE_SCL (27)
+#define PIN_WIRE_SDA (32 + 2)
+#define PIN_WIRE_SCL (32)
+
+// CUSTOM GPIOs the SX1262
+#define SX1262_CS (10)
+#define SX1262_DIO1 (20)
+#define SX1262_DIO2 (26)
+#define SX1262_BUSY (18)
+#define SX1262_RESET (17)
+// #define SX1262_ANT_SW (32 + 10)
+#define SX1262_RXEN (22)
+#define SX1262_TXEN (24)
+
+// ERC12864-10 LCD
+#define ERC12864_CS (32 + 4)
+#define ERC12864_RESET (32 + 6)
+#define ERC12864_CD (32 + 9)
+
+// L80 GPS
+#define L80_PPS (28)
+#define L80_RESET (29)
#ifdef __cplusplus
}