From 4b8f518c4825dad80e57a5d295f63cfcba15905e Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sun, 19 Mar 2023 20:40:47 -0400 Subject: [PATCH] [stm32][adc] add error code return --- bsp/stm32/libraries/HAL_Drivers/drv_adc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_adc.c b/bsp/stm32/libraries/HAL_Drivers/drv_adc.c index ea4842ad37..6de8445d88 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drv_adc.c +++ b/bsp/stm32/libraries/HAL_Drivers/drv_adc.c @@ -329,8 +329,10 @@ static rt_int16_t stm32_adc_get_vref (struct rt_adc_device *device) ADC_HandleTypeDef *stm32_adc_handler = device->parent.user_data; ret = rt_adc_enable(device, ADC_CHANNEL_VREFINT - ADC_CHANNEL_0); + if (ret != RT_EOK) return (rt_int16_t)ret; vref_value = rt_adc_read(device, ADC_CHANNEL_VREFINT - ADC_CHANNEL_0); ret = rt_adc_disable(device, ADC_CHANNEL_VREFINT - ADC_CHANNEL_0); + if (ret != RT_EOK) return (rt_int16_t)ret; vref_mv = __LL_ADC_CALC_VREFANALOG_VOLTAGE(vref_value, stm32_adc_handler->Init.Resolution); #else