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 */ 10 11 #include <board.h> 12 13 #if defined(BSP_USING_SDRAM) && defined(RT_USING_MEMHEAP_AS_HEAP) 14 #include "drv_sdram.h" 15 extern void rt_hw_sdram_init(void); 16 static struct rt_memheap system_heap; 17 #endif 18 SysTick_Handler(void)19void SysTick_Handler(void) 20 { 21 /* enter interrupt */ 22 rt_interrupt_enter(); 23 24 rt_tick_increase(); 25 26 /* leave interrupt */ 27 rt_interrupt_leave(); 28 } 29 30 /** 31 * This function will initial LPC40xx board. 32 */ rt_hw_board_init()33void rt_hw_board_init() 34 { 35 /* NVIC Configuration */ 36 #define NVIC_VTOR_MASK 0x3FFFFF80 37 #ifdef VECT_TAB_RAM 38 /* Set the Vector Table base location at 0x10000000 */ 39 SCB->VTOR = (0x10000000 & NVIC_VTOR_MASK); 40 #else /* VECT_TAB_FLASH */ 41 /* Set the Vector Table base location at 0x00000000 */ 42 SCB->VTOR = (0x00000000 & NVIC_VTOR_MASK); 43 #endif 44 45 /* init systick */ 46 SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND - 1); 47 /* set pend exception priority */ 48 NVIC_SetPriority(PendSV_IRQn, (1 << __NVIC_PRIO_BITS) - 1); 49 50 #ifdef RT_USING_HEAP 51 52 #if defined(BSP_USING_SDRAM) && defined(RT_USING_MEMHEAP_AS_HEAP) 53 rt_hw_sdram_init(); 54 rt_system_heap_init((void *)EXT_SDRAM_BEGIN, (void *)EXT_SDRAM_END); 55 rt_memheap_init(&system_heap, "sdram", (void *)HEAP_BEGIN, ((rt_uint32_t)HEAP_END - (rt_uint32_t)HEAP_BEGIN)); 56 #else 57 rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END); 58 #endif 59 60 #endif /* RT_USING_HEAP */ 61 62 #ifdef RT_USING_COMPONENTS_INIT 63 rt_components_board_init(); 64 #endif 65 #if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) 66 rt_console_set_device(RT_CONSOLE_DEVICE_NAME); 67 #endif 68 } 69