diff --git a/bsp/wch/arm/Libraries/ch32_drivers/drv_hwtimer_ch32f10x.c b/bsp/wch/arm/Libraries/ch32_drivers/drv_hwtimer_ch32f10x.c index 6b22e0d5d453ec8f273021e9d57410692e029eb3..c89b28b3e98ff116808600fb050abf7fec6c4151 100644 --- a/bsp/wch/arm/Libraries/ch32_drivers/drv_hwtimer_ch32f10x.c +++ b/bsp/wch/arm/Libraries/ch32_drivers/drv_hwtimer_ch32f10x.c @@ -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 */ - diff --git a/bsp/wch/arm/ch32f103c8-core/board/board.c b/bsp/wch/arm/ch32f103c8-core/board/board.c index fe6b3df8da0e5569a077fa5ecc4b222e871a49fa..e335f9daa3cc963cad93a2b14eaf6a1def9b6626 100644 --- a/bsp/wch/arm/ch32f103c8-core/board/board.c +++ b/bsp/wch/arm/ch32f103c8-core/board/board.c @@ -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; diff --git a/bsp/wch/arm/ch32f103c8-core/board/board.h b/bsp/wch/arm/ch32f103c8-core/board/board.h index 8bf4b819e4958a151f721adfb7ba6475a02a5b58..dd9b6c1df2a2e854f3b4cc47f48ec236562fd1a3 100644 --- a/bsp/wch/arm/ch32f103c8-core/board/board.h +++ b/bsp/wch/arm/ch32f103c8-core/board/board.h @@ -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);