From 97fd9823744aa8e939f306035e6875212794ea15 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Wed, 3 Jul 2019 00:18:04 -0700 Subject: [PATCH] fix (#865) --- firmware/controllers/system/efi_gpio.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/firmware/controllers/system/efi_gpio.cpp b/firmware/controllers/system/efi_gpio.cpp index 90b1afda89..40a32e6c2b 100644 --- a/firmware/controllers/system/efi_gpio.cpp +++ b/firmware/controllers/system/efi_gpio.cpp @@ -468,9 +468,12 @@ void OutputPin::initPin(const char *msg, brain_pin_e brainPin, const pin_output_ this->currentLogicValue = INITIAL_PIN_STATE; - efiSetPadMode(msg, brainPin, mode); - + // The order of the next two calls may look strange, which is a good observation. + // We call them in this order so that the pin is set to a known state BEFORE + // it's enabled. Enabling the pin then setting it could result in a (brief) + // mystery state being driven on the pin (potentially dangerous). setDefaultPinState(outputMode); + efiSetPadMode(msg, brainPin, mode); #endif /* EFI_GPIO_HARDWARE */ }