1 /* 2 * Copyright (c) 2006-2023, RT-Thread Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2023/03/15 flyingcys first version 9 */ 10 #include <rthw.h> 11 #include <rtthread.h> 12 13 #include "board.h" 14 #include "drv_uart.h" 15 16 #define RT_HEAP_SIZE 1024 17 static uint32_t user_heap[RT_HEAP_SIZE]; // heap default size: 4K(1024 * 4) 18 19 /* This is the timer interrupt service routine. */ systick_isr(void)20static void systick_isr(void) 21 { 22 rt_tick_increase(); 23 } 24 rt_hw_board_init(void)25void rt_hw_board_init(void) 26 { 27 bflb_irq_initialize(); 28 29 CPU_Set_MTimer_CLK(ENABLE, CPU_Get_MTimer_Source_Clock() / 1000 / 1000 - 1); 30 bflb_mtimer_config(HW_MTIMER_CLOCK * 2 / RT_TICK_PER_SECOND, systick_isr); 31 32 #ifdef RT_USING_HEAP 33 /* initialize memory system */ 34 rt_system_heap_init((void *)user_heap, (void *)user_heap + RT_HEAP_SIZE); 35 #endif 36 37 /* UART driver initialization is open by default */ 38 #ifdef RT_USING_SERIAL 39 rt_hw_uart_init(); 40 #endif 41 42 /* Set the shell console output device */ 43 #if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) 44 rt_console_set_device(RT_CONSOLE_DEVICE_NAME); 45 #endif 46 47 #ifdef RT_USING_COMPONENTS_INIT 48 rt_components_board_init(); 49 #endif 50 } 51 rt_hw_cpu_reset(void)52void rt_hw_cpu_reset(void) 53 { 54 GLB_SW_POR_Reset(); 55 } 56 MSH_CMD_EXPORT_ALIAS(rt_hw_cpu_reset, reboot, reset machine); 57