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);
|
||||
|
||||
// move this into EnginePins?
|
||||
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
|
||||
|
||||
static OutputPin *leds[] = { &warningPin, &runningPin, &enginePins.checkEnginePin,
|
||||
&enginePins.errorLedPin, &communicationPin, &enginePins.checkEnginePin };
|
||||
static OutputPin *leds[] = { &enginePins.warningPin, &enginePins.runningPin, &enginePins.checkEnginePin,
|
||||
&enginePins.errorLedPin, &enginePins.communicationPin, &enginePins.checkEnginePin };
|
||||
|
||||
extern pin_output_mode_e DEFAULT_OUTPUT;
|
||||
|
||||
static void initStatusLeds(void) {
|
||||
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
||||
outputPinRegisterExt2("led: comm status", &communicationPin,
|
||||
outputPinRegisterExt2("led: comm status", &enginePins.communicationPin,
|
||||
engineConfiguration->communicationPin, &DEFAULT_OUTPUT);
|
||||
// we initialize this here so that we can blink it on start-up
|
||||
outputPinRegisterExt2("MalfunctionIndicator", &enginePins.checkEnginePin, boardConfiguration->malfunctionIndicatorPin, &DEFAULT_OUTPUT);
|
||||
#endif
|
||||
|
||||
#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);
|
||||
outputPinRegisterExt2("led: running status", &runningPin, engineConfiguration->runningPin,
|
||||
outputPinRegisterExt2("led: running status", &enginePins.runningPin, engineConfiguration->runningPin,
|
||||
&DEFAULT_OUTPUT);
|
||||
#endif /* EFI_WARNING_LED */
|
||||
}
|
||||
|
@ -631,16 +626,16 @@ static void blinkingThread(void *arg) {
|
|||
#endif
|
||||
|
||||
if (!hasFirmwareError() && !hasFirmwareErrorFlag) {
|
||||
communicationPin.setValue(0);
|
||||
enginePins.communicationPin.setValue(0);
|
||||
}
|
||||
warningPin.setValue(0);
|
||||
enginePins.warningPin.setValue(0);
|
||||
chThdSleepMilliseconds(delayMs);
|
||||
|
||||
communicationPin.setValue(1);
|
||||
enginePins.communicationPin.setValue(1);
|
||||
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
|
||||
if (isTriggerErrorNow() || isIgnitionTimingError() || consoleByteArrived) {
|
||||
consoleByteArrived = false;
|
||||
warningPin.setValue(1);
|
||||
enginePins.warningPin.setValue(1);
|
||||
}
|
||||
#endif
|
||||
chThdSleepMilliseconds(delayMs);
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
#endif /* EFI_PROD_CODE */
|
||||
|
||||
extern bool hasFirmwareErrorFlag;
|
||||
extern EnginePins enginePins;
|
||||
|
||||
persistent_config_container_s persistentState CCM_OPTIONAL;
|
||||
|
||||
|
@ -118,13 +119,13 @@ static msg_t csThread(void) {
|
|||
int is_running = rpm > 0 && !is_cranking;
|
||||
if (is_running) {
|
||||
// blinking while running
|
||||
runningPin.setValue(0);
|
||||
enginePins.runningPin.setValue(0);
|
||||
chThdSleepMilliseconds(50);
|
||||
runningPin.setValue(1);
|
||||
enginePins.runningPin.setValue(1);
|
||||
chThdSleepMilliseconds(50);
|
||||
} else {
|
||||
// constant on while cranking and off if engine is stopped
|
||||
runningPin.setValue(is_cranking);
|
||||
enginePins.runningPin.setValue(is_cranking);
|
||||
chThdSleepMilliseconds(100);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,7 +86,11 @@ public:
|
|||
/**
|
||||
* 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 alternatorPin;
|
||||
/**
|
||||
|
|
|
@ -119,7 +119,7 @@ typedef VirtualTimer virtual_timer_t;
|
|||
#define ON_FATAL_ERROR() \
|
||||
palWritePad(LED_ERROR_PORT, LED_ERROR_PIN, 1); \
|
||||
turnAllPinsOff(); \
|
||||
communicationPin.setValue(1);
|
||||
enginePins.communicationPin.setValue(1);
|
||||
|
||||
|
||||
#endif /* GLOBAL_H_ */
|
||||
|
|
Loading…
Reference in New Issue