[bsp/stm32]fix compile warning (#10108)

* [bsp/stm32]fix compile warning
This commit is contained in:
dongly 2025-03-15 21:41:49 +08:00 committed by GitHub
parent fbe6563922
commit 9b05fc5913
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 40 additions and 36 deletions

View File

@ -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 * 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(); HAL_PWREx_EnableVddA();
#endif /* defined(SOC_SERIES_STM32U5) */ #endif /* defined(SOC_SERIES_STM32U5) */
if(HAL_ADC_ConfigChannel(stm32_adc_handler, &ADC_ChanConf) != HAL_OK) if(HAL_ADC_ConfigChannel(stm32_adc_handler, &ADC_ChanConf) != HAL_OK)
{ {
LOG_E("Failed to configure ADC channel %d", channel); LOG_E("Failed to configure ADC channel %d", channel);
return -RT_ERROR; return -RT_ERROR;
} }
/* perform an automatic ADC calibration to improve the conversion accuracy */ /* perform an automatic ADC calibration to improve the conversion accuracy */
#if defined(SOC_SERIES_STM32L4) || defined (SOC_SERIES_STM32WB) #if defined(SOC_SERIES_STM32L4) || defined (SOC_SERIES_STM32WB)
if (HAL_ADCEx_Calibration_Start(stm32_adc_handler, ADC_ChanConf.SingleDiff) != HAL_OK) if (HAL_ADCEx_Calibration_Start(stm32_adc_handler, ADC_ChanConf.SingleDiff) != HAL_OK)
{ {
LOG_E("ADC calibration error!\n"); LOG_E("ADC calibration error!\n");
return -RT_ERROR; return -RT_ERROR;
} }
#elif defined(SOC_SERIES_STM32MP1) || defined(SOC_SERIES_STM32H7) || defined(SOC_SERIES_STM32U5) #elif defined(SOC_SERIES_STM32MP1) || defined(SOC_SERIES_STM32H7) || defined(SOC_SERIES_STM32U5)
/* Run the ADC linear calibration in single-ended mode */ /* 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) 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 else
{ {
if (HAL_ADC_Stop(stm32_adc_handler) != HAL_OK) if (HAL_ADC_Stop(stm32_adc_handler) != HAL_OK)
{ {
LOG_E("Stop ADC conversion failed!\n"); LOG_E("Stop ADC conversion failed!\n");
return -RT_ERROR; return -RT_ERROR;
} }
} }
return RT_EOK; 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); RT_ASSERT(value != RT_NULL);
stm32_adc_handler = device->parent.user_data; stm32_adc_handler = device->parent.user_data;
if (HAL_ADC_Start(stm32_adc_handler) != HAL_OK) if (HAL_ADC_Start(stm32_adc_handler) != HAL_OK)
{ {
LOG_E("Start ADC conversion error!\n"); LOG_E("Start ADC conversion error!\n");
return -RT_ERROR; return -RT_ERROR;
} }
/* Wait for the ADC to convert */ /* Wait for the ADC to convert */
if (HAL_ADC_PollForConversion(stm32_adc_handler, 100) != RT_EOK) if (HAL_ADC_PollForConversion(stm32_adc_handler, 100) != RT_EOK)
{ {
LOG_E("ADC conversion error!\n"); LOG_E("ADC conversion error!\n");
return -RT_ERROR; return -RT_ERROR;
} }
/* get ADC value */ /* get ADC value */
*value = (rt_uint32_t)HAL_ADC_GetValue(stm32_adc_handler); *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; ADC_HandleTypeDef *stm32_adc_handler = device->parent.user_data;
ret = stm32_adc_enabled(device, RT_ADC_INTERN_CH_VREF, RT_TRUE); ret = stm32_adc_enabled(device, RT_ADC_INTERN_CH_VREF, RT_TRUE);
if (ret != RT_EOK) if (ret != RT_EOK)
return 0; return 0;
ret = stm32_adc_get_value(device, RT_ADC_INTERN_CH_VREF, &vref_value); ret = stm32_adc_get_value(device, RT_ADC_INTERN_CH_VREF, &vref_value);
if (ret != RT_EOK) if (ret != RT_EOK)
return 0; return 0;
ret = stm32_adc_enabled(device, RT_ADC_INTERN_CH_VREF, RT_FALSE); ret = stm32_adc_enabled(device, RT_ADC_INTERN_CH_VREF, RT_FALSE);
if (ret != RT_EOK) if (ret != RT_EOK)
return 0; return 0;
#ifdef SOC_SERIES_STM32U5 #ifdef SOC_SERIES_STM32U5
vref_mv = __LL_ADC_CALC_VREFANALOG_VOLTAGE(stm32_adc_handler->Instance, vref_value, stm32_adc_handler->Init.Resolution); 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; int result = RT_EOK;
/* save adc name */ /* save adc name */
char name_buf[5] = {'a', 'd', 'c', '0', 0}; 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++) for (i = 0; i < sizeof(adc_config) / sizeof(adc_config[0]); i++)
{ {

View File

@ -388,6 +388,7 @@ const struct fal_flash_dev stm32_onchip_flash_16k =
fal_flash_erase_16k, fal_flash_erase_16k,
}, },
8, 8,
{},
}; };
const struct fal_flash_dev stm32_onchip_flash_64k = 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, fal_flash_erase_64k,
}, },
8, 8,
{},
}; };
const struct fal_flash_dev stm32_onchip_flash_128k = 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, fal_flash_erase_128k,
}, },
8, 8,
{},
}; };
static int fal_flash_read_16k(long offset, rt_uint8_t *buf, size_t size) static int fal_flash_read_16k(long offset, rt_uint8_t *buf, size_t size)

View File

@ -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 * 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_dettach_irq,
stm32_pin_irq_enable, stm32_pin_irq_enable,
stm32_pin_get, stm32_pin_get,
RT_NULL,
}; };
rt_inline void pin_irq_hdr(int irqno) rt_inline void pin_irq_hdr(int irqno)

View File

@ -858,7 +858,7 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
static int stm32_hwtimer_init(void) static int stm32_hwtimer_init(void)
{ {
int i = 0; rt_uint32_t i = 0;
int result = RT_EOK; int result = RT_EOK;
for (i = 0; i < sizeof(stm32_hwtimer_obj) / sizeof(stm32_hwtimer_obj[0]); i++) for (i = 0; i < sizeof(stm32_hwtimer_obj) / sizeof(stm32_hwtimer_obj[0]); i++)

View File

@ -1315,7 +1315,7 @@ int rt_hw_usart_init(void)
rt_size_t obj_num = sizeof(uart_obj) / sizeof(struct stm32_uart); rt_size_t obj_num = sizeof(uart_obj) / sizeof(struct stm32_uart);
stm32_uart_get_config(); 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 */ /* init UART object */
uart_obj[i].config = &uart_config[i]; uart_obj[i].config = &uart_config[i];