cubecell WIP

This commit is contained in:
geeksville
2020-06-05 17:30:09 -07:00
parent 5915669f6f
commit 1c63a70673
8 changed files with 66 additions and 3 deletions

View File

@@ -1,6 +1,8 @@
#include "WorkerThread.h"
#include <assert.h>
#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, &notification, portMAX_DELAY); // Wait forever
}
#endif

View File

@@ -1,5 +1,8 @@
#include <Arduino.h>
// 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();
};
};
#endif

View File

@@ -73,6 +73,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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 <http://www.gnu.org/licenses/>.
#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__)

View File

@@ -9,8 +9,11 @@
#include <freertos/semphr.h>
#include <freertos/queue.h>
#else
// not yet supported on cubecell
#ifndef CubeCell_BoardPlus
#include <FreeRTOS.h>
#include <task.h>
#include <semphr.h>
#include <queue.h>
#endif
#endif

View File

@@ -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)
{

View File

@@ -25,7 +25,9 @@ class Lock
void unlock();
private:
#ifdef configUSE_PREEMPTION
SemaphoreHandle_t handle;
#endif
};
// RAII lock guard.