i2c fixes + server improvements
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user