mirror of https://github.com/RT-Thread/rt-thread
[bsp/stm32]fix compile warning (#10108)
* [bsp/stm32]fix compile warning
This commit is contained in:
parent
fbe6563922
commit
9b05fc5913
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2006-2023, RT-Thread Development Team
|
||||
* Copyright (c) 2006-2025, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
|
@ -199,19 +199,19 @@ static rt_err_t stm32_adc_enabled(struct rt_adc_device *device, rt_int8_t channe
|
|||
HAL_PWREx_EnableVddA();
|
||||
#endif /* defined(SOC_SERIES_STM32U5) */
|
||||
|
||||
if(HAL_ADC_ConfigChannel(stm32_adc_handler, &ADC_ChanConf) != HAL_OK)
|
||||
{
|
||||
LOG_E("Failed to configure ADC channel %d", channel);
|
||||
return -RT_ERROR;
|
||||
}
|
||||
if(HAL_ADC_ConfigChannel(stm32_adc_handler, &ADC_ChanConf) != HAL_OK)
|
||||
{
|
||||
LOG_E("Failed to configure ADC channel %d", channel);
|
||||
return -RT_ERROR;
|
||||
}
|
||||
|
||||
/* perform an automatic ADC calibration to improve the conversion accuracy */
|
||||
#if defined(SOC_SERIES_STM32L4) || defined (SOC_SERIES_STM32WB)
|
||||
if (HAL_ADCEx_Calibration_Start(stm32_adc_handler, ADC_ChanConf.SingleDiff) != HAL_OK)
|
||||
{
|
||||
LOG_E("ADC calibration error!\n");
|
||||
return -RT_ERROR;
|
||||
}
|
||||
if (HAL_ADCEx_Calibration_Start(stm32_adc_handler, ADC_ChanConf.SingleDiff) != HAL_OK)
|
||||
{
|
||||
LOG_E("ADC calibration error!\n");
|
||||
return -RT_ERROR;
|
||||
}
|
||||
#elif defined(SOC_SERIES_STM32MP1) || defined(SOC_SERIES_STM32H7) || defined(SOC_SERIES_STM32U5)
|
||||
/* Run the ADC linear calibration in single-ended mode */
|
||||
if (HAL_ADCEx_Calibration_Start(stm32_adc_handler, ADC_CALIB_OFFSET_LINEARITY, ADC_ChanConf.SingleDiff) != HAL_OK)
|
||||
|
@ -225,10 +225,10 @@ static rt_err_t stm32_adc_enabled(struct rt_adc_device *device, rt_int8_t channe
|
|||
else
|
||||
{
|
||||
if (HAL_ADC_Stop(stm32_adc_handler) != HAL_OK)
|
||||
{
|
||||
LOG_E("Stop ADC conversion failed!\n");
|
||||
return -RT_ERROR;
|
||||
}
|
||||
{
|
||||
LOG_E("Stop ADC conversion failed!\n");
|
||||
return -RT_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
|
@ -277,19 +277,19 @@ static rt_err_t stm32_adc_get_value(struct rt_adc_device *device, rt_int8_t chan
|
|||
RT_ASSERT(value != RT_NULL);
|
||||
|
||||
stm32_adc_handler = device->parent.user_data;
|
||||
|
||||
if (HAL_ADC_Start(stm32_adc_handler) != HAL_OK)
|
||||
{
|
||||
LOG_E("Start ADC conversion error!\n");
|
||||
return -RT_ERROR;
|
||||
}
|
||||
|
||||
if (HAL_ADC_Start(stm32_adc_handler) != HAL_OK)
|
||||
{
|
||||
LOG_E("Start ADC conversion error!\n");
|
||||
return -RT_ERROR;
|
||||
}
|
||||
|
||||
/* Wait for the ADC to convert */
|
||||
if (HAL_ADC_PollForConversion(stm32_adc_handler, 100) != RT_EOK)
|
||||
{
|
||||
LOG_E("ADC conversion error!\n");
|
||||
return -RT_ERROR;
|
||||
}
|
||||
{
|
||||
LOG_E("ADC conversion error!\n");
|
||||
return -RT_ERROR;
|
||||
}
|
||||
|
||||
/* get ADC value */
|
||||
*value = (rt_uint32_t)HAL_ADC_GetValue(stm32_adc_handler);
|
||||
|
@ -306,15 +306,15 @@ static rt_int16_t stm32_adc_get_vref (struct rt_adc_device *device)
|
|||
|
||||
ADC_HandleTypeDef *stm32_adc_handler = device->parent.user_data;
|
||||
|
||||
ret = stm32_adc_enabled(device, RT_ADC_INTERN_CH_VREF, RT_TRUE);
|
||||
if (ret != RT_EOK)
|
||||
return 0;
|
||||
ret = stm32_adc_enabled(device, RT_ADC_INTERN_CH_VREF, RT_TRUE);
|
||||
if (ret != RT_EOK)
|
||||
return 0;
|
||||
ret = stm32_adc_get_value(device, RT_ADC_INTERN_CH_VREF, &vref_value);
|
||||
if (ret != RT_EOK)
|
||||
return 0;
|
||||
if (ret != RT_EOK)
|
||||
return 0;
|
||||
ret = stm32_adc_enabled(device, RT_ADC_INTERN_CH_VREF, RT_FALSE);
|
||||
if (ret != RT_EOK)
|
||||
return 0;
|
||||
if (ret != RT_EOK)
|
||||
return 0;
|
||||
|
||||
#ifdef SOC_SERIES_STM32U5
|
||||
vref_mv = __LL_ADC_CALC_VREFANALOG_VOLTAGE(stm32_adc_handler->Instance, vref_value, stm32_adc_handler->Init.Resolution);
|
||||
|
@ -341,7 +341,7 @@ static int stm32_adc_init(void)
|
|||
int result = RT_EOK;
|
||||
/* save adc name */
|
||||
char name_buf[5] = {'a', 'd', 'c', '0', 0};
|
||||
int i = 0;
|
||||
rt_uint32_t i = 0;
|
||||
|
||||
for (i = 0; i < sizeof(adc_config) / sizeof(adc_config[0]); i++)
|
||||
{
|
||||
|
|
|
@ -388,6 +388,7 @@ const struct fal_flash_dev stm32_onchip_flash_16k =
|
|||
fal_flash_erase_16k,
|
||||
},
|
||||
8,
|
||||
{},
|
||||
};
|
||||
const struct fal_flash_dev stm32_onchip_flash_64k =
|
||||
{
|
||||
|
@ -402,6 +403,7 @@ const struct fal_flash_dev stm32_onchip_flash_64k =
|
|||
fal_flash_erase_64k,
|
||||
},
|
||||
8,
|
||||
{},
|
||||
};
|
||||
const struct fal_flash_dev stm32_onchip_flash_128k =
|
||||
{
|
||||
|
@ -416,6 +418,7 @@ const struct fal_flash_dev stm32_onchip_flash_128k =
|
|||
fal_flash_erase_128k,
|
||||
},
|
||||
8,
|
||||
{},
|
||||
};
|
||||
|
||||
static int fal_flash_read_16k(long offset, rt_uint8_t *buf, size_t size)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2006-2023, RT-Thread Development Team
|
||||
* Copyright (c) 2006-2025, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
|
@ -524,6 +524,7 @@ static const struct rt_pin_ops _stm32_pin_ops =
|
|||
stm32_pin_dettach_irq,
|
||||
stm32_pin_irq_enable,
|
||||
stm32_pin_get,
|
||||
RT_NULL,
|
||||
};
|
||||
|
||||
rt_inline void pin_irq_hdr(int irqno)
|
||||
|
|
|
@ -858,7 +858,7 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
|
|||
|
||||
static int stm32_hwtimer_init(void)
|
||||
{
|
||||
int i = 0;
|
||||
rt_uint32_t i = 0;
|
||||
int result = RT_EOK;
|
||||
|
||||
for (i = 0; i < sizeof(stm32_hwtimer_obj) / sizeof(stm32_hwtimer_obj[0]); i++)
|
||||
|
|
|
@ -1315,7 +1315,7 @@ int rt_hw_usart_init(void)
|
|||
rt_size_t obj_num = sizeof(uart_obj) / sizeof(struct stm32_uart);
|
||||
|
||||
stm32_uart_get_config();
|
||||
for (int i = 0; i < obj_num; i++)
|
||||
for (rt_uint32_t i = 0; i < obj_num; i++)
|
||||
{
|
||||
/* init UART object */
|
||||
uart_obj[i].config = &uart_config[i];
|
||||
|
|
Loading…
Reference in New Issue