mirror of https://github.com/FOME-Tech/fome-fw.git
Implement auto knock threshold sampling #3033
This commit is contained in:
parent
c95ee8dc6f
commit
06060dc43b
|
@ -216,7 +216,7 @@ if (engineConfiguration->debugMode == DBG_DWELL_METRIC) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if EFI_SOFTWARE_KNOCK
|
#if EFI_SOFTWARE_KNOCK
|
||||||
startKnockSampling(event->cylinderNumber);
|
knockSamplingCallback(event->cylinderNumber, nowNt);
|
||||||
#endif
|
#endif
|
||||||
#if EFI_HIP_9011
|
#if EFI_HIP_9011
|
||||||
hip9011_onFireEvent(event->cylinderNumber, nowNt);
|
hip9011_onFireEvent(event->cylinderNumber, nowNt);
|
||||||
|
|
|
@ -19,6 +19,7 @@ static Biquad knockFilter;
|
||||||
static volatile bool knockIsSampling = false;
|
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;
|
||||||
|
static int cylinderIndexCopy;
|
||||||
|
|
||||||
chibios_rt::BinarySemaphore knockSem(/* taken =*/ true);
|
chibios_rt::BinarySemaphore knockSem(/* taken =*/ true);
|
||||||
|
|
||||||
|
@ -105,7 +106,7 @@ const ADCConversionGroup* getConversionGroup(uint8_t cylinderIndex) {
|
||||||
return &adcConvGroupCh1;
|
return &adcConvGroupCh1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void startKnockSampling(uint8_t cylinderIndex) {
|
static void startKnockSampling(uint8_t cylinderIndex) {
|
||||||
if (!CONFIG(enableSoftwareKnock)) {
|
if (!CONFIG(enableSoftwareKnock)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -141,6 +142,20 @@ void startKnockSampling(uint8_t cylinderIndex) {
|
||||||
lastKnockSampleTime = getTimeNowNt();
|
lastKnockSampleTime = getTimeNowNt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void startKnockSamplingNoParam(void *arg) {
|
||||||
|
// ugly as hell but that's error: cast between incompatible function types from 'void (*)(uint8_t)' {aka 'void (*)(unsigned char)'} to 'schfunc_t' {aka 'void (*)(void*)'} [-Werror=cast-function-type]
|
||||||
|
startKnockSampling(cylinderIndexCopy);
|
||||||
|
}
|
||||||
|
|
||||||
|
static scheduling_s startSampling;
|
||||||
|
|
||||||
|
void knockSamplingCallback(uint8_t cylinderIndex, efitick_t nowNt) {
|
||||||
|
cylinderIndexCopy = cylinderIndex;
|
||||||
|
|
||||||
|
scheduleByAngle(&startSampling, nowNt,
|
||||||
|
/*angle*/CONFIG(knockDetectionWindowStart), startKnockSamplingNoParam PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
}
|
||||||
|
|
||||||
class KnockThread : public ThreadController<256> {
|
class KnockThread : public ThreadController<256> {
|
||||||
public:
|
public:
|
||||||
KnockThread() : ThreadController("knock", PRIO_KNOCK_PROCESS) {}
|
KnockThread() : ThreadController("knock", PRIO_KNOCK_PROCESS) {}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "pch.h"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
void initSoftwareKnock();
|
void initSoftwareKnock();
|
||||||
void startKnockSampling(uint8_t cylinderIndex);
|
void knockSamplingCallback(uint8_t cylinderIndex, efitick_t nowNt);
|
||||||
void processLastKnockEvent();
|
void processLastKnockEvent();
|
||||||
|
|
Loading…
Reference in New Issue