diff --git a/firmware/console/binary/tooth_logger.cpp b/firmware/console/binary/tooth_logger.cpp index b99621ba21..70bc003f1a 100644 --- a/firmware/console/binary/tooth_logger.cpp +++ b/firmware/console/binary/tooth_logger.cpp @@ -167,7 +167,7 @@ void ReturnToothLoggerBuffer(CompositeBuffer* buffer) { chibios_rt::CriticalSectionLocker csl; msg_t msg = freeBuffers.postI(buffer); - efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, msg == MSG_OK, "Composite logger post to free buffer fail"); + criticalAssertVoid(msg == MSG_OK, "Composite logger post to free buffer fail"); } static CompositeBuffer* findBuffer(efitick_t timestamp) { diff --git a/firmware/console/binary/tunerstudio_io.cpp b/firmware/console/binary/tunerstudio_io.cpp index 952bf0da0d..9a37952f47 100644 --- a/firmware/console/binary/tunerstudio_io.cpp +++ b/firmware/console/binary/tunerstudio_io.cpp @@ -23,7 +23,7 @@ size_t TsChannelBase::read(uint8_t* buffer, size_t size) { void TsChannelBase::copyAndWriteSmallCrcPacket(uint8_t responseCode, const uint8_t* buf, size_t size) { // don't transmit too large a buffer - efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, !isBigPacket(size), "copyAndWriteSmallCrcPacket tried to transmit too large a packet") + criticalAssertVoid(!isBigPacket(size), "copyAndWriteSmallCrcPacket tried to transmit too large a packet") // If transmitting data, copy it in to place in the scratch buffer // We want to prevent the data changing itself (higher priority threads could write @@ -37,7 +37,7 @@ void TsChannelBase::copyAndWriteSmallCrcPacket(uint8_t responseCode, const uint8 } void TsChannelBase::crcAndWriteBuffer(uint8_t responseCode, size_t size) { - efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, !isBigPacket(size), "crcAndWriteBuffer tried to transmit too large a packet") + criticalAssertVoid(!isBigPacket(size), "crcAndWriteBuffer tried to transmit too large a packet") // Index 0/1 = packet size (big endian) *(uint16_t*)scratchBuffer = SWAP_UINT16(size + 1); diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index df14066b63..afab25a84a 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -180,7 +180,7 @@ void Engine::periodicSlowCallback() { #endif // EFI_PROD_CODE #if ANALOG_HW_CHECK_MODE - efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, isAdcChannelValid(engineConfiguration->clt.adcChannel), "No CLT setting"); + criticalAssertVoid(isAdcChannelValid(engineConfiguration->clt.adcChannel), "No CLT setting"); efitimesec_t secondsNow = getTimeNowS(); #if ! HW_CHECK_ALWAYS_STIMULATE diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index a2a94a69dc..f909379ec4 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -256,7 +256,7 @@ static void initTemperatureCurve(float *bins, float *values, int size, float def } void prepareVoidConfiguration(engine_configuration_s *engineConfiguration) { - efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, engineConfiguration != NULL, "ec NULL"); + criticalAssertVoid(engineConfiguration != NULL, "ec NULL"); efi::clear(engineConfiguration); engineConfiguration->clutchDownPinMode = PI_PULLUP; diff --git a/firmware/controllers/engine_cycle/high_pressure_fuel_pump.cpp b/firmware/controllers/engine_cycle/high_pressure_fuel_pump.cpp index 9e68c1ac03..9765fc32d4 100644 --- a/firmware/controllers/engine_cycle/high_pressure_fuel_pump.cpp +++ b/firmware/controllers/engine_cycle/high_pressure_fuel_pump.cpp @@ -165,7 +165,7 @@ void HpfpController::onFastCallback() { m_deadtime = 0; } else { #if EFI_PROD_CODE && EFI_SHAFT_POSITION_INPUT - efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, engine->triggerCentral.triggerShape.getSize() > engineConfiguration->hpfpCamLobes * 6, "Too few trigger tooth for this number of HPFP lobes"); + criticalAssertVoid(engine->triggerCentral.triggerShape.getSize() > engineConfiguration->hpfpCamLobes * 6, "Too few trigger tooth for this number of HPFP lobes"); #endif // EFI_PROD_CODE // Convert deadtime from ms to degrees based on current RPM float deadtime_ms = interpolate2d( diff --git a/firmware/controllers/lua/lua.cpp b/firmware/controllers/lua/lua.cpp index cbb047400a..bb0d30f021 100644 --- a/firmware/controllers/lua/lua.cpp +++ b/firmware/controllers/lua/lua.cpp @@ -54,7 +54,7 @@ public: } void reinit(char *buffer, size_t size) { - efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, m_memoryUsed == 0, "Too late to reinit Lua heap"); + criticalAssertVoid(m_memoryUsed == 0, "Too late to reinit Lua heap"); m_size = size; m_buffer = buffer; diff --git a/firmware/controllers/system/timer/event_queue.cpp b/firmware/controllers/system/timer/event_queue.cpp index 806b20ddaf..f336962b55 100644 --- a/firmware/controllers/system/timer/event_queue.cpp +++ b/firmware/controllers/system/timer/event_queue.cpp @@ -107,7 +107,7 @@ void EventQueue::remove(scheduling_s* scheduling) { return; } - efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, current == scheduling, "current not equal to scheduling"); + criticalAssertVoid(current == scheduling, "current not equal to scheduling"); // Link around the removed item prev->nextScheduling_s = current->nextScheduling_s; diff --git a/firmware/controllers/trigger/decoders/trigger_renault.cpp b/firmware/controllers/trigger/decoders/trigger_renault.cpp index 3fdfb70ee8..16b33edf18 100644 --- a/firmware/controllers/trigger/decoders/trigger_renault.cpp +++ b/firmware/controllers/trigger/decoders/trigger_renault.cpp @@ -19,7 +19,7 @@ void initialize60_2_2_Renault_F(TriggerWaveform *s) { NO_LEFT_FILTER, 719); #if EFI_UNIT_TEST - efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, s->wave.phaseCount == (totalTeethCount - skipped) * 2 - 1, "Tooth count 60-3"); + criticalAssertVoid(s->wave.phaseCount == (totalTeethCount - skipped) * 2 - 1, "Tooth count 60-3"); #endif // EFI_UNIT_TEST float specialPosition = 58 * oneTooth; @@ -30,7 +30,7 @@ void initialize60_2_2_Renault_F(TriggerWaveform *s) { specialPosition - 1, specialPosition - 1 + oneTooth); #if EFI_UNIT_TEST - efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, s->wave.phaseCount == (totalTeethCount - skipped) * 2 + 1, "Tooth count 60-2-2"); + criticalAssertVoid(s->wave.phaseCount == (totalTeethCount - skipped) * 2 + 1, "Tooth count 60-2-2"); #endif // EFI_UNIT_TEST s->addEvent(1, TriggerValue::FALL, TriggerWheel::T_PRIMARY); diff --git a/firmware/controllers/trigger/decoders/trigger_structure.cpp b/firmware/controllers/trigger/decoders/trigger_structure.cpp index 632ca52e1b..966b696ae5 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.cpp +++ b/firmware/controllers/trigger/decoders/trigger_structure.cpp @@ -342,7 +342,7 @@ void TriggerWaveform::setTriggerSynchronizationGap2(float syncRatioFrom, float s void TriggerWaveform::setTriggerSynchronizationGap3(int gapIndex, float syncRatioFrom, float syncRatioTo) { isSynchronizationNeeded = true; - efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, gapIndex >= 0 && gapIndex < GAP_TRACKING_LENGTH, "gapIndex out of range"); + criticalAssertVoid(gapIndex >= 0 && gapIndex < GAP_TRACKING_LENGTH, "gapIndex out of range"); syncronizationRatioFrom[gapIndex] = syncRatioFrom; syncronizationRatioTo[gapIndex] = syncRatioTo; if (gapIndex == 0) { diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 868225b399..4485accdd4 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -979,7 +979,7 @@ static void resetRunningTriggerCounters() { void onConfigurationChangeTriggerCallback() { bool changed = false; // todo: how do we static_assert here? - efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, efi::size(engineConfiguration->camInputs) == efi::size(engineConfiguration->vvtOffsets), "sizes"); + criticalAssertVoid(efi::size(engineConfiguration->camInputs) == efi::size(engineConfiguration->vvtOffsets), "sizes"); for (size_t camIndex = 0; camIndex < efi::size(engineConfiguration->camInputs); camIndex++) { changed |= isConfigurationChanged(camInputs[camIndex]); diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index 6bef6e0592..0d6ae73577 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -163,7 +163,7 @@ void TriggerFormDetails::prepareEventAngles(TriggerWaveform *shape) { fixAngle(angle, "trgSync", ObdCode::CUSTOM_TRIGGER_SYNC_ANGLE_RANGE); if (shape->useOnlyRisingEdges) { - efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, triggerDefinitionIndex < triggerShapeLength, "trigger shape fail"); + criticalAssertVoid(triggerDefinitionIndex < triggerShapeLength, "trigger shape fail"); assertIsInBounds(triggerDefinitionIndex, shape->isRiseEvent, "isRise"); // In case this is a rising event, replace the following fall event with the rising as well diff --git a/firmware/hw_layer/digital_input/digital_input_exti.cpp b/firmware/hw_layer/digital_input/digital_input_exti.cpp index 043ae29ce9..988bf9052d 100644 --- a/firmware/hw_layer/digital_input/digital_input_exti.cpp +++ b/firmware/hw_layer/digital_input/digital_input_exti.cpp @@ -42,7 +42,7 @@ void efiExtiEnablePin(const char *msg, brain_pin_e brainPin, uint32_t mode, Exti return; } - efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, msg, "efiExtiEnablePin msg must not be null"); + criticalAssertVoid(msg, "efiExtiEnablePin msg must not be null"); ioportid_t port = getHwPort(msg, brainPin); if (port == NULL) { diff --git a/firmware/hw_layer/microsecond_timer/microsecond_timer.cpp b/firmware/hw_layer/microsecond_timer/microsecond_timer.cpp index 18bbaa09ef..001a0b5f30 100644 --- a/firmware/hw_layer/microsecond_timer/microsecond_timer.cpp +++ b/firmware/hw_layer/microsecond_timer/microsecond_timer.cpp @@ -50,7 +50,7 @@ static bool hwStarted = false; * This function should be invoked under kernel lock which would disable interrupts. */ void setHardwareSchedulerTimer(efitick_t nowNt, efitick_t setTimeNt) { - efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, hwStarted, "HW.started"); + criticalAssertVoid(hwStarted, "HW.started"); // How many ticks in the future is this event? auto timeDeltaNt = setTimeNt - nowNt; diff --git a/firmware/hw_layer/smart_gpio.cpp b/firmware/hw_layer/smart_gpio.cpp index c39e089a3b..a6a54c2412 100644 --- a/firmware/hw_layer/smart_gpio.cpp +++ b/firmware/hw_layer/smart_gpio.cpp @@ -221,7 +221,7 @@ void initSmartGpio() { tle6240.spi_bus = getSpiDevice(engineConfiguration->tle6240spiDevice); int ret = tle6240_add(Gpio::TLE6240_PIN_1, 0, &tle6240); - efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, ret == (int)Gpio::TLE6240_PIN_1, "tle6240"); + criticalAssertVoid(ret == (int)Gpio::TLE6240_PIN_1, "tle6240"); } #endif /* (BOARD_TLE6240_COUNT > 0) */ @@ -234,7 +234,7 @@ void initSmartGpio() { // todo: propogate 'basePinOffset' parameter int ret = mc33972_add(Gpio::MC33972_PIN_1, 0, &mc33972); - efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, ret == (int)Gpio::MC33972_PIN_1, "mc33972"); + criticalAssertVoid(ret == (int)Gpio::MC33972_PIN_1, "mc33972"); } #endif /* (BOARD_MC33972_COUNT > 0) */ @@ -247,7 +247,7 @@ void initSmartGpio() { // todo: propogate 'basePinOffset' parameter int ret = l9779_add(Gpio::L9779_IGN_1, 0, &l9779_cfg); - efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, ret == (int)Gpio::L9779_IGN_1, "l9779"); + criticalAssertVoid(ret == (int)Gpio::L9779_IGN_1, "l9779"); } #endif /* (BOARD_L9779_COUNT > 0) */ @@ -264,7 +264,7 @@ void initSmartGpio() { /* spi_bus == null checked in _add function */ int ret = tle8888_add(Gpio::TLE8888_PIN_1, 0, &tle8888_cfg); - efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, ret == (int)Gpio::TLE8888_PIN_1, "tle8888"); + criticalAssertVoid(ret == (int)Gpio::TLE8888_PIN_1, "tle8888"); } #endif /* (BOARD_TLE8888_COUNT > 0) */ @@ -275,7 +275,7 @@ void initSmartGpio() { drv8860.spi_bus = getSpiDevice(engineConfiguration->drv8860spiDevice); int ret = drv8860_add(Gpio::DRV8860_PIN_1, 0, &drv8860); - efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, ret == (int)Gpio::DRV8860_PIN_1, "drv8860"); + criticalAssertVoid(ret == (int)Gpio::DRV8860_PIN_1, "drv8860"); } #endif /* (BOARD_DRV8860_COUNT > 0) */ diff --git a/firmware/init/sensor/init_tps.cpp b/firmware/init/sensor/init_tps.cpp index 8fb7518da7..a17566c87e 100644 --- a/firmware/init/sensor/init_tps.cpp +++ b/firmware/init/sensor/init_tps.cpp @@ -189,7 +189,7 @@ bool isDigitalTps1() { } void initTps() { - efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, engineConfiguration != nullptr, "null engineConfiguration"); + criticalAssertVoid(engineConfiguration != nullptr, "null engineConfiguration"); percent_t min = engineConfiguration->tpsErrorDetectionTooLow; percent_t max = engineConfiguration->tpsErrorDetectionTooHigh; diff --git a/firmware/util/efilib.h b/firmware/util/efilib.h index 33641b79e0..f97a0141a6 100644 --- a/firmware/util/efilib.h +++ b/firmware/util/efilib.h @@ -90,7 +90,7 @@ bool isPhaseInRange(float test, float current, float next); #define IS_NEGATIVE_ZERO(value) (__builtin_signbit(value) && value==0) #define fixNegativeZero(value) (IS_NEGATIVE_ZERO(value) ? 0 : value) -#define assertIsInBounds(length, array, msg) efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, std::is_unsigned_v && (length) < efi::size(array), msg) +#define assertIsInBounds(length, array, msg) criticalAssertVoid(std::is_unsigned_v && (length) < efi::size(array), msg) #define assertIsInBoundsWithResult(length, array, msg, failedResult) efiAssert(ObdCode::OBD_PCM_Processor_Fault, std::is_unsigned_v && (length) < efi::size(array), msg, failedResult) diff --git a/firmware/util/math/biquad.cpp b/firmware/util/math/biquad.cpp index 5d6a6350b0..a2b11546a5 100644 --- a/firmware/util/math/biquad.cpp +++ b/firmware/util/math/biquad.cpp @@ -30,7 +30,7 @@ static float getNorm(float K, float Q) { } void Biquad::configureBandpass(float samplingFrequency, float centerFrequency, float Q) { - efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, samplingFrequency >= 2.5f * centerFrequency, "Invalid biquad parameters"); + criticalAssertVoid(samplingFrequency >= 2.5f * centerFrequency, "Invalid biquad parameters"); float K = getK(samplingFrequency, centerFrequency); float norm = getNorm(K, Q); @@ -43,7 +43,7 @@ void Biquad::configureBandpass(float samplingFrequency, float centerFrequency, f } void Biquad::configureLowpass(float samplingFrequency, float cutoffFrequency, float Q) { - efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, samplingFrequency >= 2.5f * cutoffFrequency, "Invalid biquad parameters"); + criticalAssertVoid(samplingFrequency >= 2.5f * cutoffFrequency, "Invalid biquad parameters"); float K = getK(samplingFrequency, cutoffFrequency); float norm = getNorm(K, Q); diff --git a/simulator/simulator/rusEfiFunctionalTest.cpp b/simulator/simulator/rusEfiFunctionalTest.cpp index d4d6794db5..a49dd05874 100644 --- a/simulator/simulator/rusEfiFunctionalTest.cpp +++ b/simulator/simulator/rusEfiFunctionalTest.cpp @@ -118,13 +118,13 @@ static void runToothLoggerTest() { { CompositeBuffer * toothBuffer = GetToothLoggerBufferNonblocking(); - efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, toothBuffer != nullptr, "filled buffer expected"); + criticalAssertVoid(toothBuffer != nullptr, "filled buffer expected"); size_t size = toothBuffer->nextIdx * sizeof(composite_logger_s); - efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, size != 0, "Positive payload size expected"); + criticalAssertVoid(size != 0, "Positive payload size expected"); const uint8_t* ptr = reinterpret_cast(toothBuffer->buffer); - efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, ptr != nullptr, "Payload reference expected"); + criticalAssertVoid(ptr != nullptr, "Payload reference expected"); } }