Skip to content

Commit 8c3790d

Browse files
Lars Jeppesencarlescufi
authored andcommitted
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 <[email protected]>
1 parent a0411ad commit 8c3790d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

drivers/adc/adc_stm32.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,6 +1308,11 @@ static int adc_stm32_sampling_time_setup(const struct device *dev, uint8_t id,
13081308
static int adc_stm32_channel_setup(const struct device *dev,
13091309
const struct adc_channel_cfg *channel_cfg)
13101310
{
1311+
#ifdef CONFIG_SOC_SERIES_STM32H5X
1312+
const struct adc_stm32_cfg *config = (const struct adc_stm32_cfg *)dev->config;
1313+
ADC_TypeDef *adc = config->base;
1314+
#endif
1315+
13111316
if (channel_cfg->differential) {
13121317
LOG_ERR("Differential channels are not supported");
13131318
return -EINVAL;
@@ -1329,6 +1334,14 @@ static int adc_stm32_channel_setup(const struct device *dev,
13291334
return -EINVAL;
13301335
}
13311336

1337+
#ifdef CONFIG_SOC_SERIES_STM32H5X
1338+
if (adc == ADC1) {
1339+
if (channel_cfg->channel_id == 0) {
1340+
LL_ADC_EnableChannel0_GPIO(adc);
1341+
}
1342+
}
1343+
#endif
1344+
13321345
LOG_DBG("Channel setup succeeded!");
13331346

13341347
return 0;

0 commit comments

Comments
 (0)