1 /*
2  * Copyright (c) 2006-2021, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author       Notes
8  * 2009-01-05     Bernard      first implementation
9  * 2010-02-04     Magicoe      ported to LPC17xx
10  * 2010-05-02     Aozima       update CMSIS to 130
11  */
12 
13 #include <rthw.h>
14 #include <rtthread.h>
15 
16 #include "board.h"
17 #include "drv_uart.h"
18 
19 /**
20  * This is the timer interrupt service routine.
21  *
22  */
SysTick_Handler(void)23 void SysTick_Handler(void)
24 {
25     /* enter interrupt */
26     rt_interrupt_enter();
27 
28     rt_tick_increase();
29 
30     /* leave interrupt */
31     rt_interrupt_leave();
32 }
33 
34 /**
35  * This function will initial LPC54xx board.
36  */
rt_hw_board_init()37 void rt_hw_board_init()
38 {
39     /* NVIC Configuration */
40 #define NVIC_VTOR_MASK              0x3FFFFF80
41 #ifdef  VECT_TAB_RAM
42     /* Set the Vector Table base location at 0x10000000 */
43     SCB->VTOR  = (0x10000000 & NVIC_VTOR_MASK);
44 #else  /* VECT_TAB_FLASH  */
45     /* Set the Vector Table base location at 0x00000000 */
46     SCB->VTOR  = (0x00000000 & NVIC_VTOR_MASK);
47 #endif
48     SystemCoreClockUpdate();
49     /* init systick  1 systick = 1/(100M / 100) 100个systick = 1s*/
50     SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
51     /* set pend exception priority */
52     NVIC_SetPriority(PendSV_IRQn, (1 << __NVIC_PRIO_BITS) - 1);
53 
54     /*init uart device*/
55     rt_hw_uart_init();
56     rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
57 
58 #ifdef RT_USING_COMPONENTS_INIT
59     /* initialization board with RT-Thread Components */
60     rt_components_board_init();
61 #endif
62 }
63 
64 /* initialization for system heap */
rt_hw_board_heap_init(void)65 int rt_hw_board_heap_init(void)
66 {
67 #ifdef RT_USING_HEAP
68     rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
69 #endif
70 
71     return 0;
72 }
73 
MemManage_Handler(void)74 void MemManage_Handler(void)
75 {
76     extern void HardFault_Handler(void);
77 
78     rt_kprintf("Memory Fault!\n");
79     HardFault_Handler();
80 }
81