diff --git a/firmware/controllers/sensors/software_knock.cpp b/firmware/controllers/sensors/software_knock.cpp index abec77223d..585c9ed5e3 100644 --- a/firmware/controllers/sensors/software_knock.cpp +++ b/firmware/controllers/sensors/software_knock.cpp @@ -12,6 +12,7 @@ EXTERN_ENGINE; #include "knock_config.h" +#include "ch.hpp" NO_CACHE adcsample_t sampleBuffer[2000]; int8_t currentCylinderIndex = 0; @@ -21,7 +22,7 @@ static volatile bool knockIsSampling = false; static volatile bool knockNeedsProcess = false; static volatile size_t sampleCount = 0; -binary_semaphore_t knockSem; +chibios_rt::BinarySemaphore knockSem(/* taken =*/ true); static void completionCallback(ADCDriver* adcp) { palClearPad(GPIOD, 2); @@ -31,7 +32,7 @@ static void completionCallback(ADCDriver* adcp) { // Notify the processing thread that it's time to process this sample chSysLockFromISR(); - chBSemSignalI(&knockSem); + knockSem.signalI(); chSysUnlockFromISR(); } } @@ -170,8 +171,6 @@ public: static KnockThread kt; void initSoftwareKnock() { - chBSemObjectInit(&knockSem, TRUE); - if (CONFIG(enableSoftwareKnock)) { knockFilter.configureBandpass(KNOCK_SAMPLE_RATE, 1000 * CONFIG(knockBandCustom), 3); adcStart(&KNOCK_ADC, nullptr); @@ -224,7 +223,7 @@ void processLastKnockEvent() { void KnockThread::ThreadTask() { while (1) { - chBSemWait(&knockSem); + knockSem.wait(); ScopePerf perf(PE::SoftwareKnockProcess); processLastKnockEvent(); diff --git a/firmware/hw_layer/mmc_card.cpp b/firmware/hw_layer/mmc_card.cpp index 4302dd17af..3a5b3664a9 100644 --- a/firmware/hw_layer/mmc_card.cpp +++ b/firmware/hw_layer/mmc_card.cpp @@ -16,6 +16,7 @@ #if EFI_FILE_LOGGING +#include "ch.hpp" #include #include #include "mmc_card.h" @@ -338,10 +339,10 @@ static const scsi_inquiry_response_t scsi_inquiry_response = { {'v',CH_KERNEL_MAJOR+'0','.',CH_KERNEL_MINOR+'0'} }; -static binary_semaphore_t usbConnectedSemaphore; +static chibios_rt::BinarySemaphore usbConnectedSemaphore(/* taken =*/ true); void onUsbConnectedNotifyMmcI() { - chBSemSignalI(&usbConnectedSemaphore); + usbConnectedSemaphore.signalI(); } #endif /* HAL_USE_USB_MSD */ @@ -417,7 +418,7 @@ static bool mountMmc() { #if HAL_USE_USB_MSD // Wait for the USB stack to wake up, or a 5 second timeout, whichever occurs first - msg_t usbResult = chBSemWaitTimeout(&usbConnectedSemaphore, TIME_MS2I(5000)); + msg_t usbResult = usbConnectedSemaphore.wait(TIME_MS2I(5000)); bool hasUsb = usbResult == MSG_OK; @@ -538,10 +539,6 @@ bool isSdCardAlive(void) { void initEarlyMmcCard() { logName[0] = 0; -#if HAL_USE_USB_MSD - chBSemObjectInit(&usbConnectedSemaphore, true); -#endif - addConsoleAction("sdinfo", sdStatistics); addConsoleActionS("ls", listDirectory); addConsoleActionS("del", removeFile);