提交 5ce84153 编写于 作者: C charlown

[bsp/wch/arm/Libraries/ch32_drivers/drv_hwtimer_ch32f10x.c]:rename func:...

[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.
上级 84111766
......@@ -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 */
......@@ -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;
......
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册