From 1c63a7067362d1ff40152c2366bb0dc99d6b1bde Mon Sep 17 00:00:00 2001 From: geeksville Date: Fri, 5 Jun 2020 17:30:09 -0700 Subject: [PATCH] cubecell WIP --- docs/hardware/cubecell-TODO.md | 6 ++++++ platformio.ini | 12 +++++++++++- src/WorkerThread.cpp | 4 ++++ src/WorkerThread.h | 7 ++++++- src/configuration.h | 20 +++++++++++++++++++- src/freertosinc.h | 3 +++ src/lock.cpp | 15 +++++++++++++++ src/lock.h | 2 ++ 8 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 docs/hardware/cubecell-TODO.md diff --git a/docs/hardware/cubecell-TODO.md b/docs/hardware/cubecell-TODO.md new file mode 100644 index 00000000..b96acbb3 --- /dev/null +++ b/docs/hardware/cubecell-TODO.md @@ -0,0 +1,6 @@ + +https://heltec-automation-docs.readthedocs.io/en/latest/cubecell/index.html + +https://github.com/HelTecAutomation/ASR650x-Arduino?utm_source=platformio.org&utm_medium=docs + +* Either portfreertos or make not theaded versions of Lock, WorkerThread, Queue (probably the latter). diff --git a/platformio.ini b/platformio.ini index c51e0954..5d5bb51e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -9,7 +9,7 @@ ; https://docs.platformio.org/page/projectconf.html [platformio] -default_envs = tbeam ; Note: the github actions CI test build can't yet build NRF52 targets +default_envs = cubecellplus ; Note: the github actions CI test build can't yet build NRF52 targets [common] ; common is not currently used @@ -123,6 +123,16 @@ board = ttgo-lora32-v1 build_flags = ${esp32_base.build_flags} -D TTGO_LORA_V2 +; The Heltec Cubecell plus +[env:cubecellplus] +platform = https://github.com/HelTecAutomation/platform-asrmicro650x.git ; we use top-of-tree because stable version has too many bugs - asrmicro650x +framework = arduino +board = cubecell_board_plus +; FIXME, bug in cubecell arduino - they are supposed to set ARDUINO +build_flags = ${env.build_flags} -DARDUINO=100 +src_filter = + ${env.src_filter} - + ; Common settings for NRF52 based targets [nrf52_base] platform = nordicnrf52 diff --git a/src/WorkerThread.cpp b/src/WorkerThread.cpp index f84d83be..36be2769 100644 --- a/src/WorkerThread.cpp +++ b/src/WorkerThread.cpp @@ -1,6 +1,8 @@ #include "WorkerThread.h" #include +#ifdef configUSE_PREEMPTION + void Thread::start(const char *name, size_t stackSize, uint32_t priority) { auto r = xTaskCreate(callRun, name, stackSize, this, priority, &taskHandle); @@ -35,3 +37,5 @@ void NotifiedWorkerThread::block() xTaskNotifyWait(0, // don't clear notification on entry clearOnRead, ¬ification, portMAX_DELAY); // Wait forever } + +#endif \ No newline at end of file diff --git a/src/WorkerThread.h b/src/WorkerThread.h index 86ec08e1..e5294941 100644 --- a/src/WorkerThread.h +++ b/src/WorkerThread.h @@ -1,5 +1,8 @@ #include +// FIXME - ugly check to see if we have freertos +#ifdef configUSE_PREEMPTION + class Thread { protected: @@ -86,4 +89,6 @@ class NotifiedWorkerThread : public WorkerThread * A method that should block execution - either waiting ona queue/mutex or a "task notification" */ virtual void block(); -}; \ No newline at end of file +}; + +#endif \ No newline at end of file diff --git a/src/configuration.h b/src/configuration.h index bc64d318..9b43cb22 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -73,6 +73,22 @@ along with this program. If not, see . #define BUTTON_PIN PIN_BUTTON1 // FIXME, use variant.h defs for all of this!!! (even on the ESP32 targets) +#elif defined(CubeCell_BoardPlus) + +// +// Standard definitions for CubeCell targets +// + +#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 + #else // @@ -256,9 +272,11 @@ along with this program. If not, see . #define DEBUG_PORT console // Serial debug port -#ifdef NO_ESP32 +// What platforms should use SEGGER? +#ifdef NRF52_SERIES #define USE_SEGGER #endif + #ifdef USE_SEGGER #include "SEGGER_RTT.h" #define DEBUG_MSG(...) SEGGER_RTT_printf(0, __VA_ARGS__) diff --git a/src/freertosinc.h b/src/freertosinc.h index 0d86ee2c..6536b91c 100644 --- a/src/freertosinc.h +++ b/src/freertosinc.h @@ -9,8 +9,11 @@ #include #include #else +// not yet supported on cubecell +#ifndef CubeCell_BoardPlus #include #include #include #include +#endif #endif \ No newline at end of file diff --git a/src/lock.cpp b/src/lock.cpp index 8041799e..4a8d28cf 100644 --- a/src/lock.cpp +++ b/src/lock.cpp @@ -5,6 +5,7 @@ namespace meshtastic { +#ifdef configUSE_PREEMPTION Lock::Lock() { handle = xSemaphoreCreateBinary(); @@ -21,6 +22,20 @@ void Lock::unlock() { assert(xSemaphoreGive(handle)); } +#else +Lock::Lock() +{ +} + +void Lock::lock() +{ +} + +void Lock::unlock() +{ +} +#endif + LockGuard::LockGuard(Lock *lock) : lock(lock) { diff --git a/src/lock.h b/src/lock.h index a6afa2f6..6a90c61b 100644 --- a/src/lock.h +++ b/src/lock.h @@ -25,7 +25,9 @@ class Lock void unlock(); private: +#ifdef configUSE_PREEMPTION SemaphoreHandle_t handle; +#endif }; // RAII lock guard.