From 84b71b475bed52d04ce5e839e0c0698d60284ffc Mon Sep 17 00:00:00 2001 From: rusEfi Date: Sun, 23 Nov 2014 22:03:16 -0600 Subject: [PATCH] auto-sync --- firmware/config/efifeatures.h | 2 +- firmware/controllers/algo/signal_executor.cpp | 37 ++++++++++--------- firmware/controllers/engine_controller.cpp | 4 ++ firmware/controllers/error_handling.c | 2 +- firmware/controllers/system/efiGpio.cpp | 13 +------ firmware/controllers/system/efiGpio.h | 22 +++++++++++ firmware/controllers/system/event_queue.cpp | 3 +- 7 files changed, 50 insertions(+), 33 deletions(-) diff --git a/firmware/config/efifeatures.h b/firmware/config/efifeatures.h index 8d1ba902a5..c7f23de56b 100644 --- a/firmware/config/efifeatures.h +++ b/firmware/config/efifeatures.h @@ -13,7 +13,7 @@ #define EFI_USE_CCM TRUE #ifndef EFI_ENABLE_ASSERTS - #define EFI_ENABLE_ASSERTS TRUE + #define EFI_ENABLE_ASSERTS FALSE #endif /* EFI_ENABLE_ASSERTS */ //#define EFI_UART_ECHO_TEST_MODE TRUE diff --git a/firmware/controllers/algo/signal_executor.cpp b/firmware/controllers/algo/signal_executor.cpp index a37572e3d3..a431be3b05 100644 --- a/firmware/controllers/algo/signal_executor.cpp +++ b/firmware/controllers/algo/signal_executor.cpp @@ -25,12 +25,15 @@ #include "main.h" #include "signal_executor.h" #include "efiGpio.h" +#include "engine.h" /** * Signal executors feed digital events right into WaveChart used by Sniffer tab of Dev Console */ #include "rpm_calculator.h" +EXTERN_ENGINE; + #include "wave_chart.h" extern WaveChart waveChart; @@ -38,6 +41,9 @@ extern WaveChart waveChart; static Logging logger; #endif +extern OutputPin outputs[IO_PIN_COUNT]; +extern pin_output_mode_e *pinDefaultState[IO_PIN_COUNT]; + void initSignalExecutor(void) { #if EFI_PROD_CODE || EFI_SIMULATOR initLogging(&logger, "s exec"); @@ -60,32 +66,25 @@ void turnPinHigh(io_pin_e pin) { #endif /* EFI_DEFAILED_LOGGING */ // turn the output level ACTIVE // todo: this XOR should go inside the setOutputPinValue method - setOutputPinValue(pin, TRUE); + doSetOutputPinValue(pin, true); // sleep for the needed duration -#if EFI_PROD_CODE || EFI_SIMULATOR -// if (pin == SPARKOUT_1_OUTPUT || pin == SPARKOUT_3_OUTPUT) { -// time_t now = hTimeNow(); -// float an = getCrankshaftAngle(now); -// scheduleMsg(&logger, "spark up%d %d", pin, now); -// scheduleMsg(&logger, "spark angle %d %f", (int)an, an); -// } -#endif - #if EFI_WAVE_CHART - // this is a performance optimization - array index is cheaper then invoking a method with 'switch' - const char *pinName = namedPinsArray[pin]; + // explicit check here is a performance optimization to speed up no-chart mode + if (!engineConfiguration->isDigitalChartEnabled) { + // this is a performance optimization - array index is cheaper then invoking a method with 'switch' + const char *pinName = namedPinsArray[pin]; // dbgDurr = hal_lld_get_counter_value() - dbgStart; - addWaveChartEvent(pinName, WC_UP); + addWaveChartEvent(pinName, WC_UP); + } #endif /* EFI_WAVE_ANALYZER */ // dbgDurr = hal_lld_get_counter_value() - dbgStart; } void turnPinLow(io_pin_e pin) { // turn off the output - // todo: this XOR should go inside the setOutputPinValue method - setOutputPinValue(pin, false); + doSetOutputPinValue(pin, false); #if EFI_DEFAILED_LOGGING systime_t after = hTimeNow(); @@ -94,10 +93,12 @@ void turnPinLow(io_pin_e pin) { #endif /* EFI_DEFAILED_LOGGING */ #if EFI_WAVE_CHART - // this is a performance optimization - array index is cheaper then invoking a method with 'switch' - const char *pinName = namedPinsArray[pin]; + if (!engineConfiguration->isDigitalChartEnabled) { + // this is a performance optimization - array index is cheaper then invoking a method with 'switch' + const char *pinName = namedPinsArray[pin]; - addWaveChartEvent(pinName, WC_DOWN); + addWaveChartEvent(pinName, WC_DOWN); + } #endif /* EFI_WAVE_ANALYZER */ } diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index 0781cfbd73..cc677d0f24 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -64,6 +64,10 @@ static LEElementPool lePool(mainPool, LE_ELEMENT_POOL_SIZE); static LEElement * fuelPumpLogic; static LEElement * radiatorFanLogic; +extern OutputPin outputs[IO_PIN_COUNT]; +extern pin_output_mode_e *pinDefaultState[IO_PIN_COUNT]; + + persistent_config_container_s persistentState CCM_OPTIONAL; /** diff --git a/firmware/controllers/error_handling.c b/firmware/controllers/error_handling.c index 47bd78bee2..7588f74a25 100644 --- a/firmware/controllers/error_handling.c +++ b/firmware/controllers/error_handling.c @@ -99,7 +99,7 @@ void onUnlockHook(void) { if (t > maxLockTime) { maxLockTime = t; } -// if (t > 10000) { +// if (t > 2800) { // // uncomment this if you want a nice stop for a breakpoint // maxLockTime = t + 1; // } diff --git a/firmware/controllers/system/efiGpio.cpp b/firmware/controllers/system/efiGpio.cpp index 23310fee96..22600225c9 100644 --- a/firmware/controllers/system/efiGpio.cpp +++ b/firmware/controllers/system/efiGpio.cpp @@ -96,18 +96,7 @@ extern uint32_t dbgStart; extern uint32_t dbgDurr; void setOutputPinValue(io_pin_e pin, int logicValue) { -#if EFI_PROD_CODE - if (outputs[pin].port != GPIO_NULL) { - efiAssertVoid(pinDefaultState[pin]!=NULL, "pin mode not initialized"); - pin_output_mode_e mode = *pinDefaultState[pin]; - efiAssertVoid(mode <= OM_OPENDRAIN_INVERTED, "invalid pin_output_mode_e"); -#else - pin_output_mode_e mode = OM_DEFAULT; -#endif - OutputPin *output = &outputs[pin]; - int eValue = getElectricalValue(logicValue, mode); - setPinValue(output, eValue, logicValue); - } + doSetOutputPinValue(pin, logicValue); } bool isPinAssigned(io_pin_e pin) { diff --git a/firmware/controllers/system/efiGpio.h b/firmware/controllers/system/efiGpio.h index 43a1cb9382..736eee8ad8 100644 --- a/firmware/controllers/system/efiGpio.h +++ b/firmware/controllers/system/efiGpio.h @@ -79,6 +79,28 @@ void setOutputPinValue(io_pin_e pin, int logicValue); bool isPinAssigned(io_pin_e pin); const char *getPinName(io_pin_e io_pin); + +#if EFI_PROD_CODE +#define doSetOutputPinValue(pin, logicValue) { \ + if (outputs[(pin)].port != GPIO_NULL) { \ + efiAssertVoid(pinDefaultState[pin]!=NULL, "pin mode not initialized"); \ + pin_output_mode_e mode = *pinDefaultState[pin]; \ + efiAssertVoid(mode <= OM_OPENDRAIN_INVERTED, "invalid pin_output_mode_e"); \ + OutputPin *output = &outputs[pin]; \ + int eValue = getElectricalValue(logicValue, mode); \ + setPinValue(output, eValue, logicValue); \ + } \ + } +#else + #define doSetOutputPinValue(pin, logicValue) { \ + pin_output_mode_e mode = OM_DEFAULT; \ + OutputPin *output = &outputs[pin]; \ + int eValue = getElectricalValue(logicValue, mode); \ + setPinValue(output, eValue, logicValue); \ + } +#endif + + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/firmware/controllers/system/event_queue.cpp b/firmware/controllers/system/event_queue.cpp index 1071ce5cfc..89f5855297 100644 --- a/firmware/controllers/system/event_queue.cpp +++ b/firmware/controllers/system/event_queue.cpp @@ -76,6 +76,7 @@ uint64_t EventQueue::getNextEventTime(uint64_t nowX) { } // static scheduling_s * longScheduling; +// static uint32_t cost; /** * Invoke all pending actions prior to specified timestamp @@ -111,7 +112,7 @@ bool EventQueue::executeAll(uint64_t now) { // uint32_t before = hal_lld_get_counter_value(); current->callback(current->param); // even with overflow it's safe to substract here -// uint32_t cost = hal_lld_get_counter_value() - before; +// cost = hal_lld_get_counter_value() - before; // if (cost > 2000) { // longScheduling = current; // cost++;