summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcharlown <[email protected]>2021-09-10 17:12:31 +0800
committercharlown <[email protected]>2021-09-10 17:12:31 +0800
commit5ce84153f3f44a674eedfbc9f5a5e7440f7736e0 (patch)
tree3d23efffc2cca4f7ca9be333ee8ec29c41d5212e
parent84111766f959685fb7b1af99f3f26bca5f7ef7d2 (diff)
[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.
-rw-r--r--bsp/wch/arm/Libraries/ch32_drivers/drv_hwtimer_ch32f10x.c16
-rw-r--r--bsp/wch/arm/ch32f103c8-core/board/board.c4
-rw-r--r--bsp/wch/arm/ch32f103c8-core/board/board.h4
3 files changed, 10 insertions, 14 deletions
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 6b22e0d5d4..c89b28b3e9 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 fe6b3df8da..e335f9daa3 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 8bf4b819e4..dd9b6c1df2 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);