hellen bugfix: all four LEDs should light up on start-up

This commit is contained in:
rusefillc 2022-03-13 01:30:35 -05:00
parent 20cf22665e
commit 9de0c10f24
1 changed files with 8 additions and 4 deletions

View File

@ -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]) {