Skip to content

Commit 5ce8415

Browse files
committed
[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.
1 parent 8411176 commit 5ce8415

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

bsp/wch/arm/Libraries/ch32_drivers/drv_hwtimer_ch32f10x.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,16 @@ static void ch32f1_hwtimer_init(struct rt_hwtimer_device *device, rt_uint32_t st
7373

7474
if (state)
7575
{
76-
ch32f1_hwtimer_clock_init(hwtimer_dev->periph);
76+
ch32f1_tim_clock_init(hwtimer_dev->periph);
7777

7878
hwtimer_info = ch32f1_hwtimer_info_config_get(hwtimer_dev->periph);
7979

80-
clk = ch32f1_hwtimer_clock_get(hwtimer_dev->periph);
80+
clk = ch32f1_tim_clock_get(hwtimer_dev->periph);
8181

8282
prescaler_value = (rt_uint16_t)(clk / hwtimer_info->minfreq) - 1;
8383

8484
/*
85-
* set interrupt callback one or each time need total time =
86-
* (cnt + 1) * (1 / (clk/(prescaler_value + 1) ) )
85+
* (1 / freq) = (cnt + 1) * (1 / (clk/(prescaler_value + 1) ) )
8786
*/
8887

8988
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
132131
hwtimer_dev = (struct hwtimer_device *)device;
133132

134133
/*
135-
* interrupt callback one or each time need total time =
136-
* (cnt + 1) * (1 / (clk/(prescaler_value + 1) ) )
134+
* (1 / freq) = (cnt + 1) * (1 / (clk/(prescaler_value + 1) ) )
137135
*/
138136

139137
TIM_SetCounter(hwtimer_dev->periph, 0);
@@ -197,15 +195,14 @@ static rt_err_t ch32f1_hwtimer_control(struct rt_hwtimer_device *device, rt_uint
197195
rt_uint16_t prescaler_value = 0;
198196

199197
/*
200-
*set interrupt callback one or each time need total time =
201-
* (cnt + 1) * (1 / (clk/(prescaler_value + 1) ) )
198+
* (1 / freq) = (cnt + 1) * (1 / (clk/(prescaler_value + 1) ) )
202199
*/
203200
if (arg != RT_NULL)
204201
{
205202

206203
freq = *((rt_uint32_t *)arg);
207204

208-
clk = ch32f1_hwtimer_clock_get(hwtimer_dev->periph);
205+
clk = ch32f1_tim_clock_get(hwtimer_dev->periph);
209206

210207
prescaler_value = (rt_uint16_t)(clk / freq) - 1;
211208

@@ -369,4 +366,3 @@ void TIM4_IRQHandler(void)
369366
#endif
370367

371368
#endif /* BSP_USING_HWTIMER */
372-

bsp/wch/arm/ch32f103c8-core/board/board.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ void ch32f1_i2c_config(I2C_TypeDef *i2cx)
200200
}
201201
}
202202

203-
void ch32f1_hwtimer_clock_init(TIM_TypeDef *timx)
203+
void ch32f1_tim_clock_init(TIM_TypeDef *timx)
204204
{
205205
if (timx == TIM1)
206206
{
@@ -223,7 +223,7 @@ void ch32f1_hwtimer_clock_init(TIM_TypeDef *timx)
223223
}
224224
}
225225

226-
rt_uint32_t ch32f1_hwtimer_clock_get(TIM_TypeDef *timx)
226+
rt_uint32_t ch32f1_tim_clock_get(TIM_TypeDef *timx)
227227
{
228228
RCC_ClocksTypeDef RCC_Clocks;
229229

bsp/wch/arm/ch32f103c8-core/board/board.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ void ch32f1_spi_clock_and_io_init(SPI_TypeDef* spix);
5050
rt_uint32_t ch32f1_spi_clock_get(SPI_TypeDef* spix);
5151
void ch32f1_i2c_clock_and_io_init(I2C_TypeDef* i2cx);
5252
void ch32f1_i2c_config(I2C_TypeDef* i2cx);
53-
void ch32f1_hwtimer_clock_init(TIM_TypeDef *timx);
54-
rt_uint32_t ch32f1_hwtimer_clock_get(TIM_TypeDef *timx);
53+
void ch32f1_tim_clock_init(TIM_TypeDef *timx);
54+
rt_uint32_t ch32f1_tim_clock_get(TIM_TypeDef *timx);
5555
struct rt_hwtimer_info* ch32f1_hwtimer_info_config_get(TIM_TypeDef *timx);
5656

5757

0 commit comments

Comments
 (0)