Update to ESP-IDF v5.4 and fix warnings (#193)

- Update to ESP-IDF v5.4
- Fixed a lot of new and existing warnings
- Fix issue with incorrect `EventFlag` usage in Dispatcher
This commit is contained in:
Ken Van Hoeylandt
2025-01-26 15:52:57 +01:00
committed by GitHub
parent fa54eaa58a
commit 1bb1260ea0
24 changed files with 67 additions and 175 deletions
+9 -14
View File
@@ -6,7 +6,7 @@ namespace tt {
#define TAG "dispatcher"
#define BACKPRESSURE_WARNING_COUNT ((EventBits_t)100)
#define WAIT_FLAG ((EventBits_t)1)
#define WAIT_FLAG ((EventBits_t)1U)
Dispatcher::~Dispatcher() {
// Wait for Mutex usage
@@ -31,38 +31,33 @@ void Dispatcher::dispatch(Function function, std::shared_ptr<void> context) {
}
uint32_t Dispatcher::consume(TickType_t timeout) {
// Wait for signal and clear
TickType_t start_ticks = kernel::getTicks();
if (eventFlag.wait(WAIT_FLAG, EventFlag::WaitAny, timeout)) {
eventFlag.clear(WAIT_FLAG);
} else {
// Wait for signal
uint32_t result = eventFlag.wait(WAIT_FLAG, EventFlag::WaitAny, timeout);
if (result & EventFlag::Error) {
return 0;
}
TickType_t ticks_remaining = TT_MAX(timeout - (kernel::getTicks() - start_ticks), 0);
TT_LOG_I(TAG, "Dispatcher continuing (%d ticks)", (int)ticks_remaining);
eventFlag.clear(WAIT_FLAG);
// Mutate
bool processing = true;
uint32_t consumed = 0;
do {
if (mutex.lock(ticks_remaining / portTICK_PERIOD_MS)) {
if (mutex.lock(10)) {
if (!queue.empty()) {
auto item = queue.front();
queue.pop();
consumed++;
processing = !queue.empty();
// Don't keep lock as callback might be slow
tt_check(mutex.unlock());
mutex.unlock();
item->function(item->context);
} else {
processing = false;
tt_check(mutex.unlock());
mutex.unlock();
}
} else {
TT_LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED);
TT_LOG_W(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED);
}
} while (processing);