1 /* 2 * Copyright (c) 2006-2022, Synwit Technology Co.,Ltd. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2021-07-01 lik first version 9 */ 10 11 #include "board.h" 12 13 #ifdef RT_USING_MEMHEAP_AS_HEAP 14 static struct rt_memheap system_heap; 15 #endif 16 bsp_clock_config(void)17static void bsp_clock_config(void) 18 { 19 SystemInit(); 20 SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND); 21 SysTick->CTRL |= 0x00000004UL; 22 } 23 SysTick_Handler(void)24void SysTick_Handler(void) 25 { 26 /* enter interrupt */ 27 rt_interrupt_enter(); 28 29 rt_tick_increase(); 30 31 /* leave interrupt */ 32 rt_interrupt_leave(); 33 } 34 rt_hw_board_init()35void rt_hw_board_init() 36 { 37 bsp_clock_config(); 38 /* Heap initialization */ 39 #ifdef RT_USING_HEAP 40 rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END); 41 #endif 42 #if defined(BSP_USING_SDRAM) && defined(RT_USING_MEMHEAP_AS_HEAP) 43 swm_sdram_init(); 44 /* If RT_USING_MEMHEAP_AS_HEAP is enabled, SDRAM is initialized to the heap */ 45 rt_memheap_init(&system_heap, "sdram", (void *)SDRAMM_BASE, BSP_SDRAM_SIZE); 46 #endif 47 /* Pin driver initialization is open by default */ 48 #ifdef RT_USING_PIN 49 swm_pin_init(); 50 #endif 51 /* USART driver initialization is open by default */ 52 #ifdef RT_USING_SERIAL 53 swm_uart_init(); 54 #endif 55 /* Set the shell console output device */ 56 #if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) 57 rt_console_set_device(RT_CONSOLE_DEVICE_NAME); 58 #endif 59 /* Board underlying hardware initialization */ 60 #ifdef RT_USING_COMPONENTS_INIT 61 rt_components_board_init(); 62 #endif 63 64 } 65