use cpp (#2493)
This commit is contained in:
parent
d564c5e845
commit
31ef22eecb
|
@ -12,6 +12,7 @@
|
||||||
EXTERN_ENGINE;
|
EXTERN_ENGINE;
|
||||||
|
|
||||||
#include "knock_config.h"
|
#include "knock_config.h"
|
||||||
|
#include "ch.hpp"
|
||||||
|
|
||||||
NO_CACHE adcsample_t sampleBuffer[2000];
|
NO_CACHE adcsample_t sampleBuffer[2000];
|
||||||
int8_t currentCylinderIndex = 0;
|
int8_t currentCylinderIndex = 0;
|
||||||
|
@ -21,7 +22,7 @@ static volatile bool knockIsSampling = false;
|
||||||
static volatile bool knockNeedsProcess = false;
|
static volatile bool knockNeedsProcess = false;
|
||||||
static volatile size_t sampleCount = 0;
|
static volatile size_t sampleCount = 0;
|
||||||
|
|
||||||
binary_semaphore_t knockSem;
|
chibios_rt::BinarySemaphore knockSem(/* taken =*/ true);
|
||||||
|
|
||||||
static void completionCallback(ADCDriver* adcp) {
|
static void completionCallback(ADCDriver* adcp) {
|
||||||
palClearPad(GPIOD, 2);
|
palClearPad(GPIOD, 2);
|
||||||
|
@ -31,7 +32,7 @@ static void completionCallback(ADCDriver* adcp) {
|
||||||
|
|
||||||
// Notify the processing thread that it's time to process this sample
|
// Notify the processing thread that it's time to process this sample
|
||||||
chSysLockFromISR();
|
chSysLockFromISR();
|
||||||
chBSemSignalI(&knockSem);
|
knockSem.signalI();
|
||||||
chSysUnlockFromISR();
|
chSysUnlockFromISR();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,8 +171,6 @@ public:
|
||||||
static KnockThread kt;
|
static KnockThread kt;
|
||||||
|
|
||||||
void initSoftwareKnock() {
|
void initSoftwareKnock() {
|
||||||
chBSemObjectInit(&knockSem, TRUE);
|
|
||||||
|
|
||||||
if (CONFIG(enableSoftwareKnock)) {
|
if (CONFIG(enableSoftwareKnock)) {
|
||||||
knockFilter.configureBandpass(KNOCK_SAMPLE_RATE, 1000 * CONFIG(knockBandCustom), 3);
|
knockFilter.configureBandpass(KNOCK_SAMPLE_RATE, 1000 * CONFIG(knockBandCustom), 3);
|
||||||
adcStart(&KNOCK_ADC, nullptr);
|
adcStart(&KNOCK_ADC, nullptr);
|
||||||
|
@ -224,7 +223,7 @@ void processLastKnockEvent() {
|
||||||
|
|
||||||
void KnockThread::ThreadTask() {
|
void KnockThread::ThreadTask() {
|
||||||
while (1) {
|
while (1) {
|
||||||
chBSemWait(&knockSem);
|
knockSem.wait();
|
||||||
|
|
||||||
ScopePerf perf(PE::SoftwareKnockProcess);
|
ScopePerf perf(PE::SoftwareKnockProcess);
|
||||||
processLastKnockEvent();
|
processLastKnockEvent();
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#if EFI_FILE_LOGGING
|
#if EFI_FILE_LOGGING
|
||||||
|
|
||||||
|
#include "ch.hpp"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "mmc_card.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'}
|
{'v',CH_KERNEL_MAJOR+'0','.',CH_KERNEL_MINOR+'0'}
|
||||||
};
|
};
|
||||||
|
|
||||||
static binary_semaphore_t usbConnectedSemaphore;
|
static chibios_rt::BinarySemaphore usbConnectedSemaphore(/* taken =*/ true);
|
||||||
|
|
||||||
void onUsbConnectedNotifyMmcI() {
|
void onUsbConnectedNotifyMmcI() {
|
||||||
chBSemSignalI(&usbConnectedSemaphore);
|
usbConnectedSemaphore.signalI();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* HAL_USE_USB_MSD */
|
#endif /* HAL_USE_USB_MSD */
|
||||||
|
@ -417,7 +418,7 @@ static bool mountMmc() {
|
||||||
|
|
||||||
#if HAL_USE_USB_MSD
|
#if HAL_USE_USB_MSD
|
||||||
// Wait for the USB stack to wake up, or a 5 second timeout, whichever occurs first
|
// 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;
|
bool hasUsb = usbResult == MSG_OK;
|
||||||
|
|
||||||
|
@ -538,10 +539,6 @@ bool isSdCardAlive(void) {
|
||||||
void initEarlyMmcCard() {
|
void initEarlyMmcCard() {
|
||||||
logName[0] = 0;
|
logName[0] = 0;
|
||||||
|
|
||||||
#if HAL_USE_USB_MSD
|
|
||||||
chBSemObjectInit(&usbConnectedSemaphore, true);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
addConsoleAction("sdinfo", sdStatistics);
|
addConsoleAction("sdinfo", sdStatistics);
|
||||||
addConsoleActionS("ls", listDirectory);
|
addConsoleActionS("ls", listDirectory);
|
||||||
addConsoleActionS("del", removeFile);
|
addConsoleActionS("del", removeFile);
|
||||||
|
|
Loading…
Reference in New Issue