drivers: adc: stm32h5x: Set option register for adc1/channel 0

The STM32H5x adc has a special option register that
needs to be set when using channel 0 on adc1.

fixes: #77618

Signed-off-by: Lars Jeppesen <lje@foss.dk>
This commit is contained in:
Lars Jeppesen 2024-08-27 10:45:34 +02:00 committed by Carles Cufí
commit 8c3790d9b7

View file

@ -1308,6 +1308,11 @@ static int adc_stm32_sampling_time_setup(const struct device *dev, uint8_t id,
static int adc_stm32_channel_setup(const struct device *dev,
const struct adc_channel_cfg *channel_cfg)
{
#ifdef CONFIG_SOC_SERIES_STM32H5X
const struct adc_stm32_cfg *config = (const struct adc_stm32_cfg *)dev->config;
ADC_TypeDef *adc = config->base;
#endif
if (channel_cfg->differential) {
LOG_ERR("Differential channels are not supported");
return -EINVAL;
@ -1329,6 +1334,14 @@ static int adc_stm32_channel_setup(const struct device *dev,
return -EINVAL;
}
#ifdef CONFIG_SOC_SERIES_STM32H5X
if (adc == ADC1) {
if (channel_cfg->channel_id == 0) {
LL_ADC_EnableChannel0_GPIO(adc);
}
}
#endif
LOG_DBG("Channel setup succeeded!");
return 0;