fix gpio the right way (#1990)
* fix the right way * use the api * explain Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
parent
0840b91f7f
commit
a3a49b02ed
|
@ -395,7 +395,7 @@ void OutputPin::toggle() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OutputPin::getAndSet(int logicValue) {
|
bool OutputPin::getAndSet(int logicValue) {
|
||||||
bool oldValue = currentLogicValue;
|
bool oldValue = getLogicValue();
|
||||||
setValue(logicValue);
|
setValue(logicValue);
|
||||||
return oldValue;
|
return oldValue;
|
||||||
}
|
}
|
||||||
|
@ -442,7 +442,8 @@ void OutputPin::setValue(int logicValue) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OutputPin::getLogicValue() const {
|
bool OutputPin::getLogicValue() const {
|
||||||
return currentLogicValue;
|
// Compare against 1 since it could also be INITIAL_PIN_STATE (which means 0, but we haven't initialized the pin yet)
|
||||||
|
return currentLogicValue == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputPin::setDefaultPinState(const pin_output_mode_e *outputMode) {
|
void OutputPin::setDefaultPinState(const pin_output_mode_e *outputMode) {
|
||||||
|
|
|
@ -74,7 +74,7 @@ public:
|
||||||
brain_pin_e brainPin;
|
brain_pin_e brainPin;
|
||||||
#endif /* EFI_GPIO_HARDWARE */
|
#endif /* EFI_GPIO_HARDWARE */
|
||||||
|
|
||||||
int8_t currentLogicValue = 0;
|
int8_t currentLogicValue = INITIAL_PIN_STATE;
|
||||||
/**
|
/**
|
||||||
* we track current pin status so that we do not touch the actual hardware if we want to write new pin bit
|
* we track current pin status so that we do not touch the actual hardware if we want to write new pin bit
|
||||||
* which is same as current pin value. This maybe helps in case of status leds, but maybe it's a total over-engineering
|
* which is same as current pin value. This maybe helps in case of status leds, but maybe it's a total over-engineering
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
|
#define INITIAL_PIN_STATE -1
|
||||||
#define GPIO_NULL NULL
|
#define GPIO_NULL NULL
|
||||||
|
|
||||||
// mode >= 0 is always true since that's an unsigned
|
// mode >= 0 is always true since that's an unsigned
|
||||||
|
|
Loading…
Reference in New Issue