diff --git a/firmware/controllers/algo/obd_error_codes.h b/firmware/controllers/algo/obd_error_codes.h index ce9ab36feb..8427c066bd 100644 --- a/firmware/controllers/algo/obd_error_codes.h +++ b/firmware/controllers/algo/obd_error_codes.h @@ -1876,16 +1876,16 @@ typedef enum { CUSTOM_ERR_ADC_USED = 6517, CUSTOM_ERR_ADC_DEPTH_SLOW = 6518, CUSTOM_ERR_ADC_DEPTH_FAST = 6519, - CUSTOM_ERR_6520 = 6520, - CUSTOM_ERR_6521 = 6521, - CUSTOM_ERR_6522 = 6522, - CUSTOM_ERR_6523 = 6523, + CUSTOM_ERR_ICU = 6520, + CUSTOM_ERR_ICU_AF = 6521, + CUSTOM_ERR_ICU_DRIVER = 6522, + CUSTOM_ERR_ICU_PIN = 6523, CUSTOM_ERR_UNEXPECTED_SPI = 6524, CUSTOM_ERR_EXT_MODE = 6525, CUSTOM_ERR_TIMER_OVERFLOW = 6526, - CUSTOM_ERR_6527 = 6527, - CUSTOM_ERR_6528 = 6528, - CUSTOM_ERR_6529 = 6529, + CUSTOM_ERR_NULL_TIMER_CALLBACK = 6527, + CUSTOM_ERR_SCHEDULING_ERROR = 6528, + CUSTOM_ERR_LOGGING_NOT_READY = 6529, CUSTOM_ERR_6530 = 6530, CUSTOM_ERR_6531 = 6531, CUSTOM_ERR_6532 = 6532, diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 01a9608372..a48479e59f 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -390,6 +390,7 @@ extern uint32_t maxLockTime; extern uint32_t maxEventQueueTime; extern uint32_t hipLastExecutionCount; extern uint32_t hwSetTimerTime; +extern uint32_t maxPrecisionTCallbackDuration; extern int maxHowFarOff; extern uint32_t *cyccnt; @@ -400,6 +401,7 @@ extern int vvtEventFallCounter; void resetMaxValues() { #if (EFI_PROD_CODE || EFI_SIMULATOR) || defined(__DOXYGEN__) maxEventQueueTime = triggerMaxDuration = 0; + maxPrecisionTCallbackDuration = 0; #endif /* EFI_PROD_CODE || EFI_SIMULATOR */ } @@ -501,6 +503,7 @@ void triggerInfo(void) { scheduleMsg(logger, "hwSetTimerTime %d", hwSetTimerTime); scheduleMsg(logger, "totalTriggerHandlerMaxTime=%d", triggerMaxDuration); + scheduleMsg(logger, "maxPrecisionTCallbackDuration=%d", maxPrecisionTCallbackDuration); resetMaxValues(); #endif /* EFI_PROD_CODE */ diff --git a/firmware/hw_layer/digital_input_hw.cpp b/firmware/hw_layer/digital_input_hw.cpp index fab1b364f9..1bd47a2291 100644 --- a/firmware/hw_layer/digital_input_hw.cpp +++ b/firmware/hw_layer/digital_input_hw.cpp @@ -34,7 +34,7 @@ static digital_input_s * finddigital_input_s(ICUDriver *driver) { return ®isteredIcus.elements[i]; } } - firmwareError(CUSTOM_ERR_6520, "reader not found"); + firmwareError(CUSTOM_ERR_ICU, "reader not found"); return (digital_input_s *) NULL; } @@ -60,7 +60,7 @@ static void icuPeriordCallBack(ICUDriver *driver) { static uint32_t getAlternateFunctions(ICUDriver *driver) { if (driver == NULL) { - firmwareError(CUSTOM_ERR_6521, "getAlternateFunctions(NULL)"); + firmwareError(CUSTOM_ERR_ICU_AF, "getAlternateFunctions(NULL)"); return 0xffffffff; } #if STM32_ICU_USE_TIM1 @@ -88,7 +88,7 @@ static uint32_t getAlternateFunctions(ICUDriver *driver) { return GPIO_AF_TIM9; } #endif - firmwareError(CUSTOM_ERR_6522, "No such driver"); + firmwareError(CUSTOM_ERR_ICU_DRIVER, "No such driver"); return 0xffffffff; } @@ -115,7 +115,7 @@ icuchannel_t getInputCaptureChannel(brain_pin_e hwPin) { case GPIOE_11: // TIM1 return ICU_CHANNEL_2; default: - firmwareError(CUSTOM_ERR_6523, "Unexpected hw pin in getInputCaptureChannel %s", hwPortname(hwPin)); + firmwareError(CUSTOM_ERR_ICU_PIN, "Unexpected hw pin in getInputCaptureChannel %s", hwPortname(hwPin)); return ICU_CHANNEL_1; } } diff --git a/firmware/hw_layer/microsecond_timer.cpp b/firmware/hw_layer/microsecond_timer.cpp index 54e4197ab8..37b3177dd5 100644 --- a/firmware/hw_layer/microsecond_timer.cpp +++ b/firmware/hw_layer/microsecond_timer.cpp @@ -19,6 +19,9 @@ // https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https%3a%2f%2fmy.st.com%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fcortex_mx_stm32%2fInterrupt%20on%20CEN%20bit%20setting%20in%20TIM7&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=474 #if (EFI_PROD_CODE && HAL_USE_GPT) || defined(__DOXYGEN__) +#include "efilib2.h" + +uint32_t maxPrecisionTCallbackDuration = 0; #define GPTDEVICE GPTD5 @@ -79,7 +82,7 @@ static void callback(GPTDriver *gptp) { (void)gptp; timerCallbackCounter++; if (globalTimerCallback == NULL) { - firmwareError(CUSTOM_ERR_6527, "NULL globalTimerCallback"); + firmwareError(CUSTOM_ERR_NULL_TIMER_CALLBACK, "NULL globalTimerCallback"); return; } isTimerPending = false; @@ -93,14 +96,19 @@ static void callback(GPTDriver *gptp) { // chSysUnlockFromISR() // ; + uint32_t before = GET_TIMESTAMP(); globalTimerCallback(NULL); + uint32_t precisionCallbackDuration = GET_TIMESTAMP() - before; + if (precisionCallbackDuration > maxPrecisionTCallbackDuration) { + maxPrecisionTCallbackDuration = precisionCallbackDuration; + } } static void usTimerWatchDog(void) { if (getTimeNowNt() >= lastSetTimerTimeNt + 2 * CORE_CLOCK) { strcpy(buff, "no_event"); itoa10(&buff[8], lastSetTimerValue); - firmwareError(CUSTOM_ERR_6528, buff); + firmwareError(CUSTOM_ERR_SCHEDULING_ERROR, buff); return; } diff --git a/firmware/util/datalogging.cpp b/firmware/util/datalogging.cpp index cb1da566da..0005e21f43 100644 --- a/firmware/util/datalogging.cpp +++ b/firmware/util/datalogging.cpp @@ -51,7 +51,7 @@ static bool intermediateLoggingBufferInited = false; */ static ALWAYS_INLINE bool validateBuffer(Logging *logging, uint32_t extraLen) { if (logging->buffer == NULL) { - firmwareError(CUSTOM_ERR_6529, "Logging not initialized: %s", logging->name); + firmwareError(CUSTOM_ERR_LOGGING_NOT_READY, "Logging not initialized: %s", logging->name); return true; }