From 6f767f603af0cdcf967f5a41a1a3b4f662341b1c Mon Sep 17 00:00:00 2001 From: rusefillc Date: Sat, 30 Jul 2022 15:03:45 -0400 Subject: [PATCH] (insert passive-aggressive smart prefix here) HARDWARE VALIDATION has disappeared fix #4405 --- firmware/controllers/system/efi_gpio.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/firmware/controllers/system/efi_gpio.cpp b/firmware/controllers/system/efi_gpio.cpp index 79cb2b690e..23ce194668 100644 --- a/firmware/controllers/system/efi_gpio.cpp +++ b/firmware/controllers/system/efi_gpio.cpp @@ -567,6 +567,24 @@ void OutputPin::initPin(const char *msg, brain_pin_e brainPin, const pin_output_ #if EFI_GPIO_HARDWARE && EFI_PROD_CODE efiSetPadMode(msg, brainPin, mode); + if (brain_pin_is_onchip(brainPin)) { + int actualValue = palReadPad(port, pin); + // we had enough drama with pin configuration in board.h and else that we shall self-check + + // todo: handle OM_OPENDRAIN and OM_OPENDRAIN_INVERTED as well + if (*outputMode == OM_DEFAULT || *outputMode == OM_INVERTED) { + const int logicalValue = + (*outputMode == OM_INVERTED) + ? !actualValue + : actualValue; + + // if the pin was set to logical 1, then set an error and disable the pin so that things don't catch fire + if (logicalValue) { + firmwareError(OBD_PCM_Processor_Fault, "HARDWARE VALIDATION FAILED %s: unexpected startup pin state %s actual value=%d logical value=%d mode=%s", msg, hwPortname(brainPin), actualValue, logicalValue, getPin_output_mode_e(*outputMode)); + OutputPin::deInit(); + } + } + } #endif /* EFI_GPIO_HARDWARE */ }