1 /*
2  * Copyright (c) 2006-2022, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author            Notes
8  * 2022-02-16     Tuber             first version
9  */
10 
11 #include <rtthread.h>
12 #include <rtdevice.h>
13 #include <rthw.h>
14 #include "board.h"
15 
16 #ifdef RT_USING_SERIAL
17 #include "drv_uart.h"
18 #endif
19 
20 #ifdef RT_USING_FINSH
21 #include <finsh.h>
reboot(uint8_t argc,char ** argv)22 static void reboot(uint8_t argc, char **argv)
23 {
24     rt_hw_cpu_reset();
25 }
MSH_CMD_EXPORT(reboot,Reboot System)26 MSH_CMD_EXPORT(reboot, Reboot System)
27 #endif /* RT_USING_FINSH */
28 
29 void SysTick_Handler(void)
30 {
31     /* enter interrupt */
32     rt_interrupt_enter();
33 
34     rt_tick_increase();
35 
36     /* leave interrupt */
37     rt_interrupt_leave();
38 }
39 
rt_hw_board_init()40 void rt_hw_board_init()
41 {
42     // 打开PLL
43     PWR_UnitModCfg(ENABLE, UNIT_SYS_PLL);
44     // 设置外部40M做主频
45     SetSysClock(CLK_SOURCE_PLL_40MHz);
46     SysTick_Config(GetSysClock() / RT_TICK_PER_SECOND);
47     //开启中断
48     NVIC_SetPriority(SysTick_IRQn, 0);
49     NVIC_EnableIRQ(SysTick_IRQn);
50 
51 #if defined(RT_USING_HEAP)
52     rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
53 #endif
54 
55 #ifdef RT_USING_SERIAL
56     rt_hw_uart_init();
57 #endif
58 
59 #ifdef RT_USING_CONSOLE
60     rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
61 #endif
62 
63 #ifdef RT_USING_COMPONENTS_INIT
64     rt_components_board_init();
65 #endif
66 
67 }
68