Various improvements (#461)

* **New Features**
  * Time and delay utilities added (ticks, ms, µs); SD card now uses an expansion-header CS pin; HTTP downloads warn when run on the GUI task and yield to avoid blocking.

* **Bug Fixes / Reliability**
  * Many hard-crash paths converted to guarded checks to reduce abrupt termination and improve stability.

* **Tests**
  * Unit tests added to validate time and delay accuracy.

* **Chores**
  * License header and build/macro updates.
This commit is contained in:
Ken Van Hoeylandt
2026-01-27 08:04:21 +01:00
committed by GitHub
parent 619b5aa53b
commit e6abd496f9
95 changed files with 433 additions and 284 deletions
@@ -4,6 +4,8 @@
#include <assert.h>
#include <stdbool.h>
#include <Tactility/Check.h>
#include <Tactility/FreeRTOS/semphr.h>
#ifdef __cplusplus
@@ -28,17 +30,17 @@ inline static void mutex_destruct(struct Mutex* mutex) {
}
inline static void mutex_lock(struct Mutex* mutex) {
assert(xPortInIsrContext() != pdTRUE);
check(xPortInIsrContext() != pdTRUE);
xSemaphoreTake(mutex->handle, portMAX_DELAY);
}
inline static bool mutex_try_lock(struct Mutex* mutex) {
assert(xPortInIsrContext() != pdTRUE);
check(xPortInIsrContext() != pdTRUE);
return xSemaphoreTake(mutex->handle, 0) == pdTRUE;
}
inline static bool mutex_try_lock_timed(struct Mutex* mutex, TickType_t timeout) {
assert(xPortInIsrContext() != pdTRUE);
check(xPortInIsrContext() != pdTRUE);
return xSemaphoreTake(mutex->handle, timeout) == pdTRUE;
}
@@ -51,7 +53,7 @@ inline static bool mutex_is_locked(struct Mutex* mutex) {
}
inline static void mutex_unlock(struct Mutex* mutex) {
assert(xPortInIsrContext() != pdTRUE);
check(xPortInIsrContext() != pdTRUE);
xSemaphoreGive(mutex->handle);
}