Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 33 additions & 33 deletions bsp/stm32/libraries/HAL_Drivers/drivers/drv_adc.c
Original file line number Diff line number Diff line change
@@ -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
*
Expand Down Expand Up @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
{
Expand All @@ -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 =
{
Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion bsp/stm32/libraries/HAL_Drivers/drivers/drv_gpio.c
Original file line number Diff line number Diff line change
@@ -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
*
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion bsp/stm32/libraries/HAL_Drivers/drivers/drv_tim.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand Down
2 changes: 1 addition & 1 deletion bsp/stm32/libraries/HAL_Drivers/drivers/drv_usart_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down