[bsp/wch/arm/Libraries/ch32_drivers/drv_hwtimer_ch32f10x.c]:rename func: ch32f1_hwtimer_clock_init, ch32f1_hwtimer_clock_get, hwtimer and pwm will be use it. change some code annotation.

[bsp/wch/arm/ch32f103c8-core]: rename func.
This commit is contained in:
charlown 2021-09-10 17:12:31 +08:00
parent 84111766f9
commit 5ce84153f3
3 changed files with 10 additions and 14 deletions

View File

@ -73,17 +73,16 @@ static void ch32f1_hwtimer_init(struct rt_hwtimer_device *device, rt_uint32_t st
if (state)
{
ch32f1_hwtimer_clock_init(hwtimer_dev->periph);
ch32f1_tim_clock_init(hwtimer_dev->periph);
hwtimer_info = ch32f1_hwtimer_info_config_get(hwtimer_dev->periph);
clk = ch32f1_hwtimer_clock_get(hwtimer_dev->periph);
clk = ch32f1_tim_clock_get(hwtimer_dev->periph);
prescaler_value = (rt_uint16_t)(clk / hwtimer_info->minfreq) - 1;
/*
* set interrupt callback one or each time need total time =
* (cnt + 1) * (1 / (clk/(prescaler_value + 1) ) )
* (1 / freq) = (cnt + 1) * (1 / (clk/(prescaler_value + 1) ) )
*/
TIM_TimeBaseInitType.TIM_Period = hwtimer_info->maxcnt - 1;
@ -132,8 +131,7 @@ static rt_err_t ch32f1_hwtimer_start(struct rt_hwtimer_device *device, rt_uint32
hwtimer_dev = (struct hwtimer_device *)device;
/*
* interrupt callback one or each time need total time =
* (cnt + 1) * (1 / (clk/(prescaler_value + 1) ) )
* (1 / freq) = (cnt + 1) * (1 / (clk/(prescaler_value + 1) ) )
*/
TIM_SetCounter(hwtimer_dev->periph, 0);
@ -197,15 +195,14 @@ static rt_err_t ch32f1_hwtimer_control(struct rt_hwtimer_device *device, rt_uint
rt_uint16_t prescaler_value = 0;
/*
*set interrupt callback one or each time need total time =
* (cnt + 1) * (1 / (clk/(prescaler_value + 1) ) )
* (1 / freq) = (cnt + 1) * (1 / (clk/(prescaler_value + 1) ) )
*/
if (arg != RT_NULL)
{
freq = *((rt_uint32_t *)arg);
clk = ch32f1_hwtimer_clock_get(hwtimer_dev->periph);
clk = ch32f1_tim_clock_get(hwtimer_dev->periph);
prescaler_value = (rt_uint16_t)(clk / freq) - 1;
@ -369,4 +366,3 @@ void TIM4_IRQHandler(void)
#endif
#endif /* BSP_USING_HWTIMER */

View File

@ -200,7 +200,7 @@ void ch32f1_i2c_config(I2C_TypeDef *i2cx)
}
}
void ch32f1_hwtimer_clock_init(TIM_TypeDef *timx)
void ch32f1_tim_clock_init(TIM_TypeDef *timx)
{
if (timx == TIM1)
{
@ -223,7 +223,7 @@ void ch32f1_hwtimer_clock_init(TIM_TypeDef *timx)
}
}
rt_uint32_t ch32f1_hwtimer_clock_get(TIM_TypeDef *timx)
rt_uint32_t ch32f1_tim_clock_get(TIM_TypeDef *timx)
{
RCC_ClocksTypeDef RCC_Clocks;

View File

@ -50,8 +50,8 @@ void ch32f1_spi_clock_and_io_init(SPI_TypeDef* spix);
rt_uint32_t ch32f1_spi_clock_get(SPI_TypeDef* spix);
void ch32f1_i2c_clock_and_io_init(I2C_TypeDef* i2cx);
void ch32f1_i2c_config(I2C_TypeDef* i2cx);
void ch32f1_hwtimer_clock_init(TIM_TypeDef *timx);
rt_uint32_t ch32f1_hwtimer_clock_get(TIM_TypeDef *timx);
void ch32f1_tim_clock_init(TIM_TypeDef *timx);
rt_uint32_t ch32f1_tim_clock_get(TIM_TypeDef *timx);
struct rt_hwtimer_info* ch32f1_hwtimer_info_config_get(TIM_TypeDef *timx);