Hal refactored (#99)

This commit is contained in:
Ken Van Hoeylandt
2024-12-02 00:32:39 +01:00
committed by GitHub
parent 0188ce721c
commit 33bb742dfb
103 changed files with 1222 additions and 1228 deletions
+13 -6
View File
@@ -1,11 +1,20 @@
#include <Mutex.h>
#include "LvglSync.h"
#include "Check.h"
namespace tt::lvgl {
static LvglLock lock_singleton = nullptr;
static LvglUnlock unlock_singleton = nullptr;
Mutex lockMutex;
static bool defaultLock(uint32_t timeoutTicks) {
return lockMutex.acquire(timeoutTicks) == TtStatusOk;
}
static void defaultUnlock() {
lockMutex.release();
}
static LvglLock lock_singleton = defaultLock;
static LvglUnlock unlock_singleton = defaultUnlock;
void syncSet(LvglLock lock, LvglUnlock unlock) {
lock_singleton = lock;
@@ -13,12 +22,10 @@ void syncSet(LvglLock lock, LvglUnlock unlock) {
}
bool lock(uint32_t timeout_ticks) {
tt_check(lock_singleton);
return lock_singleton(timeout_ticks);
}
void unlock() {
tt_check(unlock_singleton);
unlock_singleton();
}