From dbeb5351cd84368ed19919172ac4a4485a96b3f2 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Wed, 29 Oct 2014 10:03:57 -0500 Subject: [PATCH] auto-sync --- firmware/console/status_loop.cpp | 58 +++++++++++++++++++ .../controllers/algo/main_trigger_callback.h | 4 +- firmware/controllers/electronic_throttle.cpp | 2 +- .../controllers/trigger/trigger_central.cpp | 6 +- .../controllers/trigger/trigger_decoder.h | 9 --- firmware/hw_layer/io_pins.c | 55 ------------------ 6 files changed, 64 insertions(+), 70 deletions(-) diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index 6740a22b5c..3432e43cd0 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -333,6 +333,60 @@ static void showFuelInfo(Engine *engine) { static THD_WORKING_AREA(lcdThreadStack, UTILITY_THREAD_STACK_SIZE); +/** + * blinking thread to show that we are alive + */ +static THD_WORKING_AREA(comBlinkingStack, UTILITY_THREAD_STACK_SIZE); + +/** + * error thread to show error condition (blinking LED means non-fatal error) + */ +static THD_WORKING_AREA(errBlinkingStack, UTILITY_THREAD_STACK_SIZE); + +#if EFI_PROD_CODE || defined(__DOXYGEN__) +static void comBlinkingThread(void *arg) { + (void) arg; + chRegSetThreadName("communication blinking"); + while (TRUE) { + int delay; + + if (getNeedToWriteConfiguration()) { + delay = isConsoleReady() ? 200 : 66; + } else { + delay = isConsoleReady() ? 100 : 33; + } + + setOutputPinValue(LED_COMMUNICATION_1, 0); + setOutputPinValue(LED_EXT_1, 1); +// setOutputPinValue(LED_EXT_2, 1); +// setOutputPinValue(LED_EXT_3, 1); + chThdSleepMilliseconds(delay); + + setOutputPinValue(LED_COMMUNICATION_1, 1); + setOutputPinValue(LED_EXT_1, 0); +// setOutputPinValue(LED_EXT_2, 0); +// setOutputPinValue(LED_EXT_3, 0); + chThdSleepMilliseconds(delay); + } +} + +static void errBlinkingThread(void *arg) { + (void) arg; + chRegSetThreadName("err blinking"); +#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__) + while (TRUE) { + int delay = 33; + if (isTriggerDecoderError() || isIgnitionTimingError()) + setOutputPinValue(LED_WARNING, 1); + chThdSleepMilliseconds(delay); + setOutputPinValue(LED_WARNING, 0); + chThdSleepMilliseconds(delay); + } +#endif /* EFI_ENGINE_CONTROL */ +} +#endif /* EFI_PROD_CODE */ + + static void lcdThread(Engine *engine) { chRegSetThreadName("lcd"); while (true) { @@ -438,6 +492,10 @@ void startStatusThreads(Engine *engine) { // todo: refactoring needed, this file should probably be split into pieces chThdCreateStatic(lcdThreadStack, sizeof(lcdThreadStack), NORMALPRIO, (tfunc_t) lcdThread, engine); chThdCreateStatic(tsThreadStack, sizeof(tsThreadStack), NORMALPRIO, (tfunc_t) tsStatusThread, engine); +#if EFI_PROD_CODE || defined(__DOXYGEN__) + chThdCreateStatic(comBlinkingStack, sizeof(comBlinkingStack), NORMALPRIO, (tfunc_t) comBlinkingThread, NULL); + chThdCreateStatic(errBlinkingStack, sizeof(errBlinkingStack), NORMALPRIO, (tfunc_t) errBlinkingThread, NULL); +#endif /* EFI_PROD_CODE */ } void setFullLog(int value) { diff --git a/firmware/controllers/algo/main_trigger_callback.h b/firmware/controllers/algo/main_trigger_callback.h index 3e37f8d0c7..48515f357d 100644 --- a/firmware/controllers/algo/main_trigger_callback.h +++ b/firmware/controllers/algo/main_trigger_callback.h @@ -35,17 +35,15 @@ void initMainEventListener(Engine *engine, engine_configuration2_s *engineConfig void onTriggerEvent(trigger_event_e ckpSignalType, uint32_t eventIndex, MainTriggerCallback *mainTriggerCallback); #endif +int isIgnitionTimingError(void); #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ - - void showMainHistogram(void); void onEveryMillisecondTimerSignal(void); -int isIgnitionTimingError(void); float getFuel(int rpm, float key); #ifdef __cplusplus diff --git a/firmware/controllers/electronic_throttle.cpp b/firmware/controllers/electronic_throttle.cpp index f8024535bc..6f63ace347 100644 --- a/firmware/controllers/electronic_throttle.cpp +++ b/firmware/controllers/electronic_throttle.cpp @@ -32,7 +32,7 @@ #include "pwm_generator.h" #include "pwm_generator_logic.h" -#if EFI_ELECTRONIC_THROTTLE_BODY +#if EFI_ELECTRONIC_THROTTLE_BODY || defined(__DOXYGEN__) static Logging logger; /** diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index e053c923ac..f34523ebbf 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -57,7 +57,7 @@ void addTriggerEventListener(ShaftPositionListener listener, const char *name, v triggerCentral.addEventListener(listener, name, arg); } -#if EFI_PROD_CODE || EFI_SIMULATOR +#if (EFI_PROD_CODE || EFI_SIMULATOR) || defined(__DOXYGEN__) extern configuration_s *configuration; void hwHandleShaftSignal(trigger_event_e signal) { @@ -189,7 +189,7 @@ static void triggerShapeInfo(Engine *engine) { } static void triggerInfo(Engine *engine) { -#if EFI_PROD_CODE || EFI_SIMULATOR +#if (EFI_PROD_CODE || EFI_SIMULATOR) || defined(__DOXYGEN__) scheduleMsg(&logger, "Template %s/%d trigger %d", getConfigurationName(engineConfiguration->engineType), engineConfiguration->engineType, engineConfiguration->triggerConfig.triggerType); @@ -204,6 +204,8 @@ static void triggerInfo(Engine *engine) { boolToString(engineConfiguration->needSecondTriggerInput)); scheduleMsg(&logger, "expected duty #0=%f/#1=%f", engineConfiguration2->triggerShape.dutyCycle[0], engineConfiguration2->triggerShape.dutyCycle[1]); + + scheduleMsg(&logger, "isError %d", isTriggerDecoderError()); #endif #if EFI_PROD_CODE diff --git a/firmware/controllers/trigger/trigger_decoder.h b/firmware/controllers/trigger/trigger_decoder.h index 1cbfdb0043..d9cfe1ebf8 100644 --- a/firmware/controllers/trigger/trigger_decoder.h +++ b/firmware/controllers/trigger/trigger_decoder.h @@ -82,15 +82,6 @@ uint32_t findTriggerZeroEventIndex(trigger_shape_s * shape, trigger_config_s con void initializeTriggerShape(Logging *logger, engine_configuration_s const *engineConfiguration, engine_configuration2_s *engineConfiguration2); void initTriggerDecoder(void); -#ifdef __cplusplus -extern "C" -{ -#endif - int isTriggerDecoderError(void); -#ifdef __cplusplus -} -#endif - #endif /* TRIGGER_DECODER_H_ */ diff --git a/firmware/hw_layer/io_pins.c b/firmware/hw_layer/io_pins.c index 07663081fd..2ffbf6fb7b 100644 --- a/firmware/hw_layer/io_pins.c +++ b/firmware/hw_layer/io_pins.c @@ -34,16 +34,6 @@ static GPIO_TypeDef *PORTS[] = { GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG static pin_output_mode_e DEFAULT_OUTPUT = OM_DEFAULT; -/** - * blinking thread to show that we are alive - */ -static THD_WORKING_AREA(comBlinkingStack, UTILITY_THREAD_STACK_SIZE); - -/** - * error thread to show error condition (blinking LED means non-fatal error) - */ -static THD_WORKING_AREA(errBlinkingStack, UTILITY_THREAD_STACK_SIZE); - void turnOutputPinOn(io_pin_e pin) { setOutputPinValue(pin, TRUE); } @@ -64,48 +54,6 @@ void setDefaultPinState(io_pin_e pin, pin_output_mode_e *outputMode) { setOutputPinValue(pin, FALSE); // initial state } -static void comBlinkingThread(void *arg) { - (void) arg; - chRegSetThreadName("communication blinking"); - while (TRUE) { - int delay; - if (getNeedToWriteConfiguration()) { - delay = isConsoleReady() ? 200 : 66; - } else { - delay = isConsoleReady() ? 100 : 33; - } - - setOutputPinValue(LED_COMMUNICATION_1, 0); - setOutputPinValue(LED_EXT_1, 1); -// setOutputPinValue(LED_EXT_2, 1); -// setOutputPinValue(LED_EXT_3, 1); - chThdSleepMilliseconds(delay); - - setOutputPinValue(LED_COMMUNICATION_1, 1); - setOutputPinValue(LED_EXT_1, 0); -// setOutputPinValue(LED_EXT_2, 0); -// setOutputPinValue(LED_EXT_3, 0); - chThdSleepMilliseconds(delay); - } -} - -// todo: fix this, should be a proper declaration in a .h file -int isTriggerDecoderError(void); - -static void errBlinkingThread(void *arg) { - (void) arg; - chRegSetThreadName("err blinking"); -#if EFI_ENGINE_CONTROL - while (TRUE) { - int delay = 33; - if (isTriggerDecoderError() || isIgnitionTimingError()) - setOutputPinValue(LED_WARNING, 1); - chThdSleepMilliseconds(delay); - setOutputPinValue(LED_WARNING, 0); - chThdSleepMilliseconds(delay); - } -#endif /* EFI_ENGINE_CONTROL */ -} static void outputPinRegisterExt(const char *msg, io_pin_e ioPin, GPIO_TypeDef *port, uint32_t pin, pin_output_mode_e *outputMode) { @@ -253,8 +201,5 @@ void initOutputPins(void) { ledRegister(LED_HUGE_20, GPIOE, 1); */ - chThdCreateStatic(comBlinkingStack, sizeof(comBlinkingStack), NORMALPRIO, (tfunc_t) comBlinkingThread, NULL); - chThdCreateStatic(errBlinkingStack, sizeof(errBlinkingStack), NORMALPRIO, (tfunc_t) errBlinkingThread, NULL); - addConsoleActionS("get_pin_value", getPinValue); }