Remove trigger listener list (#1886)

* avoid 64b on hot path

* no tooth log when fast

* use crit section locker

* final

* only flip pins if not also self stim

* only trace if doing work

* slightly drop lateDelay

* trace if not bailing out

* remove listener array
This commit is contained in:
Matthew Kennedy 2020-10-17 05:00:11 -07:00 committed by GitHub
parent d1f421fd06
commit a68cbae0dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 50 deletions

View File

@ -16,6 +16,8 @@
#include "listener_array.h" #include "listener_array.h"
#include "pwm_generator_logic.h" #include "pwm_generator_logic.h"
#include "tooth_logger.h" #include "tooth_logger.h"
#include "hip9011.h"
#include "logic_analyzer.h"
#include "settings.h" #include "settings.h"
#include "engine_math.h" #include "engine_math.h"
@ -46,7 +48,6 @@ trigger_central_s::trigger_central_s() : hwEventCounters() {
} }
TriggerCentral::TriggerCentral() : trigger_central_s() { TriggerCentral::TriggerCentral() : trigger_central_s() {
clearCallbacks(&triggerListeneres);
triggerState.resetTriggerState(); triggerState.resetTriggerState();
noiseFilter.resetAccumSignalData(); noiseFilter.resetAccumSignalData();
} }
@ -72,25 +73,10 @@ EXTERN_ENGINE;
static Logging *logger; static Logging *logger;
void TriggerCentral::addEventListener(ShaftPositionListener listener, const char *name, Engine *engine) {
print("registerCkpListener: %s\r\n", name);
triggerListeneres.registerCallback((VoidInt)(void*)listener, engine);
}
angle_t TriggerCentral::getVVTPosition() { angle_t TriggerCentral::getVVTPosition() {
return vvtPosition; return vvtPosition;
} }
/**
* @brief Adds a trigger event listener
*
* Trigger event listener would be invoked on each trigger event. For example, for a 60/2 wheel
* that would be 116 events: 58 SHAFT_PRIMARY_RISING and 58 SHAFT_PRIMARY_FALLING events.
*/
void addTriggerEventListener(ShaftPositionListener listener, const char *name, Engine *engine) {
engine->triggerCentral.addEventListener(listener, name, engine);
}
#define miataNbIndex (0) #define miataNbIndex (0)
static bool vvtWithRealDecoder(vvt_mode_e vvtMode) { static bool vvtWithRealDecoder(vvt_mode_e vvtMode) {
@ -487,7 +473,6 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal, efitick_t timesta
scheduleMsg(logger, "trigger %d %d %d", triggerIndexForListeners, getRevolutionCounter(), (int)getTimeNowUs()); scheduleMsg(logger, "trigger %d %d %d", triggerIndexForListeners, getRevolutionCounter(), (int)getTimeNowUs());
#endif /* TRIGGER_EXTREME_LOGGING */ #endif /* TRIGGER_EXTREME_LOGGING */
rpmShaftPositionCallback(signal, triggerIndexForListeners, timestamp PASS_ENGINE_PARAMETER_SUFFIX); rpmShaftPositionCallback(signal, triggerIndexForListeners, timestamp PASS_ENGINE_PARAMETER_SUFFIX);
#if !EFI_UNIT_TEST #if !EFI_UNIT_TEST
@ -495,25 +480,22 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal, efitick_t timesta
#endif #endif
#if !EFI_UNIT_TEST #if !EFI_UNIT_TEST
#if EFI_SHAFT_POSITION_INPUT && EFI_MAP_AVERAGING #if EFI_MAP_AVERAGING
mapAveragingTriggerCallback(triggerIndexForListeners, timestamp PASS_ENGINE_PARAMETER_SUFFIX); mapAveragingTriggerCallback(triggerIndexForListeners, timestamp PASS_ENGINE_PARAMETER_SUFFIX);
#endif /* EFI_SHAFT_POSITION_INPUT && EFI_MAP_AVERAGING */ #endif /* EFI_MAP_AVERAGING */
#endif /* EFI_UNIT_TEST */ #endif /* EFI_UNIT_TEST */
//auxValveTriggerCallback #if EFI_HIP_9011
if (CONFIG(isHip9011Enabled)) {
intHoldCallback(signal, triggerIndexForListeners, timestamp PASS_ENGINE_PARAMETER_SUFFIX);
/**
* Here we invoke all the listeners - the main engine control logic is inside these listeners
*/
for (int i = 0; i < triggerListeneres.currentListenersCount; i++) {
ShaftPositionListener listener = (ShaftPositionListener) (void*) triggerListeneres.callbacks[i];
(listener)(signal, triggerIndexForListeners, timestamp PASS_ENGINE_PARAMETER_SUFFIX);
} }
#endif
#if EFI_LOGIC_ANALYZER
waTriggerEventListener(signal, triggerIndexForListeners, timestamp PASS_ENGINE_PARAMETER_SUFFIX);
#endif
mainTriggerCallback(triggerIndexForListeners, timestamp PASS_ENGINE_PARAMETER_SUFFIX); mainTriggerCallback(triggerIndexForListeners, timestamp PASS_ENGINE_PARAMETER_SUFFIX);
} }
} }

View File

@ -38,7 +38,6 @@ class TriggerCentral final : public trigger_central_s {
public: public:
TriggerCentral(); TriggerCentral();
void init(DECLARE_ENGINE_PARAMETER_SIGNATURE); void init(DECLARE_ENGINE_PARAMETER_SIGNATURE);
void addEventListener(ShaftPositionListener handler, const char *name, Engine *engine);
void handleShaftSignal(trigger_event_e signal, efitick_t timestamp DECLARE_ENGINE_PARAMETER_SUFFIX); void handleShaftSignal(trigger_event_e signal, efitick_t timestamp DECLARE_ENGINE_PARAMETER_SUFFIX);
int getHwEventCounter(int index) const; int getHwEventCounter(int index) const;
void resetCounters(); void resetCounters();
@ -68,9 +67,6 @@ public:
TriggerWaveform vvtShape; TriggerWaveform vvtShape;
TriggerFormDetails triggerFormDetails; TriggerFormDetails triggerFormDetails;
private:
IntListenerArray<15> triggerListeneres;
}; };
void triggerInfo(void); void triggerInfo(void);
@ -80,7 +76,6 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t timestamp DECLARE_ENG
void initTriggerCentral(Logging *sharedLogger); void initTriggerCentral(Logging *sharedLogger);
void printAllTriggers(); void printAllTriggers();
void addTriggerEventListener(ShaftPositionListener handler, const char *name, Engine *engine);
int isSignalDecoderError(void); int isSignalDecoderError(void);
void resetMaxValues(); void resetMaxValues();

View File

@ -11,9 +11,9 @@
* @author Andrey Belomutskiy, (c) 2012-2020 * @author Andrey Belomutskiy, (c) 2012-2020
*/ */
#include "logic_analyzer.h"
#include "global.h" #include "global.h"
#include "engine.h"
#include "logic_analyzer.h"
#include "os_access.h" #include "os_access.h"
#include "eficonsole.h" #include "eficonsole.h"
#include "pin_repository.h" #include "pin_repository.h"
@ -22,7 +22,6 @@
#include "trigger_central.h" #include "trigger_central.h"
#include "os_util.h" #include "os_util.h"
#include "engine_math.h" #include "engine_math.h"
#include "engine.h"
#include "rpm_calculator.h" #include "rpm_calculator.h"
#include "engine_sniffer.h" #include "engine_sniffer.h"
@ -128,7 +127,7 @@ WaveReader::WaveReader() {
hw = nullptr; hw = nullptr;
} }
static void waTriggerEventListener(trigger_event_e ckpSignalType, uint32_t index, efitick_t edgeTimestamp DECLARE_ENGINE_PARAMETER_SUFFIX) { void waTriggerEventListener(trigger_event_e ckpSignalType, uint32_t index, efitick_t edgeTimestamp DECLARE_ENGINE_PARAMETER_SUFFIX) {
(void)ckpSignalType; (void)ckpSignalType;
if (index != 0) { if (index != 0) {
return; return;
@ -227,10 +226,6 @@ void initWaveAnalyzer(Logging *sharedLogger) {
initWave(PROTOCOL_WA_CHANNEL_3, 2); initWave(PROTOCOL_WA_CHANNEL_3, 2);
initWave(PROTOCOL_WA_CHANNEL_4, 3); initWave(PROTOCOL_WA_CHANNEL_4, 3);
#if EFI_SHAFT_POSITION_INPUT
addTriggerEventListener(waTriggerEventListener, "wave analyzer", engine);
#endif
addConsoleAction("waveinfo", showWaveInfo); addConsoleAction("waveinfo", showWaveInfo);
} }

View File

@ -54,5 +54,7 @@ void initWaveAnalyzer(Logging *sharedLogger);
void printWave(Logging *logging); void printWave(Logging *logging);
void showWaveInfo(void); void showWaveInfo(void);
void waTriggerEventListener(trigger_event_e ckpSignalType, uint32_t index, efitick_t edgeTimestamp DECLARE_ENGINE_PARAMETER_SUFFIX);
#endif /* EFI_LOGIC_ANALYZER */ #endif /* EFI_LOGIC_ANALYZER */

View File

@ -244,7 +244,7 @@ static void endIntegration(void *) {
/** /**
* Shaft Position callback used to start or finish HIP integration * Shaft Position callback used to start or finish HIP integration
*/ */
static void intHoldCallback(trigger_event_e ckpEventType, uint32_t index, efitick_t edgeTimestamp DECLARE_ENGINE_PARAMETER_SUFFIX) { void intHoldCallback(trigger_event_e ckpEventType, uint32_t index, efitick_t edgeTimestamp DECLARE_ENGINE_PARAMETER_SUFFIX) {
(void)ckpEventType; (void)ckpEventType;
// this callback is invoked on interrupt thread // this callback is invoked on interrupt thread
if (index != 0) if (index != 0)
@ -423,11 +423,6 @@ void initHip9011(Logging *sharedLogger) {
instance.currentBandIndex = getBandIndex(); instance.currentBandIndex = getBandIndex();
/**
* this engine cycle callback would be scheduling actual integration start and end callbacks
*/
addTriggerEventListener(&intHoldCallback, "DD int/hold", engine);
// MISO PB14 // MISO PB14
// palSetPadMode(GPIOB, 14, PAL_MODE_ALTERNATE(EFI_SPI2_AF) | PAL_STM32_PUDR_PULLUP); // palSetPadMode(GPIOB, 14, PAL_MODE_ALTERNATE(EFI_SPI2_AF) | PAL_STM32_PUDR_PULLUP);
// MOSI PB15 // MOSI PB15

View File

@ -26,4 +26,4 @@ void setPrescalerAndSDO(int value);
void setKnockThresh(float value); void setKnockThresh(float value);
void setMaxKnockSubDeg(int value); void setMaxKnockSubDeg(int value);
void intHoldCallback(trigger_event_e ckpEventType, uint32_t index, efitick_t edgeTimestamp DECLARE_ENGINE_PARAMETER_SUFFIX);