From 13e255cb500dbbd0f899218a03329fbd6250ac6e Mon Sep 17 00:00:00 2001 From: rusEfi Date: Fri, 6 Jan 2017 11:02:49 -0500 Subject: [PATCH] auto-sync --- firmware/controllers/algo/advance_map.cpp | 4 ++++ firmware/controllers/core/fsio_impl.cpp | 4 ++-- firmware/controllers/system/efiGpio.h | 11 ++++++---- .../trigger/main_trigger_callback.cpp | 16 ++++++++------ .../controllers/trigger/trigger_central.cpp | 22 ++++++++++--------- .../trigger/trigger_emulator_algo.cpp | 4 ++-- firmware/rusefi.cpp | 6 ++--- firmware/util/cli_registry.cpp | 4 ++-- firmware/util/histogram.c | 2 +- unit_tests/efifeatures.h | 2 +- .../simulator/efifeatures.h | 2 +- 11 files changed, 44 insertions(+), 33 deletions(-) diff --git a/firmware/controllers/algo/advance_map.cpp b/firmware/controllers/algo/advance_map.cpp index edcdc264dd..541c7759af 100644 --- a/firmware/controllers/algo/advance_map.cpp +++ b/firmware/controllers/algo/advance_map.cpp @@ -27,7 +27,9 @@ EXTERN_ENGINE; +#if !EFI_UNIT_TEST || defined(__DOXYGEN__) extern TunerStudioOutputChannels tsOutputChannels; +#endif static ign_Map3D_t advanceMap("advance"); static ign_Map3D_t iatAdvanceCorrectionMap("iat corr"); @@ -83,8 +85,10 @@ static angle_t getRunningAdvance(int rpm, float engineLoad DECLARE_ENGINE_PARAME iatCorrection = iatAdvanceCorrectionMap.getValue((float) rpm, engine->engineState.iat); } if (engineConfiguration->debugMode == DBG_TIMING) { +#if !EFI_UNIT_TEST || defined(__DOXYGEN__) tsOutputChannels.debugFloatField1 = iatCorrection; tsOutputChannels.debugFloatField2 = engine->engineState.cltTimingCorrection; +#endif } float result = advanceMap.getValue((float) rpm, engineLoad) diff --git a/firmware/controllers/core/fsio_impl.cpp b/firmware/controllers/core/fsio_impl.cpp index bc4bfe44eb..18cd25e4a8 100644 --- a/firmware/controllers/core/fsio_impl.cpp +++ b/firmware/controllers/core/fsio_impl.cpp @@ -55,10 +55,10 @@ static LEElementPool evalPool(evalPoolElements, LE_EVAL_POOL_SIZE); #define SYS_ELEMENT_POOL_SIZE 128 #define UD_ELEMENT_POOL_SIZE 128 -static LEElement sysElements[SYS_ELEMENT_POOL_SIZE]; +static LEElement sysElements[SYS_ELEMENT_POOL_SIZE] CCM_OPTIONAL; LEElementPool sysPool(sysElements, SYS_ELEMENT_POOL_SIZE); -static LEElement userElements[UD_ELEMENT_POOL_SIZE]; +static LEElement userElements[UD_ELEMENT_POOL_SIZE] CCM_OPTIONAL; LEElementPool userPool(userElements, UD_ELEMENT_POOL_SIZE); static LEElement * fsioLogics[LE_COMMAND_COUNT] CCM_OPTIONAL; diff --git a/firmware/controllers/system/efiGpio.h b/firmware/controllers/system/efiGpio.h index 9f93866deb..7ff28708a2 100644 --- a/firmware/controllers/system/efiGpio.h +++ b/firmware/controllers/system/efiGpio.h @@ -30,14 +30,15 @@ public: void unregister(); #if EFI_PROD_CODE || defined(__DOXYGEN__) ioportid_t port; - int pin; + uint8_t pin; #endif /* EFI_PROD_CODE */ + int8_t currentLogicValue; + // 4 byte pointer is a bit of a memory waste here pin_output_mode_e *modePtr; /** * we track current pin status so that we do not touch the actual hardware if we want to write new pin bit * which is same as current pin value. This maybe helps in case of status leds, but maybe it's a total over-engineering */ - int currentLogicValue; }; class NamedOutputPin : public OutputPin { @@ -48,6 +49,7 @@ public: * @return true if pin was stopped */ bool stop(); + // todo: char pointer is a bit of a memory waste here, we can reduce RAM usage by software-based getName() method const char *name; }; @@ -56,9 +58,10 @@ public: InjectorOutputPin(); void reset(); efitimeus_t overlappingScheduleOffTime; - int injectorIndex; + // todo: implement this via address manipulation to reduce memory usage + int8_t injectorIndex; bool cancelNextTurningInjectorOff; - int overlappingCounter; + int8_t overlappingCounter; }; class IgnitionOutputPin : public NamedOutputPin { diff --git a/firmware/controllers/trigger/main_trigger_callback.cpp b/firmware/controllers/trigger/main_trigger_callback.cpp index b08a4eff4f..a8ee1fb37d 100644 --- a/firmware/controllers/trigger/main_trigger_callback.cpp +++ b/firmware/controllers/trigger/main_trigger_callback.cpp @@ -408,12 +408,14 @@ static ALWAYS_INLINE void handleFuel(const bool limitedFuel, uint32_t trgEventIn } } -static histogram_s mainLoopHisto; +#if EFI_HISTOGRAMS || defined(__DOXYGEN__) +static histogram_s mainLoopHistogram; +#endif /* EFI_HISTOGRAMS */ void showMainHistogram(void) { -#if EFI_PROD_CODE || defined(__DOXYGEN__) - printHistogram(logger, &mainLoopHisto); -#endif +#if EFI_HISTOGRAMS || defined(__DOXYGEN__) + printHistogram(logger, &mainLoopHistogram); +#endif /* EFI_HISTOGRAMS */ } #if EFI_PROD_CODE || defined(__DOXYGEN__) @@ -512,10 +514,10 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t trgEventIndex D * For spark we schedule both start of coil charge and actual spark based on trigger angle */ handleSpark(limitedSpark, trgEventIndex, rpm PASS_ENGINE_PARAMETER); -#if (EFI_HISTOGRAMS && EFI_PROD_CODE) || defined(__DOXYGEN__) +#if EFI_HISTOGRAMS || defined(__DOXYGEN__) int diff = hal_lld_get_counter_value() - beforeCallback; if (diff > 0) - hsAdd(&mainLoopHisto, diff); + hsAdd(&mainLoopHistogram, diff); #endif /* EFI_HISTOGRAMS */ if (trgEventIndex == 0) { @@ -559,7 +561,7 @@ void initMainEventListener(Logging *sharedLogger, Engine *engine) { #endif #if EFI_HISTOGRAMS || defined(__DOXYGEN__) - initHistogram(&mainLoopHisto, "main callback"); + initHistogram(&mainLoopHistogram, "main callback"); #endif /* EFI_HISTOGRAMS */ addTriggerEventListener(mainTriggerCallback, "main loop", engine); diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index cf2fa3a764..79d5b8e696 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -36,7 +36,9 @@ WaveChart waveChart; EXTERN_ENGINE; -static histogram_s triggerCallback; +#if EFI_HISTOGRAMS || defined(__DOXYGEN__) +static histogram_s triggerCallbackHistogram; +#endif /* EFI_HISTOGRAMS */ static Logging *logger; @@ -286,19 +288,19 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal DECLARE_ENGINE_PAR } } -#if EFI_HISTOGRAMS && EFI_PROD_CODE +#if EFI_HISTOGRAMS || defined(__DOXYGEN__) int afterCallback = hal_lld_get_counter_value(); int diff = afterCallback - beforeCallback; // this counter is only 32 bits so it overflows every minute, let's ignore the value in case of the overflow for simplicity if (diff > 0) { - hsAdd(&triggerCallback, diff); + hsAdd(&triggerCallbackHistogram, diff); } #endif /* EFI_HISTOGRAMS */ } void printAllCallbacksHistogram(void) { -#if EFI_PROD_CODE - printHistogram(logger, &triggerCallback); +#if EFI_HISTOGRAMS || defined(__DOXYGEN__) + printHistogram(logger, &triggerCallbackHistogram); #endif } @@ -501,7 +503,7 @@ float getTriggerDutyCycle(int index) { #endif static void resetRunningTriggerCounters() { -#if !EFI_UNIT_TEST +#if !EFI_UNIT_TEST || defined(__DOXYGEN__) engine->triggerCentral.resetCounters(); triggerInfo(); #endif @@ -511,18 +513,18 @@ void initTriggerCentral(Logging *sharedLogger, Engine *engine) { logger = sharedLogger; strcpy((char*) shaft_signal_msg_index, "x_"); -#if EFI_ENGINE_SNIFFER +#if EFI_ENGINE_SNIFFER || defined(__DOXYGEN__) initWaveChart(&waveChart); #endif /* EFI_ENGINE_SNIFFER */ -#if EFI_PROD_CODE || EFI_SIMULATOR +#if EFI_PROD_CODE || EFI_SIMULATOR || defined(__DOXYGEN__) addConsoleAction("triggerinfo", triggerInfo); addConsoleAction("trigger_shape_info", triggerShapeInfo); addConsoleAction("reset_trigger", resetRunningTriggerCounters); #endif -#if EFI_HISTOGRAMS - initHistogram(&triggerCallback, "all callbacks"); +#if EFI_HISTOGRAMS || defined(__DOXYGEN__) + initHistogram(&triggerCallbackHistogram, "all callbacks"); #endif /* EFI_HISTOGRAMS */ } diff --git a/firmware/controllers/trigger/trigger_emulator_algo.cpp b/firmware/controllers/trigger/trigger_emulator_algo.cpp index a291524432..b1cba56a22 100644 --- a/firmware/controllers/trigger/trigger_emulator_algo.cpp +++ b/firmware/controllers/trigger/trigger_emulator_algo.cpp @@ -84,9 +84,9 @@ static single_wave_s waves[PWM_PHASE_MAX_WAVE_PER_PWM] = { single_wave_s(pinStat single_wave_s(pinStates3) }; static single_wave_s sr[PWM_PHASE_MAX_WAVE_PER_PWM] = { waves[0], waves[1], waves[2] }; -static float swtchTms[PWM_PHASE_MAX_COUNT]; +static float switchTimesBuffer[PWM_PHASE_MAX_COUNT]; -PwmConfig triggerSignal(swtchTms, sr); +PwmConfig triggerSignal(switchTimesBuffer, sr); #define DO_NOT_STOP 999999999 diff --git a/firmware/rusefi.cpp b/firmware/rusefi.cpp index 862415b2be..f672ec2f1d 100644 --- a/firmware/rusefi.cpp +++ b/firmware/rusefi.cpp @@ -240,14 +240,14 @@ void chDbgStackOverflowPanic(Thread *otp) { chDbgPanic3(panicMessage, __FILE__, __LINE__); } -static char UNUSED_RAM_SIZE[11100]; +static char UNUSED_RAM_SIZE[25100]; -static char UNUSED_CCM_SIZE[16500] CCM_OPTIONAL; +static char UNUSED_CCM_SIZE[9500] CCM_OPTIONAL; int getRusEfiVersion(void) { if (UNUSED_RAM_SIZE[0] != 0) return 123; // this is here to make the compiler happy about the unused array if (UNUSED_CCM_SIZE[0] * 0 != 0) return 3211; // this is here to make the compiler happy about the unused array - return 20170102; + return 20170105; } diff --git a/firmware/util/cli_registry.cpp b/firmware/util/cli_registry.cpp index bc5ebe7974..5df8a8c0f1 100644 --- a/firmware/util/cli_registry.cpp +++ b/firmware/util/cli_registry.cpp @@ -35,7 +35,7 @@ static Logging * logging; static int consoleActionCount = 0; -static TokenCallback consoleActions[CONSOLE_MAX_ACTIONS]; +static TokenCallback consoleActions[CONSOLE_MAX_ACTIONS] CCM_OPTIONAL; #define SECURE_LINE_PREFIX "sec!" #define SECURE_LINE_PREFIX_LENGTH 4 @@ -152,7 +152,7 @@ static int getParameterCount(action_type_e parameterType) { * @brief This function prints out a list of all available commands */ void helpCommand(void) { -#if EFI_PROD_CODE +#if EFI_PROD_CODE || defined(__DOXYGEN__) if (isBoardTestMode()) { printBoardTestState(); return; diff --git a/firmware/util/histogram.c b/firmware/util/histogram.c index c036e7519d..06c3a696e8 100644 --- a/firmware/util/histogram.c +++ b/firmware/util/histogram.c @@ -13,7 +13,7 @@ #include "histogram.h" #include "main.h" -#if EFI_HISTOGRAMS +#if EFI_HISTOGRAMS || EFI_UNIT_TEST #define H_ACCURACY 0.05 #define H_CONFIDENCE 0.8 diff --git a/unit_tests/efifeatures.h b/unit_tests/efifeatures.h index d0e0c5fa13..d78f68c30a 100644 --- a/unit_tests/efifeatures.h +++ b/unit_tests/efifeatures.h @@ -18,7 +18,7 @@ #define EFI_FSIO TRUE -#define EFI_HISTOGRAMS TRUE +#define EFI_HISTOGRAMS FALSE #define CONSOLE_MAX_ACTIONS 128 diff --git a/win32_functional_tests/simulator/efifeatures.h b/win32_functional_tests/simulator/efifeatures.h index 10f85f17d2..c2ab0950e0 100644 --- a/win32_functional_tests/simulator/efifeatures.h +++ b/win32_functional_tests/simulator/efifeatures.h @@ -48,7 +48,7 @@ #define EFI_ANALOG_SENSORS TRUE #define EFI_SENSOR_CHART TRUE -#define EFI_HISTOGRAMS TRUE +#define EFI_HISTOGRAMS FALSE #define EFI_TUNER_STUDIO TRUE