diff --git a/firmware/console/binary/output_channels.txt b/firmware/console/binary/output_channels.txt index b4c2f8e800..a1bc674a88 100644 --- a/firmware/console/binary/output_channels.txt +++ b/firmware/console/binary/output_channels.txt @@ -343,5 +343,7 @@ uint16_t rpmAcceleration;dRPM;"RPM/s",1, 0, 0, 5, 0 int16_t autoscale rawBattery;;"V",{1/@@PACK_MULT_VOLTAGE@@}, 0, 0, 5, 3 - uint8_t[160 iterate] unusedAtTheEnd;;"",1, 0, 0, 0, 0 + uint8_t extiOverflowCount;;"", 1, 0, 0, 255, 0 + + uint8_t[159 iterate] unusedAtTheEnd;;"",1, 0, 0, 0, 0 end_struct diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index ecd8dad350..603cb52cf8 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -54,6 +54,7 @@ #include "buffered_writer.h" #include "dynoview.h" #include "frequency_sensor.h" +#include "digital_input_exti.h" extern bool main_loop_started; @@ -846,6 +847,9 @@ void updateTunerStudioState() { tsOutputChannels->triggerVvtFall = engine->triggerCentral.vvtEventFallCounter[0]; #endif // EFI_SHAFT_POSITION_INPUT +#if HAL_USE_PAL && EFI_PROD_CODE + tsOutputChannels->extiOverflowCount = getExtiOverflowCounter(); +#endif switch (engineConfiguration->debugMode) { case DBG_TPS_ACCEL: diff --git a/firmware/hw_layer/digital_input/digital_input_exti.cpp b/firmware/hw_layer/digital_input/digital_input_exti.cpp index ac45f97a6a..af426170d8 100644 --- a/firmware/hw_layer/digital_input/digital_input_exti.cpp +++ b/firmware/hw_layer/digital_input/digital_input_exti.cpp @@ -161,6 +161,8 @@ private: static ExtiQueue queue; +static uint8_t overflowCounter = 0; + CH_IRQ_HANDLER(STM32_I2C1_EVENT_HANDLER) { OSAL_IRQ_PROLOGUE(); @@ -185,12 +187,18 @@ CH_IRQ_HANDLER(STM32_I2C1_EVENT_HANDLER) { if (channel.Name) { channel.Callback(channel.CallbackData, timestamp); } + } else { + overflowCounter++; } } OSAL_IRQ_EPILOGUE(); } +uint8_t getExtiOverflowCounter() { + return overflowCounter; +} + void handleExtiIsr(uint8_t index) { // No need to lock anything, we're already the highest-pri interrupt! @@ -251,6 +259,10 @@ void efiExtiInit() { void efiExtiEnablePin(const char *, brain_pin_e, uint32_t, ExtiCallback, void *) { } void efiExtiDisablePin(brain_pin_e) { } +uint8_t getExtiOverflowCounter() { + return 0; +} + #endif #endif /* HAL_USE_PAL && EFI_PROD_CODE */ diff --git a/firmware/hw_layer/digital_input/digital_input_exti.h b/firmware/hw_layer/digital_input/digital_input_exti.h index b1100e7fab..ce2fb6b69c 100644 --- a/firmware/hw_layer/digital_input/digital_input_exti.h +++ b/firmware/hw_layer/digital_input/digital_input_exti.h @@ -14,4 +14,5 @@ using ExtiCallback = void(*)(void*, efitick_t); void efiExtiInit(); void efiExtiEnablePin(const char *msg, brain_pin_e pin, uint32_t mode, ExtiCallback cb, void *cb_data); void efiExtiDisablePin(brain_pin_e brainPin); +uint8_t getExtiOverflowCounter(); #endif /* HAL_USE_PAL */