working on thread safety, preparing for static RTOS

This commit is contained in:
2023-12-12 22:55:22 +01:00
parent c3be10903b
commit 07d9f52b8d
6 changed files with 142 additions and 45 deletions

View File

@ -4,6 +4,29 @@
// TODO namespace the names
SemaphoreHandle_t * global_threading_semaphore = NULL;
uint8_t global_threading_available_c() {
if (global_threading_semaphore == NULL) {
global_threading_semaphore = xSemaphoreCreateBinary();
//xSemaphoreGive(global_threading_semaphore);
}
if (uxSemaphoreGetCount(global_threading_semaphore) == 1) {
return 1;
} else {
return 0;
}
}
void enable_global_threading_c() {
xSemaphoreGive(global_threading_semaphore);
}
void disable_global_threading_c() {
xSemaphoreTake(global_threading_semaphore, portMAX_DELAY);
}
const char *get_task_name() { return pcTaskGetName(NULL); }
void stop_it() { taskENTER_CRITICAL(); }