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 * 2021-01-28 flybreak first version 9 * 2023-01-22 rose_man add RT_USING_SMP 10 * 2025-08-04 hydevcode first version 11 */ 12 13 #include <rthw.h> 14 #include <rtthread.h> 15 #include <stdio.h> 16 #include "board.h" 17 #include <pico/bootrom.h> 18 #include <pico/stdlib.h> 19 #include <hardware/clocks.h> 20 #include <hardware/structs/systick.h> 21 #include <drv_uart.h> 22 23 #define PLL_SYS_KHZ (150 * 1000) 24 SysTick_Handler(void)25void SysTick_Handler(void) 26 { 27 rt_interrupt_enter(); 28 rt_tick_increase(); 29 rt_interrupt_leave(); 30 } 31 systick_config(uint32_t ticks)32uint32_t systick_config(uint32_t ticks) 33 { 34 if ((ticks - 1UL) > M33_SYST_RVR_RELOAD_BITS) 35 { 36 return (1UL); /* Reload value impossible */ 37 } 38 39 systick_hw->rvr = (uint32_t)(ticks - 1UL); /* set reload register */ 40 systick_hw->csr = M33_SYST_CSR_CLKSOURCE_BITS | 41 M33_SYST_CSR_TICKINT_BITS | 42 M33_SYST_CSR_ENABLE_BITS; /* Enable SysTick IRQ and SysTick Timer */ 43 } 44 #include "pico/runtime.h" rt_hw_board_init()45void rt_hw_board_init() 46 { 47 #ifdef RT_USING_HEAP 48 rt_system_heap_init(HEAP_BEGIN, HEAP_END); 49 #endif 50 set_sys_clock_khz(PLL_SYS_KHZ, true); 51 52 alarm_pool_init_default(); 53 systick_config(clock_get_hz(clk_sys) / RT_TICK_PER_SECOND); 54 55 56 #ifdef RT_USING_COMPONENTS_INIT 57 rt_components_board_init(); 58 #endif 59 60 #ifdef RT_USING_SERIAL 61 stdio_init_all(); 62 rt_hw_uart_init(); 63 #endif 64 65 #ifdef RT_USING_CONSOLE 66 rt_console_set_device(RT_CONSOLE_DEVICE_NAME); 67 #endif 68 }