From 9cbdbb794eb91ce54833d5734900e0942c9a1f2a Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 3 Nov 2019 22:02:52 -0500 Subject: [PATCH] pieces of #971 --- firmware/controllers/sensors/map.cpp | 17 +++++++++++++++-- firmware/development/wave_analyzer.cpp | 12 ------------ firmware/development/wave_analyzer.h | 26 +++++++++++++------------- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/firmware/controllers/sensors/map.cpp b/firmware/controllers/sensors/map.cpp index e1f9a9d93e..ba06b2fab9 100644 --- a/firmware/controllers/sensors/map.cpp +++ b/firmware/controllers/sensors/map.cpp @@ -15,6 +15,7 @@ #if EFI_PROD_CODE #include "digital_input_hw.h" +#include "digital_input_exti.h" #include "pin_repository.h" #endif @@ -246,7 +247,7 @@ static void printMAPInfo(void) { } if (hasBaroSensor(PASS_ENGINE_PARAMETER_SIGNATURE)) { - scheduleMsg(logger, "baro type=%d value=%.2f", engineConfiguration->baroSensor.type, getBaroPressure()); + scheduleMsg(logger, "baro type=%d value=%.2f", engineConfiguration->baroSensor.type, getBaroPressure(PASS_ENGINE_PARAMETER_SIGNATURE)); if (engineConfiguration->baroSensor.type == MT_CUSTOM) { scheduleMsg(logger, "min=%.2f@%.2f max=%.2f@%.2f", engineConfiguration->baroSensor.lowValue, @@ -272,13 +273,24 @@ void initMapDecoder(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) { digitalMapInput->widthListeners.registerCallback((VoidInt) digitalMapWidthCallback, NULL); } +#else + #if EFI_PROD_CODE + efiExtiEnablePin( + "Frequency MAP", + CONFIGB(frequencyReportingMapInputPin), + PAL_EVENT_MODE_RISING_EDGE, + (palcallback_t)digitalMapWidthCallback, + nullptr + ); + #endif /* EFI_PROD_CODE */ +#endif /* HAL_USE_ICU */ if (CONFIG(useFixedBaroCorrFromMap)) { // Read initial MAP sensor value and store it for Baro correction. storedInitialBaroPressure = getRawMap(PASS_ENGINE_PARAMETER_SIGNATURE); scheduleMsg(logger, "Get initial baro MAP pressure = %.2fkPa", storedInitialBaroPressure); // validate if it's within a reasonable range (the engine should not be spinning etc.) - storedInitialBaroPressure = validateBaroMap(storedInitialBaroPressure); + storedInitialBaroPressure = validateBaroMap(storedInitialBaroPressure PASS_ENGINE_PARAMETER_SUFFIX); if (!cisnan(storedInitialBaroPressure)) { scheduleMsg(logger, "Using this fixed MAP pressure to override the baro correction!"); } else { @@ -286,6 +298,7 @@ void initMapDecoder(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) { } } +#if EFI_PROD_CODE addConsoleAction("mapinfo", printMAPInfo); #endif } diff --git a/firmware/development/wave_analyzer.cpp b/firmware/development/wave_analyzer.cpp index 0f5a1ee8ac..8466559da4 100644 --- a/firmware/development/wave_analyzer.cpp +++ b/firmware/development/wave_analyzer.cpp @@ -143,18 +143,6 @@ static void initWave(const char *name, int index) { WaveReader::WaveReader() { hw = nullptr; - last_wave_high_widthUs = 0; - name = nullptr; - fallEventCounter = riseEventCounter = 0; - currentRevolutionCounter = 0; - prevTotalOnTimeUs = 0; - totalOnTimeAccumulatorUs = 0; - lastActivityTimeUs = 0; - periodEventTimeUs = 0; - widthEventTimeUs = 0; - signalPeriodUs = 0; - waveOffsetUs = 0; - last_wave_low_widthUs = 0; } static void waTriggerEventListener(trigger_event_e ckpSignalType, uint32_t index DECLARE_ENGINE_PARAMETER_SUFFIX) { diff --git a/firmware/development/wave_analyzer.h b/firmware/development/wave_analyzer.h index a13b7026f8..e90127ba8b 100644 --- a/firmware/development/wave_analyzer.h +++ b/firmware/development/wave_analyzer.h @@ -23,34 +23,34 @@ public: void onFallEvent(); digital_input_s *hw; - const char *name; - volatile int fallEventCounter; - volatile int riseEventCounter; + const char *name = nullptr; + volatile int fallEventCounter = 0; + volatile int riseEventCounter = 0; - int currentRevolutionCounter; + int currentRevolutionCounter = 0; /** * Total ON time during last engine cycle */ - efitimeus_t prevTotalOnTimeUs; + efitimeus_t prevTotalOnTimeUs = 0; - efitimeus_t totalOnTimeAccumulatorUs; + efitimeus_t totalOnTimeAccumulatorUs = 0; - volatile efitimeus_t lastActivityTimeUs; // timestamp in microseconds ticks + volatile efitimeus_t lastActivityTimeUs = 0; // timestamp in microseconds ticks /** * time of signal fall event, in microseconds */ - volatile efitimeus_t periodEventTimeUs; - volatile efitimeus_t widthEventTimeUs; // time of signal rise in microseconds + volatile efitimeus_t periodEventTimeUs = 0; + volatile efitimeus_t widthEventTimeUs = 0; // time of signal rise in microseconds - volatile efitimeus_t signalPeriodUs; // period between two signal rises in microseconds + volatile efitimeus_t signalPeriodUs = 0; // period between two signal rises in microseconds /** * offset from engine cycle start in microseconds */ - volatile efitimeus_t waveOffsetUs; - volatile efitimeus_t last_wave_low_widthUs; // time period in systimer ticks - volatile efitimeus_t last_wave_high_widthUs; // time period in systimer ticks + volatile efitimeus_t waveOffsetUs = 0; + volatile efitimeus_t last_wave_low_widthUs = 0; // time period in systimer ticks + volatile efitimeus_t last_wave_high_widthUs = 0; // time period in systimer ticks }; void initWaveAnalyzer(Logging *sharedLogger);