(insert passive-aggressive smart prefix here) HARDWARE VALIDATION has disappeared fix #4405

This commit is contained in:
rusefillc 2022-07-30 15:03:45 -04:00
parent 94738f4a16
commit 6f767f603a
1 changed files with 18 additions and 0 deletions

View File

@ -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 */
}