refactoring - reducing GPIO complexity
This commit is contained in:
parent
ac16341b2b
commit
6938538fac
|
@ -549,15 +549,14 @@ static OutputPin *leds[] = { &enginePins.warningPin, &enginePins.runningPin, &en
|
|||
extern pin_output_mode_e DEFAULT_OUTPUT;
|
||||
|
||||
static void initStatusLeds(void) {
|
||||
outputPinRegisterExt2("led: comm status", &enginePins.communicationPin,
|
||||
engineConfiguration->communicationPin, &DEFAULT_OUTPUT);
|
||||
enginePins.communicationPin.initPin("led: comm status", 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);
|
||||
enginePins.checkEnginePin.initPin("MalfunctionIndicator", boardConfiguration->malfunctionIndicatorPin, &DEFAULT_OUTPUT);
|
||||
|
||||
|
||||
#if EFI_WARNING_LED || defined(__DOXYGEN__)
|
||||
outputPinRegisterExt2("led: warning status", &enginePins.warningPin, LED_WARNING_BRAIN_PIN, &DEFAULT_OUTPUT);
|
||||
outputPinRegisterExt2("led: running status", &enginePins.runningPin, engineConfiguration->runningPin,
|
||||
&DEFAULT_OUTPUT);
|
||||
enginePins.warningPin.initPin("led: warning status", LED_WARNING_BRAIN_PIN, &DEFAULT_OUTPUT);
|
||||
enginePins.runningPin.initPin("led: running status", engineConfiguration->runningPin, &DEFAULT_OUTPUT);
|
||||
#endif /* EFI_WARNING_LED */
|
||||
}
|
||||
|
||||
|
|
|
@ -229,6 +229,10 @@ void initOutputPins(void) {
|
|||
#endif /* EFI_GPIO_HARDWARE */
|
||||
}
|
||||
|
||||
void OutputPin::initPin(const char *msg, brain_pin_e brainPin, pin_output_mode_e *outputMode) {
|
||||
outputPinRegisterExt2(msg, this, brainPin, outputMode);
|
||||
}
|
||||
|
||||
void outputPinRegisterExt2(const char *msg, OutputPin *outputPin, brain_pin_e brainPin, pin_output_mode_e *outputMode) {
|
||||
#if EFI_GPIO_HARDWARE || defined(__DOXYGEN__)
|
||||
if (brainPin == GPIO_UNASSIGNED)
|
||||
|
|
|
@ -33,6 +33,8 @@ public:
|
|||
bool getLogicValue();
|
||||
void unregister();
|
||||
bool isPinAssigned();
|
||||
void initPin(const char *msg, brain_pin_e brainPin, pin_output_mode_e *outputMode);
|
||||
|
||||
#if EFI_GPIO_HARDWARE || defined(__DOXYGEN__)
|
||||
ioportid_t port;
|
||||
uint8_t pin;
|
||||
|
@ -123,14 +125,12 @@ public:
|
|||
|
||||
#define getElectricalValue0(mode) ((mode) == OM_INVERTED || (mode) == OM_OPENDRAIN_INVERTED)
|
||||
|
||||
|
||||
/**
|
||||
* it's a macro to be sure that stack is not used
|
||||
* @return 1 for OM_DEFAULT and OM_OPENDRAIN
|
||||
*/
|
||||
#define getElectricalValue1(mode) ((mode) == OM_DEFAULT || (mode) == OM_OPENDRAIN)
|
||||
|
||||
|
||||
#define getElectricalValue(logicalValue, mode) \
|
||||
(logicalValue ? getElectricalValue1(mode) : getElectricalValue0(mode))
|
||||
|
||||
|
|
Loading…
Reference in New Issue