| Line | Branch | Decision | Exec | Source |
|---|---|---|---|---|
| 1 | /* | |||
| 2 | * @file knock_logic.h | |||
| 3 | * | |||
| 4 | * @date Apr 04, 2021 | |||
| 5 | * @author Andrey Gusakov | |||
| 6 | */ | |||
| 7 | ||||
| 8 | #pragma once | |||
| 9 | ||||
| 10 | #include "peak_detect.h" | |||
| 11 | #include "knock_controller_generated.h" | |||
| 12 | ||||
| 13 | int getCylinderKnockBank(uint8_t cylinderNumber); | |||
| 14 | ||||
| 15 | #define bore2frequency(bore) (900 / (CONST_PI * (bore) / 2)) | |||
| 16 | ||||
| 17 | class KnockControllerBase : public EngineModule, public knock_controller_s { | |||
| 18 | public: | |||
| 19 |
2/2✓ Branch 2 taken 7502 times.
✓ Branch 3 taken 682 times.
|
8184 | KnockControllerBase() { | |
| 20 | // start with threshold higher than any possible knock to avoid recording spurious knocks | |||
| 21 | 682 | m_knockThreshold = 100; | ||
| 22 | 682 | } | ||
| 23 | // EngineModule implementation | |||
| 24 | void onFastCallback() override; | |||
| 25 | ||||
| 26 | // onKnockSenseCompleted is the callback from the knock sense driver to report a sensed knock level | |||
| 27 | void onKnockSenseCompleted(uint8_t cylinderNumber, float dbv, efitick_t lastKnockTime); | |||
| 28 | ||||
| 29 | float getFuelTrimMultiplier() const; | |||
| 30 | float getKnockRetard() const; | |||
| 31 | uint32_t getKnockCount() const; | |||
| 32 | ||||
| 33 | virtual float getKnockThreshold() const = 0; | |||
| 34 | virtual float getMaximumRetard() const = 0; | |||
| 35 | ||||
| 36 | private: | |||
| 37 | using PD = PeakDetect<float, MS2NT(50)>; | |||
| 38 | PD peakDetectors[MAX_CYLINDER_COUNT]; | |||
| 39 | PD allCylinderPeakDetector; | |||
| 40 | }; | |||
| 41 | ||||
| 42 | class KnockController : public KnockControllerBase { | |||
| 43 | public: | |||
| 44 | float getKnockThreshold() const override; | |||
| 45 | float getMaximumRetard() const override; | |||
| 46 | }; | |||
| 47 |