refactoring
This commit is contained in:
parent
27cfa521f0
commit
62f37f04ae
|
@ -545,28 +545,23 @@ static THD_WORKING_AREA(lcdThreadStack, UTILITY_THREAD_STACK_SIZE);
|
||||||
*/
|
*/
|
||||||
static THD_WORKING_AREA(blinkingStack, 128);
|
static THD_WORKING_AREA(blinkingStack, 128);
|
||||||
|
|
||||||
// move this into EnginePins?
|
static OutputPin *leds[] = { &enginePins.warningPin, &enginePins.runningPin, &enginePins.checkEnginePin,
|
||||||
OutputPin communicationPin; // blue LED on brain board by default
|
&enginePins.errorLedPin, &enginePins.communicationPin, &enginePins.checkEnginePin };
|
||||||
OutputPin warningPin; // orange LED on brain board by default
|
|
||||||
OutputPin runningPin; // green LED on brain board by default
|
|
||||||
|
|
||||||
static OutputPin *leds[] = { &warningPin, &runningPin, &enginePins.checkEnginePin,
|
|
||||||
&enginePins.errorLedPin, &communicationPin, &enginePins.checkEnginePin };
|
|
||||||
|
|
||||||
extern pin_output_mode_e DEFAULT_OUTPUT;
|
extern pin_output_mode_e DEFAULT_OUTPUT;
|
||||||
|
|
||||||
static void initStatusLeds(void) {
|
static void initStatusLeds(void) {
|
||||||
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
||||||
outputPinRegisterExt2("led: comm status", &communicationPin,
|
outputPinRegisterExt2("led: comm status", &enginePins.communicationPin,
|
||||||
engineConfiguration->communicationPin, &DEFAULT_OUTPUT);
|
engineConfiguration->communicationPin, &DEFAULT_OUTPUT);
|
||||||
// we initialize this here so that we can blink it on start-up
|
// we initialize this here so that we can blink it on start-up
|
||||||
outputPinRegisterExt2("MalfunctionIndicator", &enginePins.checkEnginePin, boardConfiguration->malfunctionIndicatorPin, &DEFAULT_OUTPUT);
|
outputPinRegisterExt2("MalfunctionIndicator", &enginePins.checkEnginePin, boardConfiguration->malfunctionIndicatorPin, &DEFAULT_OUTPUT);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if EFI_WARNING_LED || defined(__DOXYGEN__)
|
#if EFI_WARNING_LED || defined(__DOXYGEN__)
|
||||||
outputPinRegister("led: warning status", &warningPin, LED_WARNING_PORT,
|
outputPinRegister("led: warning status", &enginePins.warningPin, LED_WARNING_PORT,
|
||||||
LED_WARNING_PIN);
|
LED_WARNING_PIN);
|
||||||
outputPinRegisterExt2("led: running status", &runningPin, engineConfiguration->runningPin,
|
outputPinRegisterExt2("led: running status", &enginePins.runningPin, engineConfiguration->runningPin,
|
||||||
&DEFAULT_OUTPUT);
|
&DEFAULT_OUTPUT);
|
||||||
#endif /* EFI_WARNING_LED */
|
#endif /* EFI_WARNING_LED */
|
||||||
}
|
}
|
||||||
|
@ -631,16 +626,16 @@ static void blinkingThread(void *arg) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!hasFirmwareError() && !hasFirmwareErrorFlag) {
|
if (!hasFirmwareError() && !hasFirmwareErrorFlag) {
|
||||||
communicationPin.setValue(0);
|
enginePins.communicationPin.setValue(0);
|
||||||
}
|
}
|
||||||
warningPin.setValue(0);
|
enginePins.warningPin.setValue(0);
|
||||||
chThdSleepMilliseconds(delayMs);
|
chThdSleepMilliseconds(delayMs);
|
||||||
|
|
||||||
communicationPin.setValue(1);
|
enginePins.communicationPin.setValue(1);
|
||||||
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
|
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
|
||||||
if (isTriggerErrorNow() || isIgnitionTimingError() || consoleByteArrived) {
|
if (isTriggerErrorNow() || isIgnitionTimingError() || consoleByteArrived) {
|
||||||
consoleByteArrived = false;
|
consoleByteArrived = false;
|
||||||
warningPin.setValue(1);
|
enginePins.warningPin.setValue(1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
chThdSleepMilliseconds(delayMs);
|
chThdSleepMilliseconds(delayMs);
|
||||||
|
|
|
@ -68,6 +68,7 @@
|
||||||
#endif /* EFI_PROD_CODE */
|
#endif /* EFI_PROD_CODE */
|
||||||
|
|
||||||
extern bool hasFirmwareErrorFlag;
|
extern bool hasFirmwareErrorFlag;
|
||||||
|
extern EnginePins enginePins;
|
||||||
|
|
||||||
persistent_config_container_s persistentState CCM_OPTIONAL;
|
persistent_config_container_s persistentState CCM_OPTIONAL;
|
||||||
|
|
||||||
|
@ -118,13 +119,13 @@ static msg_t csThread(void) {
|
||||||
int is_running = rpm > 0 && !is_cranking;
|
int is_running = rpm > 0 && !is_cranking;
|
||||||
if (is_running) {
|
if (is_running) {
|
||||||
// blinking while running
|
// blinking while running
|
||||||
runningPin.setValue(0);
|
enginePins.runningPin.setValue(0);
|
||||||
chThdSleepMilliseconds(50);
|
chThdSleepMilliseconds(50);
|
||||||
runningPin.setValue(1);
|
enginePins.runningPin.setValue(1);
|
||||||
chThdSleepMilliseconds(50);
|
chThdSleepMilliseconds(50);
|
||||||
} else {
|
} else {
|
||||||
// constant on while cranking and off if engine is stopped
|
// constant on while cranking and off if engine is stopped
|
||||||
runningPin.setValue(is_cranking);
|
enginePins.runningPin.setValue(is_cranking);
|
||||||
chThdSleepMilliseconds(100);
|
chThdSleepMilliseconds(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,11 @@ public:
|
||||||
/**
|
/**
|
||||||
* brain board RED LED by default
|
* brain board RED LED by default
|
||||||
*/
|
*/
|
||||||
OutputPin errorLedPin; //
|
OutputPin errorLedPin;
|
||||||
|
OutputPin communicationPin; // blue LED on brain board by default
|
||||||
|
OutputPin warningPin; // orange LED on brain board by default
|
||||||
|
OutputPin runningPin; // green LED on brain board by default
|
||||||
|
|
||||||
OutputPin idleSolenoidPin;
|
OutputPin idleSolenoidPin;
|
||||||
OutputPin alternatorPin;
|
OutputPin alternatorPin;
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -119,7 +119,7 @@ typedef VirtualTimer virtual_timer_t;
|
||||||
#define ON_FATAL_ERROR() \
|
#define ON_FATAL_ERROR() \
|
||||||
palWritePad(LED_ERROR_PORT, LED_ERROR_PIN, 1); \
|
palWritePad(LED_ERROR_PORT, LED_ERROR_PIN, 1); \
|
||||||
turnAllPinsOff(); \
|
turnAllPinsOff(); \
|
||||||
communicationPin.setValue(1);
|
enginePins.communicationPin.setValue(1);
|
||||||
|
|
||||||
|
|
||||||
#endif /* GLOBAL_H_ */
|
#endif /* GLOBAL_H_ */
|
||||||
|
|
Loading…
Reference in New Issue