diff --git a/platformio.ini b/platformio.ini
index c235f94cd..a74eb6018 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -9,7 +9,7 @@
; https://docs.platformio.org/page/projectconf.html
[platformio]
-default_envs = cubecellplus ; Note: the github actions CI test build can't yet build NRF52 targets
+default_envs = nrf52dk ; Note: the github actions CI test build can't yet build NRF52 targets
[common]
; common is not currently used
@@ -131,9 +131,9 @@ platform = https://github.com/HelTecAutomation/platform-asrmicro650x.git ; we us
framework = arduino
board = cubecell_board_plus
; FIXME, bug in cubecell arduino - they are supposed to set ARDUINO
-build_flags = ${env.build_flags} -DARDUINO=100
+build_flags = ${env.build_flags} -DARDUINO=100 -Isrc/cubecell
src_filter =
- ${env.src_filter} -
+ ${env.src_filter} - -
; Common settings for NRF52 based targets
[nrf52_base]
diff --git a/src/WorkerThread.h b/src/WorkerThread.h
index afe5c2b69..ab1864869 100644
--- a/src/WorkerThread.h
+++ b/src/WorkerThread.h
@@ -1,7 +1,7 @@
#include
+#include "freertosinc.h"
-// FIXME - ugly check to see if we have freertos
-#ifdef configUSE_PREEMPTION
+#ifdef HAS_FREE_RTOS
class Thread
{
diff --git a/src/configuration.h b/src/configuration.h
index 807dd8fcd..09132fd41 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -81,13 +81,11 @@ along with this program. If not, see .
#define NO_ESP32 // Don't use ESP32 libs (mainly bluetooth)
-// We bind to the GPS using variant.h instead for this platform (Serial1)
-
// 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 LED_PIN -1 // FIXME totally bogus
+#define BUTTON_PIN -1
#else
@@ -189,7 +187,7 @@ along with this program. If not, see .
#define HW_VENDOR "heltec"
// the default ESP32 Pin of 15 is the Oled SCL, set to 36 and 37 and works fine.
-//Tested on Neo6m module.
+// Tested on Neo6m module.
#undef GPS_RX_PIN
#undef GPS_TX_PIN
#define GPS_RX_PIN 36
diff --git a/src/cubecell/FS.h b/src/cubecell/FS.h
new file mode 100644
index 000000000..3f72219a1
--- /dev/null
+++ b/src/cubecell/FS.h
@@ -0,0 +1 @@
+// Placeholder FIXME
\ No newline at end of file
diff --git a/src/freertosinc.h b/src/freertosinc.h
index 6536b91c9..818eae6b3 100644
--- a/src/freertosinc.h
+++ b/src/freertosinc.h
@@ -1,19 +1,30 @@
#pragma once
-// The FreeRTOS includes are in a different directory on ESP32 and I can't figure out how to make that work with platformio gcc options
-// so this is my quick hack to make things work
+// The FreeRTOS includes are in a different directory on ESP32 and I can't figure out how to make that work with platformio gcc
+// options so this is my quick hack to make things work
#ifdef ARDUINO_ARCH_ESP32
+#define HAS_FREE_RTOS
#include
-#include
-#include
#include
+#include
+#include
#else
// not yet supported on cubecell
#ifndef CubeCell_BoardPlus
+#define HAS_FREE_RTOS
#include
-#include
-#include
#include
+#include
+#include
+#else
+
+#include
+
+typedef uint32_t TickType_t;
+typedef uint32_t BaseType_t;
+
+#define portMAX_DELAY UINT32_MAX
+
#endif
#endif
\ No newline at end of file
diff --git a/src/main.cpp b/src/main.cpp
index e6820e841..16aa20998 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -44,6 +44,13 @@
#include "BluetoothUtil.h"
#endif
+#include "RF95Interface.h"
+#include "SX1262Interface.h"
+
+#ifdef NRF52_SERIES
+#include "variant.h"
+#endif
+
// We always create a screen object, but we only init it if we find the hardware
meshtastic::Screen screen(SSD1306_ADDRESS);
@@ -117,12 +124,7 @@ static uint32_t ledBlinker()
Periodic ledPeriodic(ledBlinker);
-#include "RF95Interface.h"
-#include "SX1262Interface.h"
-#ifdef NO_ESP32
-#include "variant.h"
-#endif
void setup()
{
diff --git a/src/mesh/MemoryPool.h b/src/mesh/MemoryPool.h
index 4fefb4c4d..dc6305d17 100644
--- a/src/mesh/MemoryPool.h
+++ b/src/mesh/MemoryPool.h
@@ -107,6 +107,7 @@ template class MemoryPool : public Allocator
maxElements); // sanity check to make sure a programmer didn't free something that didn't come from this pool
}
+#ifdef HAS_FREE_RTOS
/// Return a buffer from an ISR, if higherPriWoken is set to true you have some work to do ;-)
void releaseFromISR(T *p, BaseType_t *higherPriWoken)
{
@@ -115,6 +116,7 @@ template class MemoryPool : public Allocator
(size_t)(p - buf) <
maxElements); // sanity check to make sure a programmer didn't free something that didn't come from this pool
}
+#endif
protected:
/// Return a queable object which has been prefilled with zeros - allow timeout to wait for available buffers (you
diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp
index 2c2204c67..9bebda112 100644
--- a/src/mesh/NodeDB.cpp
+++ b/src/mesh/NodeDB.cpp
@@ -3,7 +3,6 @@
#include
#include "FS.h"
-#include "SPIFFS.h"
#include "CryptoEngine.h"
#include "GPS.h"
@@ -34,11 +33,14 @@ DeviceState versions used to be defined in the .proto file but really only this
#define DEVICESTATE_MIN_VER DEVICESTATE_CUR_VER
#ifndef NO_ESP32
+// ESP32 version
+#include "SPIFFS.h"
#define FS SPIFFS
#define FSBegin() FS.begin(true)
#define FILE_O_WRITE "w"
#define FILE_O_READ "r"
#else
+// NRF52 version
#include "InternalFileSystem.h"
#define FS InternalFS
#define FSBegin() FS.begin()
diff --git a/src/mesh/PacketHistory.h b/src/mesh/PacketHistory.h
index 3cc81084f..d390915a2 100644
--- a/src/mesh/PacketHistory.h
+++ b/src/mesh/PacketHistory.h
@@ -35,9 +35,8 @@ class PacketRecordOrderFunction
// If the timer ticks have rolled over the difference between times will be _enormous_. Handle that case specially
uint32_t t1 = p1.rxTimeMsec, t2 = p2.rxTimeMsec;
- if (abs(t1 - t2) >
- UINT32_MAX /
- 2) { // time must have rolled over, swap them because the new little number is 'bigger' than the old big number
+ if (t1 - t2 > UINT32_MAX / 2) {
+ // time must have rolled over, swap them because the new little number is 'bigger' than the old big number
t1 = t2;
t2 = p1.rxTimeMsec;
}
diff --git a/src/mesh/PointerQueue.h b/src/mesh/PointerQueue.h
index ef97eac41..b587ac649 100644
--- a/src/mesh/PointerQueue.h
+++ b/src/mesh/PointerQueue.h
@@ -18,6 +18,7 @@ template class PointerQueue : public TypedQueue
return this->dequeue(&p, maxWait) ? p : nullptr;
}
+#ifdef HAS_FREE_RTOS
// returns a ptr or null if the queue was empty
T *dequeuePtrFromISR(BaseType_t *higherPriWoken)
{
@@ -25,4 +26,5 @@ template class PointerQueue : public TypedQueue
return this->dequeueFromISR(&p, higherPriWoken) ? p : nullptr;
}
+#endif
};
diff --git a/src/mesh/RadioLibInterface.h b/src/mesh/RadioLibInterface.h
index 706fcdf0d..cb6991d43 100644
--- a/src/mesh/RadioLibInterface.h
+++ b/src/mesh/RadioLibInterface.h
@@ -3,6 +3,10 @@
#include "PeriodicTask.h"
#include "RadioInterface.h"
+#ifdef CubeCell_BoardPlus
+#define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
+#endif
+
#include
// ESP32 has special rules about ISR code
diff --git a/src/mesh/ReliableRouter.h b/src/mesh/ReliableRouter.h
index 51cb587a8..beb58a8ed 100644
--- a/src/mesh/ReliableRouter.h
+++ b/src/mesh/ReliableRouter.h
@@ -48,7 +48,7 @@ struct PendingPacket {
PendingPacket() {}
PendingPacket(MeshPacket *p);
- void setNextTx() { nextTxMsec = millis() + random(20 * 1000, 22 * 1000); }
+ void setNextTx() { nextTxMsec = millis() + random(20 * 1000L, 22 * 1000L); }
};
class GlobalPacketIdHashFunction
diff --git a/src/mesh/TypedQueue.h b/src/mesh/TypedQueue.h
index a16e624f9..90ed07f10 100644
--- a/src/mesh/TypedQueue.h
+++ b/src/mesh/TypedQueue.h
@@ -5,6 +5,8 @@
#include "freertosinc.h"
+#ifdef HAS_FREE_RTOS
+
/**
* A wrapper for freertos queues. Note: each element object should be small
* and POD (Plain Old Data type) as elements are memcpied by value.
@@ -35,3 +37,45 @@ template class TypedQueue
bool dequeueFromISR(T *p, BaseType_t *higherPriWoken) { return xQueueReceiveFromISR(h, p, higherPriWoken); }
};
+
+#else
+
+#include
+
+/**
+ * A wrapper for freertos queues. Note: each element object should be small
+ * and POD (Plain Old Data type) as elements are memcpied by value.
+ */
+template class TypedQueue
+{
+ std::queue q;
+
+ public:
+ TypedQueue(int maxElements) {}
+
+ // int numFree() { return uxQueueSpacesAvailable(h); }
+
+ bool isEmpty() { return q.empty(); }
+
+ bool enqueue(T x, TickType_t maxWait = portMAX_DELAY)
+ {
+ q.push(x);
+ return true;
+ }
+
+ // bool enqueueFromISR(T x, BaseType_t *higherPriWoken) { return xQueueSendToBackFromISR(h, &x, higherPriWoken) == pdTRUE; }
+
+ bool dequeue(T *p, TickType_t maxWait = portMAX_DELAY)
+ {
+ if (isEmpty())
+ return false;
+ else {
+ *p = q.front();
+ q.pop();
+ return true;
+ }
+ }
+
+ // bool dequeueFromISR(T *p, BaseType_t *higherPriWoken) { return xQueueReceiveFromISR(h, p, higherPriWoken); }
+};
+#endif
diff --git a/src/nrf52/PmuBQ25703A.cpp b/src/nrf52/PmuBQ25703A.cpp
deleted file mode 100644
index c369ca2b1..000000000
--- a/src/nrf52/PmuBQ25703A.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-#ifdef ARDUINO_NRF52840_PPR
-#include "PmuBQ25703A.h"
-#include
-
-// Default address for device. Note, it is without read/write bit. When read with analyser,
-// this will appear 1 bit shifted to the left
-#define BQ25703ADevaddr 0xD6
-
-const byte Lorro_BQ25703A::BQ25703Aaddr = BQ25703ADevaddr;
-
-void PmuBQ25703A::init()
-{
- // Set the watchdog timer to not have a timeout
- regs.chargeOption0.set_WDTMR_ADJ(0);
- assert(writeRegEx(regs.chargeOption0)); // FIXME, instead log a critical hw failure and reboot
- delay(15); // FIXME, why are these delays required? - check datasheet
-
- // Set the ADC on IBAT and PSYS to record values
- // When changing bitfield values, call the writeRegEx function
- // This is so you can change all the bits you want before sending out the byte.
- regs.chargeOption1.set_EN_IBAT(1);
- regs.chargeOption1.set_EN_PSYS(1);
- assert(writeRegEx(regs.chargeOption1));
- delay(15);
-
- // Set ADC to make continuous readings. (uses more power)
- regs.aDCOption.set_ADC_CONV(1);
- // Set individual ADC registers to read. All have default off.
- regs.aDCOption.set_EN_ADC_VBUS(1);
- regs.aDCOption.set_EN_ADC_PSYS(1);
- regs.aDCOption.set_EN_ADC_IDCHG(1);
- regs.aDCOption.set_EN_ADC_ICHG(1);
- regs.aDCOption.set_EN_ADC_VSYS(1);
- regs.aDCOption.set_EN_ADC_VBAT(1);
- // Once bits have been twiddled, send bytes to device
- assert(writeRegEx(regs.aDCOption));
- delay(15);
-}
-
-#endif
-
-/*
-
-
-//Initialise the device and library
-Lorro_BQ25703A BQ25703A;
-
-//Instantiate with reference to global set
-extern Lorro_BQ25703A::Regt BQ25703Areg;
-
-uint32_t previousMillis;
-uint16_t loopInterval = 1000;
-
-void setup() {
-
- Serial.begin(115200);
-
-
-}
-
-void loop() {
-
- uint32_t currentMillis = millis();
-
- if( currentMillis - previousMillis > loopInterval ){
- previousMillis = currentMillis;
-
- Serial.print( "Voltage of VBUS: " );
- Serial.print( BQ25703Areg.aDCVBUSPSYS.get_VBUS() );
- Serial.println( "mV" );
- delay( 15 );
-
- Serial.print( "System power usage: " );
- Serial.print( BQ25703Areg.aDCVBUSPSYS.get_sysPower() );
- Serial.println( "W" );
- delay( 15 );
-
- Serial.print( "Voltage of VBAT: " );
- Serial.print( BQ25703Areg.aDCVSYSVBAT.get_VBAT() );
- Serial.println( "mV" );
- delay( 15 );
-
- Serial.print( "Voltage of VSYS: " );
- Serial.print( BQ25703Areg.aDCVSYSVBAT.get_VSYS() );
- Serial.println( "mV" );
- delay( 15 );
-
- Serial.print( "Charging current: " );
- Serial.print( BQ25703Areg.aDCIBAT.get_ICHG() );
- Serial.println( "mA" );
- delay( 15 );
-
- Serial.print( "Voltage of VSYS: " );
- Serial.print( BQ25703Areg.aDCIBAT.get_IDCHG() );
- Serial.println( "mA" );
- delay( 15 );
-
- }
-
-}*/
\ No newline at end of file
diff --git a/src/nrf52/PmuBQ25703A.h b/src/nrf52/PmuBQ25703A.h
deleted file mode 100644
index 804b85bf9..000000000
--- a/src/nrf52/PmuBQ25703A.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#pragma once
-
-#include
-
-class PmuBQ25703A : private Lorro_BQ25703A
-{
- Lorro_BQ25703A::Regt regs;
-
- public:
- /**
- * Configure the PMU for our board
- */
- void init();
-
- // Methods to have a common API with AXP192
- bool isBatteryConnect() { return true; } // FIXME
- bool isVBUSPlug() { return true; }
- bool isChargeing() { return true; } // FIXME, intentional misspelling
-
- /// battery voltage in mV
- int getBattVoltage() { return 3200; }
-};
diff --git a/src/nrf52/SPIFFS.h b/src/nrf52/SPIFFS.h
deleted file mode 100644
index 819693660..000000000
--- a/src/nrf52/SPIFFS.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#pragma once
-
-// FIXME - make a FS abstraction for NRF52
\ No newline at end of file