io_pins: efiReadPin() variant with pin_input_mode_e argument

Will invert state in case of inverted mode.
This commit is contained in:
Andrey Gusakov 2025-02-11 14:31:22 +03:00 committed by rusefillc
parent 9209bc64cb
commit 48144a49b4
2 changed files with 14 additions and 0 deletions

View File

@ -134,3 +134,15 @@ void setMockState(brain_pin_e pin, bool state) {
}
#endif /* EFI_PROD_CODE */
bool efiIsInputPinInverted(pin_input_mode_e mode)
{
return ((mode == PI_INVERTED_DEFAULT) ||
(mode == PI_INVERTED_PULLUP) ||
(mode == PI_INVERTED_PULLDOWN));
}
bool efiReadPin(brain_pin_e pin, pin_input_mode_e mode)
{
return efiReadPin(pin) ^ efiIsInputPinInverted(mode);
}

View File

@ -33,6 +33,8 @@ void efiSetPadUnused(brain_pin_e brainPin);
#if EFI_GPIO_HARDWARE
bool efiReadPin(brain_pin_e pin);
bool efiReadPin(brain_pin_e pin, pin_input_mode_e mode);
bool efiIsInputPinInverted(pin_input_mode_e mode);
iomode_t getInputMode(pin_input_mode_e mode);