From 8ddd47c4b8f424d1865b64fe1064bcc80a0a9a06 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Tue, 17 Oct 2023 21:35:36 -0400 Subject: [PATCH] document why do we care about detectHellenMcuType fix #5615 --- .../config/boards/hellen/hellen_common.cpp | 43 ------------------- 1 file changed, 43 deletions(-) diff --git a/firmware/config/boards/hellen/hellen_common.cpp b/firmware/config/boards/hellen/hellen_common.cpp index 4b0928675a..9d37d9c8a3 100644 --- a/firmware/config/boards/hellen/hellen_common.cpp +++ b/firmware/config/boards/hellen/hellen_common.cpp @@ -66,49 +66,6 @@ void configureHellenCanTerminator() { } } -// this should be called before setHellenXXXLedPins() -static void detectHellenMcuType() { - // we test the red LED1 pin because the red LED used has the smallest voltage drop, - // and thus can be detected more accurately - static const brain_pin_e led1Pins[2] = { - // LED1 pin of the 176-pin mcu module (we check it first!) - H176_LED1_RED, - // LED1 pin of the 144-pin mcu module - H144_LED1_RED, - }; - int padState[2]; - // 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(port, hwIndex, PAL_MODE_OUTPUT_PUSHPULL); - palClearPad(port, hwIndex); - // set LED1 pin to input - 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(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]) { - efiPrintf("* Hellen 176-pin mcu detected!"); - } else if (!padState[0] && padState[1]) { - efiPrintf("* Hellen 144-pin mcu detected!"); - } else { - efiPrintf("* Cannot figure if legacy 144 or 176 Hellen mcu module!"); - } -} - void detectHellenBoardType() { - detectHellenMcuType(); engine->engineState.hellenBoardId = detectHellenBoardId(); }