handshake-capture-c6: SPI bus lock, SD v1.0.2 diagnostics, MUST_DO review
- SPI_Bus_Lock: serialize LCD + SD on shared SPI; pause display during SD - SD_Init after WiFi scan; SD_IsReady gating; serial [SD]/[CAP] diagnostics - MUST_DO_IMPROVEMENTS.md full firmware review backlog; README link - Bump HANDSHAKE_FIRMWARE_VERSION to 1.0.2 (header) Made-with: Cursor
This commit is contained in:
37
handshake-capture-c6/SPI_Bus_Lock.cpp
Normal file
37
handshake-capture-c6/SPI_Bus_Lock.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#include "SPI_Bus_Lock.h"
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/semphr.h>
|
||||
|
||||
static SemaphoreHandle_t s_spi_bus_mutex = nullptr;
|
||||
static volatile bool s_display_paused = false;
|
||||
|
||||
static void ensureMutex() {
|
||||
if (s_spi_bus_mutex == nullptr) {
|
||||
s_spi_bus_mutex = xSemaphoreCreateRecursiveMutex();
|
||||
}
|
||||
}
|
||||
|
||||
void SPIBus_Init() {
|
||||
ensureMutex();
|
||||
}
|
||||
|
||||
void SPIBus_Lock() {
|
||||
ensureMutex();
|
||||
if (s_spi_bus_mutex != nullptr) {
|
||||
xSemaphoreTakeRecursive(s_spi_bus_mutex, portMAX_DELAY);
|
||||
}
|
||||
}
|
||||
|
||||
void SPIBus_Unlock() {
|
||||
if (s_spi_bus_mutex != nullptr) {
|
||||
xSemaphoreGiveRecursive(s_spi_bus_mutex);
|
||||
}
|
||||
}
|
||||
|
||||
void SPIBus_SetDisplayPaused(bool paused) {
|
||||
s_display_paused = paused;
|
||||
}
|
||||
|
||||
bool SPIBus_IsDisplayPaused() {
|
||||
return s_display_paused;
|
||||
}
|
||||
Reference in New Issue
Block a user