Skip to content

Commit dea12ec

Browse files
committed
style(bsp/gd32): 修改格式
1 parent 6dbb143 commit dea12ec

File tree

2 files changed

+34
-28
lines changed

2 files changed

+34
-28
lines changed

bsp/gd32/arm/gd32405rg/applications/main.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Change Logs:
77
* Date Author Notes
8-
* 2021-08-20 BruceOu first implementation
8+
* 2026-01-08 ShiHongChao first implementation
99
*/
1010

1111
#include <stdio.h>
@@ -40,15 +40,15 @@ static rt_err_t hwtimer_test_cb(rt_device_t dev, rt_size_t size)
4040
{
4141
rt_kprintf("this is hwtimer timeout callback fucntion!\n");
4242
rt_kprintf("tick is :%d !\n", rt_tick_get());
43-
43+
4444
return 0;
4545
}
4646

4747
#define HWTIMER_DEV_NAME "timer13"
4848

4949
/* hwtimer test */
5050
static void hwtimer_test(void)
51-
{
51+
{
5252
rt_err_t ret = RT_EOK;
5353
rt_hwtimerval_t timeout_s; /* 定时器超时值 */
5454
rt_device_t hw_dev = RT_NULL; /* 定时器设备句柄 */
@@ -73,7 +73,7 @@ static void hwtimer_test(void)
7373

7474
/* 设置超时回调函数 */
7575
rt_device_set_rx_indicate(hw_dev, hwtimer_test_cb);
76-
76+
7777
/* 设置计数频率(若未设置该项,默认为1Mhz 或 支持的最小计数频率) */
7878
rt_device_control(hw_dev, HWTIMER_CTRL_FREQ_SET, &freq);
7979
/* 设置模式为周期性定时器(若未设置,默认是HWTIMER_MODE_ONESHOT)*/
@@ -84,7 +84,7 @@ static void hwtimer_test(void)
8484
rt_kprintf("set mode failed! ret is :%d\n", ret);
8585
return;
8686
}
87-
87+
8888
/* 设置定时器超时值为5s并启动定时器 */
8989
timeout_s.sec = 5; /* 秒 */
9090
timeout_s.usec = 0; /* 微秒 */

bsp/gd32/arm/gd32405rg/board/board.c

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
*
66
* Change Logs:
77
* Date Author Notes
8-
* 2021-08-20 BruceOu first implementation
9-
* 2024-03-19 Evlers add serial supports
8+
* 2026-01-08 ShiHongChao first implementation
109
*/
1110
#include <stdint.h>
1211
#include <rthw.h>
@@ -69,13 +68,13 @@ void rt_hw_board_init()
6968
system_clock_8M_200M();
7069

7170
/* NVIC Configuration */
72-
#define NVIC_VTOR_MASK 0x3FFFFF80
73-
#ifdef VECT_TAB_RAM
71+
#define NVIC_VTOR_MASK 0x3FFFFF80
72+
#ifdef VECT_TAB_RAM
7473
/* Set the Vector Table base location at 0x10000000 */
75-
SCB->VTOR = (0x10000000 & NVIC_VTOR_MASK);
74+
SCB->VTOR = (0x10000000 & NVIC_VTOR_MASK);
7675
#else /* VECT_TAB_FLASH */
7776
/* Set the Vector Table base location at 0x08000000 */
78-
SCB->VTOR = (0x08000000 & NVIC_VTOR_MASK);
77+
SCB->VTOR = (0x08000000 & NVIC_VTOR_MASK);
7978
#endif
8079

8180
SystemClock_Config();
@@ -107,25 +106,28 @@ static void system_clock_8M_200M(void)
107106
{
108107
uint32_t timeout = 0U;
109108
uint32_t stab_flag = 0U;
110-
109+
111110
/* reset RCU */
112111
rcu_deinit();
113112

114113
/* enable HXTAL */
115114
RCU_CTL |= RCU_CTL_HXTALEN;
116115

117116
/* wait until HXTAL is stable or the startup time is longer than HXTAL_STARTUP_TIMEOUT */
118-
do{
117+
do
118+
{
119119
timeout++;
120120
stab_flag = (RCU_CTL & RCU_CTL_HXTALSTB);
121-
}while((0U == stab_flag) && (HXTAL_STARTUP_TIMEOUT != timeout));
121+
} while ((0U == stab_flag) && (HXTAL_STARTUP_TIMEOUT != timeout));
122122

123123
/* if fail */
124-
if(0U == (RCU_CTL & RCU_CTL_HXTALSTB)){
125-
while(1){
124+
if (0U == (RCU_CTL & RCU_CTL_HXTALSTB))
125+
{
126+
while (1)
127+
{
126128
}
127129
}
128-
130+
129131
RCU_APB1EN |= RCU_APB1EN_PMUEN;
130132
PMU_CTL |= PMU_CTL_LDOVS;
131133

@@ -137,35 +139,39 @@ static void system_clock_8M_200M(void)
137139
/* APB1 = AHB/4 */
138140
RCU_CFG0 |= RCU_APB1_CKAHB_DIV4;
139141

140-
/* Configure the main PLL, PSC = 8, PLL_N = 400, PLL_P = 2, PLL_Q = 9 */
142+
/* Configure the main PLL, PSC = 8, PLL_N = 400, PLL_P = 2, PLL_Q = 9 */
141143
RCU_PLL = (8U | (400U << 6U) | (((2U >> 1U) - 1U) << 16U) |
142-
(RCU_PLLSRC_HXTAL) | (9U << 24U));
144+
(RCU_PLLSRC_HXTAL) | (9U << 24U));
143145

144146
/* enable PLL */
145147
RCU_CTL |= RCU_CTL_PLLEN;
146148

147149
/* wait until PLL is stable */
148-
while(0U == (RCU_CTL & RCU_CTL_PLLSTB)){
150+
while (0U == (RCU_CTL & RCU_CTL_PLLSTB))
151+
{
149152
}
150-
153+
151154
/* Enable the high-drive to extend the clock frequency to 200 Mhz */
152155
PMU_CTL |= PMU_CTL_HDEN;
153-
while(0U == (PMU_CS & PMU_CS_HDRF)){
156+
while (0U == (PMU_CS & PMU_CS_HDRF))
157+
{
154158
}
155-
159+
156160
/* select the high-drive mode */
157161
PMU_CTL |= PMU_CTL_HDS;
158-
while(0U == (PMU_CS & PMU_CS_HDSRF)){
159-
}
160-
162+
while (0U == (PMU_CS & PMU_CS_HDSRF))
163+
{
164+
}
165+
161166
/* select PLL as system clock */
162167
RCU_CFG0 &= ~RCU_CFG0_SCS;
163168
RCU_CFG0 |= RCU_CKSYSSRC_PLLP;
164169

165170
/* wait until PLL is selected as system clock */
166-
while(0U == (RCU_CFG0 & RCU_SCSS_PLLP)){
171+
while (0U == (RCU_CFG0 & RCU_SCSS_PLLP))
172+
{
167173
}
168-
174+
169175
/* Update SystemCoreClock variable */
170176
SystemCoreClock = 200000000U; // 200MHz
171177
}

0 commit comments

Comments
 (0)