mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-07 14:14:52 +00:00

Some checks are pending
CI / setup (check) (push) Waiting to run
CI / setup (esp32) (push) Waiting to run
CI / setup (esp32c3) (push) Waiting to run
CI / setup (esp32c6) (push) Waiting to run
CI / setup (esp32s3) (push) Waiting to run
CI / setup (nrf52840) (push) Waiting to run
CI / setup (rp2040) (push) Waiting to run
CI / setup (stm32) (push) Waiting to run
CI / check (push) Blocked by required conditions
CI / build-esp32 (push) Blocked by required conditions
CI / build-esp32-s3 (push) Blocked by required conditions
CI / build-esp32-c3 (push) Blocked by required conditions
CI / build-esp32-c6 (push) Blocked by required conditions
CI / build-nrf52 (push) Blocked by required conditions
CI / build-rpi2040 (push) Blocked by required conditions
CI / build-stm32 (push) Blocked by required conditions
CI / package-raspbian (push) Waiting to run
CI / package-raspbian-armv7l (push) Waiting to run
CI / package-native (push) Waiting to run
CI / after-checks (push) Blocked by required conditions
CI / gather-artifacts (esp32) (push) Blocked by required conditions
CI / gather-artifacts (esp32c3) (push) Blocked by required conditions
CI / gather-artifacts (esp32c6) (push) Blocked by required conditions
CI / gather-artifacts (esp32s3) (push) Blocked by required conditions
CI / gather-artifacts (nrf52840) (push) Blocked by required conditions
CI / gather-artifacts (rp2040) (push) Blocked by required conditions
CI / gather-artifacts (stm32) (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions
CI / release-firmware (esp32) (push) Blocked by required conditions
CI / release-firmware (esp32c3) (push) Blocked by required conditions
CI / release-firmware (esp32c6) (push) Blocked by required conditions
CI / release-firmware (esp32s3) (push) Blocked by required conditions
CI / release-firmware (nrf52840) (push) Blocked by required conditions
CI / release-firmware (rp2040) (push) Blocked by required conditions
CI / release-firmware (stm32) (push) Blocked by required conditions
Flawfinder Scan / Flawfinder (push) Waiting to run
* Now with even fewer ings * Ye * Mo * QMA6100PSensor
94 lines
2.0 KiB
C++
94 lines
2.0 KiB
C++
#include "NotifiedWorkerThread.h"
|
|
#include "configuration.h"
|
|
#include "main.h"
|
|
|
|
namespace concurrency
|
|
{
|
|
|
|
static bool debugNotification;
|
|
|
|
/**
|
|
* Notify this thread so it can run
|
|
*/
|
|
bool NotifiedWorkerThread::notify(uint32_t v, bool overwrite)
|
|
{
|
|
bool r = notifyCommon(v, overwrite);
|
|
|
|
if (r)
|
|
mainDelay.interrupt();
|
|
|
|
return r;
|
|
}
|
|
|
|
/**
|
|
* Notify this thread so it can run
|
|
*/
|
|
IRAM_ATTR bool NotifiedWorkerThread::notifyCommon(uint32_t v, bool overwrite)
|
|
{
|
|
if (overwrite || notification == 0) {
|
|
enabled = true;
|
|
setInterval(0); // Run ASAP
|
|
runASAP = true;
|
|
|
|
notification = v;
|
|
if (debugNotification) {
|
|
LOG_DEBUG("Set notification %d", v);
|
|
}
|
|
return true;
|
|
} else {
|
|
if (debugNotification) {
|
|
LOG_DEBUG("Drop notification %d", v);
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Notify from an ISR
|
|
*
|
|
* This must be inline or IRAM_ATTR on ESP32
|
|
*/
|
|
IRAM_ATTR bool NotifiedWorkerThread::notifyFromISR(BaseType_t *highPriWoken, uint32_t v, bool overwrite)
|
|
{
|
|
bool r = notifyCommon(v, overwrite);
|
|
if (r)
|
|
mainDelay.interruptFromISR(highPriWoken);
|
|
|
|
return r;
|
|
}
|
|
|
|
/**
|
|
* Schedule a notification to fire in delay msecs
|
|
*/
|
|
bool NotifiedWorkerThread::notifyLater(uint32_t delay, uint32_t v, bool overwrite)
|
|
{
|
|
bool didIt = notify(v, overwrite);
|
|
|
|
if (didIt) { // If we didn't already have something queued, override the delay to be larger
|
|
setIntervalFromNow(delay); // a new version of setInterval relative to the current time
|
|
if (debugNotification) {
|
|
LOG_DEBUG("Delay notification %u", delay);
|
|
}
|
|
}
|
|
|
|
return didIt;
|
|
}
|
|
|
|
void NotifiedWorkerThread::checkNotification()
|
|
{
|
|
auto n = notification;
|
|
notification = 0; // clear notification
|
|
if (n) {
|
|
onNotify(n);
|
|
}
|
|
}
|
|
|
|
int32_t NotifiedWorkerThread::runOnce()
|
|
{
|
|
enabled = false; // Only run once per notification
|
|
checkNotification();
|
|
|
|
return RUN_SAME;
|
|
}
|
|
|
|
} // namespace concurrency
|