adc_subscription: call efiSetPadMode for primary input only

Same pin can be used by two analog inputs (externaly muxed)
Call brain_pin_markUsed() only while requesting for primary user
This commit is contained in:
Andrey Gusakov 2024-07-20 23:58:50 +03:00 committed by rusefillc
parent dce26afd3f
commit 4007e0d7f8
1 changed files with 7 additions and 2 deletions

View File

@ -73,8 +73,13 @@ TODO: this code is similar to initIfValid, what is the plan? shall we extract he
*/
brain_pin_e pin = getAdcChannelBrainPin(name, channel);
if (pin != Gpio::Invalid) {
// todo: external muxes for internal ADC #3350
efiSetPadMode(name, pin, PAL_MODE_INPUT_ANALOG);
// todo: external muxes for internal ADC #3350
/* reuqest pin only for first muxed channel */
if (!adcIsMuxedInput(channel)) {
efiSetPadMode(name, pin, PAL_MODE_INPUT_ANALOG);
} else {
efiSetPadModeWithoutOwnershipAcquisition(name, pin, PAL_MODE_INPUT_ANALOG);
}
}
// if 0, default to the board's divider coefficient for given channel