-
Notifications
You must be signed in to change notification settings - Fork 964
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from meshtastic/dev-wifi
from dev-wifi to my fork
- Loading branch information
Showing
46 changed files
with
520 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
|
||
|
||
export VERSION=1.0.0 | ||
export VERSION=1.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#pragma once | ||
|
||
#include "WorkerThread.h" | ||
|
||
namespace concurrency { | ||
|
||
/** | ||
* @brief A worker thread that waits on a freertos notification | ||
*/ | ||
class BaseNotifiedWorkerThread : public WorkerThread | ||
{ | ||
public: | ||
/** | ||
* Notify this thread so it can run | ||
*/ | ||
virtual void notify(uint32_t v = 0, eNotifyAction action = eNoAction) = 0; | ||
|
||
/** | ||
* Notify from an ISR | ||
* | ||
* This must be inline or IRAM_ATTR on ESP32 | ||
*/ | ||
virtual void notifyFromISR(BaseType_t *highPriWoken, uint32_t v = 0, eNotifyAction action = eNoAction) { notify(v, action); } | ||
|
||
protected: | ||
/** | ||
* The notification that was most recently used to wake the thread. Read from loop() | ||
*/ | ||
uint32_t notification = 0; | ||
|
||
/** | ||
* What notification bits should be cleared just after we read and return them in notification? | ||
* | ||
* Defaults to clear all of them. | ||
*/ | ||
uint32_t clearOnRead = UINT32_MAX; | ||
|
||
/** | ||
* A method that should block execution - either waiting ona queue/mutex or a "task notification" | ||
*/ | ||
virtual void block() = 0; | ||
}; | ||
|
||
} // namespace concurrency |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include "Thread.h" | ||
#include <assert.h> | ||
|
||
namespace concurrency | ||
{ | ||
|
||
void BaseThread::callRun(void *_this) | ||
{ | ||
((BaseThread *)_this)->doRun(); | ||
} | ||
|
||
} // namespace concurrency |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#pragma once | ||
|
||
#include <cstdlib> | ||
#include <stdint.h> | ||
|
||
#include "freertosinc.h" | ||
|
||
namespace concurrency | ||
{ | ||
|
||
/** | ||
* @brief Base threading | ||
*/ | ||
class BaseThread | ||
{ | ||
protected: | ||
/** | ||
* set this to true to ask thread to cleanly exit asap | ||
*/ | ||
volatile bool wantExit = false; | ||
|
||
public: | ||
virtual void start(const char *name, size_t stackSize = 1024, uint32_t priority = tskIDLE_PRIORITY) = 0; | ||
|
||
virtual ~BaseThread() {} | ||
|
||
// uint32_t getStackHighwaterMark() { return uxTaskGetStackHighWaterMark(taskHandle); } | ||
|
||
protected: | ||
/** | ||
* The method that will be called when start is called. | ||
*/ | ||
virtual void doRun() = 0; | ||
|
||
/** | ||
* All thread run methods must periodically call serviceWatchdog, or the system will declare them hung and panic. | ||
* | ||
* this only applies after startWatchdog() has been called. If you need to sleep for a long time call stopWatchdog() | ||
*/ | ||
virtual void serviceWatchdog() {} | ||
virtual void startWatchdog() {} | ||
virtual void stopWatchdog() {} | ||
|
||
static void callRun(void *_this); | ||
}; | ||
|
||
} // namespace concurrency |
8 changes: 6 additions & 2 deletions
8
src/concurrency/NotifiedWorkerThread.cpp → ...currency/FreeRtosNotifiedWorkerThread.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,23 @@ | ||
#include "NotifiedWorkerThread.h" | ||
|
||
#ifdef HAS_FREE_RTOS | ||
|
||
namespace concurrency { | ||
|
||
/** | ||
* Notify this thread so it can run | ||
*/ | ||
void NotifiedWorkerThread::notify(uint32_t v, eNotifyAction action) | ||
void FreeRtosNotifiedWorkerThread::notify(uint32_t v, eNotifyAction action) | ||
{ | ||
xTaskNotify(taskHandle, v, action); | ||
} | ||
|
||
void NotifiedWorkerThread::block() | ||
void FreeRtosNotifiedWorkerThread::block() | ||
{ | ||
xTaskNotifyWait(0, // don't clear notification on entry | ||
clearOnRead, ¬ification, portMAX_DELAY); // Wait forever | ||
} | ||
|
||
} // namespace concurrency | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#pragma once | ||
|
||
#include "BaseNotifiedWorkerThread.h" | ||
|
||
#ifdef HAS_FREE_RTOS | ||
|
||
namespace concurrency { | ||
|
||
/** | ||
* @brief A worker thread that waits on a freertos notification | ||
*/ | ||
class FreeRtosNotifiedWorkerThread : public BaseNotifiedWorkerThread | ||
{ | ||
public: | ||
/** | ||
* Notify this thread so it can run | ||
*/ | ||
void notify(uint32_t v = 0, eNotifyAction action = eNoAction); | ||
|
||
/** | ||
* Notify from an ISR | ||
* | ||
* This must be inline or IRAM_ATTR on ESP32 | ||
*/ | ||
inline void notifyFromISR(BaseType_t *highPriWoken, uint32_t v = 0, eNotifyAction action = eNoAction) | ||
{ | ||
xTaskNotifyFromISR(taskHandle, v, action, highPriWoken); | ||
} | ||
|
||
protected: | ||
|
||
/** | ||
* A method that should block execution - either waiting ona queue/mutex or a "task notification" | ||
*/ | ||
virtual void block(); | ||
}; | ||
|
||
} // namespace concurrency | ||
|
||
#endif |
Oops, something went wrong.