reducing code duplication

This commit is contained in:
rusefi 2023-06-11 23:17:13 -04:00
parent 731fd89ef7
commit f77f356e6d
11 changed files with 15 additions and 13 deletions

View File

@ -995,7 +995,7 @@ void validateConfiguration() {
void applyNonPersistentConfiguration() {
#if EFI_PROD_CODE
efiAssertVoid(ObdCode::CUSTOM_APPLY_STACK, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "apply c");
efiAssertVoid(ObdCode::CUSTOM_APPLY_STACK, assertRemainingStack(), "apply c");
efiPrintf("applyNonPersistentConfiguration()");
#endif

View File

@ -197,7 +197,7 @@ void InjectionEvent::onTriggerTooth(int rpm, efitick_t nowNt, float currentPhase
static void handleFuel(int rpm, efitick_t nowNt, float currentPhase, float nextPhase) {
ScopePerf perf(PE::HandleFuel);
efiAssertVoid(ObdCode::CUSTOM_STACK_6627, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "lowstck#3");
efiAssertVoid(ObdCode::CUSTOM_STACK_6627, assertRemainingStack(), "lowstck#3");
LimpState limitedFuelState = getLimpManager()->allowInjection();

View File

@ -59,7 +59,7 @@ static void endAveraging(MapAverager* arg);
static size_t currentMapAverager = 0;
static void startAveraging(scheduling_s *endAveragingScheduling) {
efiAssertVoid(ObdCode::CUSTOM_ERR_6649, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "lowstck#9");
efiAssertVoid(ObdCode::CUSTOM_ERR_6649, assertRemainingStack(), "lowstck#9");
// TODO: set currentMapAverager based on cylinder bank
auto& averager = getMapAvg(currentMapAverager);
@ -126,7 +126,7 @@ void MapAverager::stop() {
* as fast as possible
*/
void mapAveragingAdcCallback(float instantVoltage) {
efiAssertVoid(ObdCode::CUSTOM_ERR_6650, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "lowstck#9a");
efiAssertVoid(ObdCode::CUSTOM_ERR_6650, assertRemainingStack(), "lowstck#9a");
SensorResult mapResult = getMapAvg(currentMapAverager).submit(instantVoltage);

View File

@ -34,7 +34,7 @@
uint32_t hwSetTimerDuration;
void globalTimerCallback() {
efiAssertVoid(ObdCode::CUSTOM_ERR_6624, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "lowstck#2y");
efiAssertVoid(ObdCode::CUSTOM_ERR_6624, assertRemainingStack(), "lowstck#2y");
___engine.executor.onTimerCallback();
}

View File

@ -413,7 +413,7 @@ void TriggerWaveform::setThirdTriggerSynchronizationGap(float syncRatio) {
void TriggerWaveform::initializeTriggerWaveform(operation_mode_e triggerOperationMode, const trigger_config_s &triggerType) {
#if EFI_PROD_CODE
efiAssertVoid(ObdCode::CUSTOM_ERR_6641, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "init t");
efiAssertVoid(ObdCode::CUSTOM_ERR_6641, assertRemainingStack(), "init t");
efiPrintf("initializeTriggerWaveform(%s/%d)", getTrigger_type_e(triggerType.type), (int)triggerType.type);
#endif

View File

@ -1039,7 +1039,7 @@ static void calculateTriggerSynchPoint(
TriggerDecoderBase& initState) {
#if EFI_PROD_CODE
efiAssertVoid(ObdCode::CUSTOM_TRIGGER_STACK, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "calc s");
efiAssertVoid(ObdCode::CUSTOM_TRIGGER_STACK, assertRemainingStack(), "calc s");
#endif
shape.initializeSyncPoint(initState, primaryTriggerConfiguration);

View File

@ -694,7 +694,7 @@ uint32_t TriggerDecoderBase::findTriggerZeroEventIndex(
TriggerWaveform& shape,
const TriggerConfiguration& triggerConfiguration) {
#if EFI_PROD_CODE
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "findPos", -1);
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, assertRemainingStack(), "findPos", -1);
#endif

View File

@ -57,6 +57,8 @@ typedef unsigned int time_t;
#define getCurrentRemainingStack() getRemainingStack(chThdGetSelfX())
#define assertRemainingStack() (getCurrentRemainingStack() > EXPECTED_REMAINING_STACK)
#define EFI_ERROR_CODE 0xffffffff
/**

View File

@ -80,7 +80,7 @@ extern bool isSpiInitialized[5];
* Only one consumer can use SPI bus at a given time
*/
void lockSpi(spi_device_e device) {
efiAssertVoid(ObdCode::CUSTOM_STACK_SPI, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "lockSpi");
efiAssertVoid(ObdCode::CUSTOM_STACK_SPI, assertRemainingStack(), "lockSpi");
spiAcquireBus(getSpiDevice(device));
}
@ -177,7 +177,7 @@ void onFastAdcComplete(adcsample_t*) {
/**
* this callback is executed 10 000 times a second, it needs to be as fast as possible
*/
efiAssertVoid(ObdCode::CUSTOM_STACK_ADC, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "lowstck#9b");
efiAssertVoid(ObdCode::CUSTOM_STACK_ADC, assertRemainingStack(), "lowstck#9b");
#if EFI_SENSOR_CHART && EFI_SHAFT_POSITION_INPUT
if (getEngineState()->sensorChartMode == SC_AUX_FAST1) {
@ -370,7 +370,7 @@ void setBor(int borValue) {
// This function initializes hardware that can do so before configuration is loaded
void initHardwareNoConfig() {
efiAssertVoid(ObdCode::CUSTOM_IH_STACK, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "init h");
efiAssertVoid(ObdCode::CUSTOM_IH_STACK, assertRemainingStack(), "init h");
efiPrintf("initHardware()");

View File

@ -78,7 +78,7 @@ void Logging::appendFast(const char *text) {
}
void Logging::appendPrintf(const char *fmt, ...) {
efiAssertVoid(ObdCode::CUSTOM_APPEND_STACK, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "lowstck#4");
efiAssertVoid(ObdCode::CUSTOM_APPEND_STACK, assertRemainingStack(), "lowstck#4");
size_t available = remainingSize();

View File

@ -34,7 +34,7 @@
uint32_t hwSetTimerDuration;
void globalTimerCallback() {
efiAssertVoid(ObdCode::CUSTOM_ERR_6624, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "lowstck#2y");
efiAssertVoid(ObdCode::CUSTOM_ERR_6624, assertRemainingStack(), "lowstck#2y");
___engine.executor.onTimerCallback();
}