auto-sync

This commit is contained in:
rusEfi 2014-10-29 10:03:57 -05:00
parent 0e08397497
commit d5309495b1
6 changed files with 64 additions and 70 deletions

View File

@ -333,6 +333,60 @@ static void showFuelInfo(Engine *engine) {
static THD_WORKING_AREA(lcdThreadStack, UTILITY_THREAD_STACK_SIZE); 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) { static void lcdThread(Engine *engine) {
chRegSetThreadName("lcd"); chRegSetThreadName("lcd");
while (true) { while (true) {
@ -438,6 +492,10 @@ void startStatusThreads(Engine *engine) {
// todo: refactoring needed, this file should probably be split into pieces // todo: refactoring needed, this file should probably be split into pieces
chThdCreateStatic(lcdThreadStack, sizeof(lcdThreadStack), NORMALPRIO, (tfunc_t) lcdThread, engine); chThdCreateStatic(lcdThreadStack, sizeof(lcdThreadStack), NORMALPRIO, (tfunc_t) lcdThread, engine);
chThdCreateStatic(tsThreadStack, sizeof(tsThreadStack), NORMALPRIO, (tfunc_t) tsStatusThread, 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) { void setFullLog(int value) {

View File

@ -35,17 +35,15 @@ void initMainEventListener(Engine *engine, engine_configuration2_s *engineConfig
void onTriggerEvent(trigger_event_e ckpSignalType, uint32_t eventIndex, MainTriggerCallback *mainTriggerCallback); void onTriggerEvent(trigger_event_e ckpSignalType, uint32_t eventIndex, MainTriggerCallback *mainTriggerCallback);
#endif #endif
int isIgnitionTimingError(void);
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#endif /* __cplusplus */ #endif /* __cplusplus */
void showMainHistogram(void); void showMainHistogram(void);
void onEveryMillisecondTimerSignal(void); void onEveryMillisecondTimerSignal(void);
int isIgnitionTimingError(void);
float getFuel(int rpm, float key); float getFuel(int rpm, float key);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -32,7 +32,7 @@
#include "pwm_generator.h" #include "pwm_generator.h"
#include "pwm_generator_logic.h" #include "pwm_generator_logic.h"
#if EFI_ELECTRONIC_THROTTLE_BODY #if EFI_ELECTRONIC_THROTTLE_BODY || defined(__DOXYGEN__)
static Logging logger; static Logging logger;
/** /**

View File

@ -57,7 +57,7 @@ void addTriggerEventListener(ShaftPositionListener listener, const char *name, v
triggerCentral.addEventListener(listener, name, arg); triggerCentral.addEventListener(listener, name, arg);
} }
#if EFI_PROD_CODE || EFI_SIMULATOR #if (EFI_PROD_CODE || EFI_SIMULATOR) || defined(__DOXYGEN__)
extern configuration_s *configuration; extern configuration_s *configuration;
void hwHandleShaftSignal(trigger_event_e signal) { void hwHandleShaftSignal(trigger_event_e signal) {
@ -189,7 +189,7 @@ static void triggerShapeInfo(Engine *engine) {
} }
static void triggerInfo(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), scheduleMsg(&logger, "Template %s/%d trigger %d", getConfigurationName(engineConfiguration->engineType),
engineConfiguration->engineType, engineConfiguration->triggerConfig.triggerType); engineConfiguration->engineType, engineConfiguration->triggerConfig.triggerType);
@ -204,6 +204,8 @@ static void triggerInfo(Engine *engine) {
boolToString(engineConfiguration->needSecondTriggerInput)); boolToString(engineConfiguration->needSecondTriggerInput));
scheduleMsg(&logger, "expected duty #0=%f/#1=%f", engineConfiguration2->triggerShape.dutyCycle[0], scheduleMsg(&logger, "expected duty #0=%f/#1=%f", engineConfiguration2->triggerShape.dutyCycle[0],
engineConfiguration2->triggerShape.dutyCycle[1]); engineConfiguration2->triggerShape.dutyCycle[1]);
scheduleMsg(&logger, "isError %d", isTriggerDecoderError());
#endif #endif
#if EFI_PROD_CODE #if EFI_PROD_CODE

View File

@ -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 initializeTriggerShape(Logging *logger, engine_configuration_s const *engineConfiguration, engine_configuration2_s *engineConfiguration2);
void initTriggerDecoder(void); void initTriggerDecoder(void);
#ifdef __cplusplus
extern "C"
{
#endif
int isTriggerDecoderError(void); int isTriggerDecoderError(void);
#ifdef __cplusplus
}
#endif
#endif /* TRIGGER_DECODER_H_ */ #endif /* TRIGGER_DECODER_H_ */

View File

@ -34,16 +34,6 @@ static GPIO_TypeDef *PORTS[] = { GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG
static pin_output_mode_e DEFAULT_OUTPUT = OM_DEFAULT; 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) { void turnOutputPinOn(io_pin_e pin) {
setOutputPinValue(pin, TRUE); setOutputPinValue(pin, TRUE);
} }
@ -64,48 +54,6 @@ void setDefaultPinState(io_pin_e pin, pin_output_mode_e *outputMode) {
setOutputPinValue(pin, FALSE); // initial state 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, static void outputPinRegisterExt(const char *msg, io_pin_e ioPin, GPIO_TypeDef *port, uint32_t pin,
pin_output_mode_e *outputMode) { pin_output_mode_e *outputMode) {
@ -253,8 +201,5 @@ void initOutputPins(void) {
ledRegister(LED_HUGE_20, GPIOE, 1); 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); addConsoleActionS("get_pin_value", getPinValue);
} }