From 9de0c10f24f9f587f0179a4230439f8a1fd08144 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Sun, 13 Mar 2022 01:30:35 -0500 Subject: [PATCH] hellen bugfix: all four LEDs should light up on start-up --- firmware/config/boards/hellen/hellen_common.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/firmware/config/boards/hellen/hellen_common.cpp b/firmware/config/boards/hellen/hellen_common.cpp index d37b014cc8..d00dba92b1 100644 --- a/firmware/config/boards/hellen/hellen_common.cpp +++ b/firmware/config/boards/hellen/hellen_common.cpp @@ -46,19 +46,23 @@ void detectHellenMcuType() { // check each mcu module type sequentially for (int mcuType = 0; mcuType < 2; mcuType++) { brain_pin_e ledPin = led1Pins[mcuType]; + ioportid_t port = getBrainPinPort(ledPin); + int hwIndex = getBrainPinIndex(ledPin); // set LED1 pin to output & clear the state (discharge parasitic capacitance) - palSetPadMode(getBrainPinPort(ledPin), getBrainPinIndex(ledPin), PAL_MODE_OUTPUT_PUSHPULL); - palClearPad(getBrainPinPort(ledPin), getBrainPinIndex(ledPin)); + palSetPadMode(port, hwIndex, PAL_MODE_OUTPUT_PUSHPULL); + palClearPad(port, hwIndex); // set LED1 pin to input - palSetPadMode(getBrainPinPort(ledPin), getBrainPinIndex(ledPin), PAL_MODE_INPUT); // todo: currently we don't use PAL_MODE_INPUT_PULLDOWN - needs more testing + palSetPadMode(port, hwIndex, PAL_MODE_INPUT); // todo: currently we don't use PAL_MODE_INPUT_PULLDOWN - needs more testing // wait for the pin state to settle down chThdSleepMilliseconds(1); // get the pin states padState[mcuType] = 1; for (int i = 0; i < 4; i++) { // we get "1" only if all readings are "1" - padState[mcuType] &= palReadPad(getBrainPinPort(ledPin), getBrainPinIndex(ledPin)); + padState[mcuType] &= palReadPad(port, hwIndex); } + // back to output mode + palSetPadMode(port, hwIndex, PAL_MODE_OUTPUT_PUSHPULL); } efiPrintf("Hellen board pin states = %d %d", padState[0], padState[1]); if (padState[0] && !padState[1]) {