@@ -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-
0 commit comments