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  * 2017-08-02     XiaoYang     porting to LPC54608 bsp
12  * 2019-08-05     Magicoe      porting to LPC55S69-EVK bsp
13  */
14 
15 #include <rthw.h>
16 #include <rtthread.h>
17 
18 #include "board.h"
19 #include "clock_config.h"
20 #include "drv_uart.h"
21 
22 /**
23  * This is the timer interrupt service routine.
24  *
25  */
SysTick_Handler(void)26 void SysTick_Handler(void)
27 {
28     /* enter interrupt */
29     rt_interrupt_enter();
30 
31     rt_tick_increase();
32 
33     /* leave interrupt */
34     rt_interrupt_leave();
35 }
36 
37 /**
38  * This function will initial LPC55Sxx board.
39  */
rt_hw_board_init()40 void rt_hw_board_init()
41 {
42     /* Hardware Initialization */
43     BOARD_InitPins();
44 
45     CLOCK_EnableClock(kCLOCK_InputMux);
46 
47     CLOCK_EnableClock(kCLOCK_Gpio0);
48     CLOCK_EnableClock(kCLOCK_Gpio1);
49 
50     GPIO_PortInit(GPIO, 0);
51     GPIO_PortInit(GPIO, 1);
52 
53     /* NVIC Configuration */
54 #define NVIC_VTOR_MASK              0x3FFFFF80
55 #ifdef  VECT_TAB_RAM
56     /* Set the Vector Table base location at 0x10000000 */
57     SCB->VTOR  = (0x10000000 & NVIC_VTOR_MASK);
58 #else  /* VECT_TAB_FLASH  */
59     /* Set the Vector Table base location at 0x00000000 */
60     SCB->VTOR  = (0x00000000 & NVIC_VTOR_MASK);
61 #endif
62 
63     BOARD_BootClockPLL150M();
64     //BOARD_BootClockFROHF96M();
65 
66     /* init systick  1 systick = 1/(100M / 100) 100 systicks = 1s*/
67     SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
68     /* set pend exception priority */
69     NVIC_SetPriority(PendSV_IRQn, (1 << __NVIC_PRIO_BITS) - 1);
70 
71     /*init uart device*/
72     rt_hw_uart_init();
73 
74 #if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
75     rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
76 #endif
77 
78 #ifdef RT_USING_COMPONENTS_INIT
79     /* initialization board with RT-Thread Components */
80     rt_components_board_init();
81 #endif
82 
83 #ifdef RT_USING_HEAP
84     rt_kprintf("sram heap, begin: 0x%p, end: 0x%p\n", HEAP_BEGIN, HEAP_END);
85     rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
86 #endif
87 }
88 
89 /**
90  * This function will called when memory fault.
91  */
MemManage_Handler(void)92 void MemManage_Handler(void)
93 {
94     extern void HardFault_Handler(void);
95 
96     rt_kprintf("Memory Fault!\n");
97     HardFault_Handler();
98 }
99