This commit is contained in:
Matthew Kennedy 2021-03-25 15:12:17 -07:00 committed by GitHub
parent 67925a98fc
commit 2839c6f069
2 changed files with 8 additions and 12 deletions

View File

@ -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();

View File

@ -16,6 +16,7 @@
#if EFI_FILE_LOGGING
#include "ch.hpp"
#include <stdio.h>
#include <string.h>
#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);