i2c fixes + server improvements

This commit is contained in:
2026-10-05 19:28:37 +02:00
parent 7094d05030
commit 02f3df8c41
9 changed files with 254 additions and 52 deletions
+40
View File
@@ -0,0 +1,40 @@
#include "ygg_lock.h"
#include <freertos/semphr.h>
static SemaphoreHandle_t s_i2c_mutex = NULL;
static SemaphoreHandle_t s_lvgl_mutex = NULL;
void ygg_lock_init(void) {
if (s_i2c_mutex == NULL) {
s_i2c_mutex = xSemaphoreCreateMutex();
}
if (s_lvgl_mutex == NULL) {
s_lvgl_mutex = xSemaphoreCreateMutex();
}
}
bool ygg_i2c_lock_take(TickType_t timeout) {
if (s_i2c_mutex == NULL) {
return false;
}
return xSemaphoreTake(s_i2c_mutex, timeout) == pdTRUE;
}
void ygg_i2c_lock_give(void) {
if (s_i2c_mutex != NULL) {
xSemaphoreGive(s_i2c_mutex);
}
}
bool ygg_lvgl_lock_take(TickType_t timeout) {
if (s_lvgl_mutex == NULL) {
return false;
}
return xSemaphoreTake(s_lvgl_mutex, timeout) == pdTRUE;
}
void ygg_lvgl_lock_give(void) {
if (s_lvgl_mutex != NULL) {
xSemaphoreGive(s_lvgl_mutex);
}
}