1 /* 2 * Copyright (c) 2006-2022, RT-Thread Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2020-04-29 supperthomas first version 9 * 10 */ 11 #include <rtthread.h> 12 #include <rthw.h> 13 #include <nrfx_systick.h> 14 15 #include "board.h" 16 #include "drv_uart.h" 17 #include <nrfx_clock.h> 18 19 /** 20 * This is the timer interrupt service routine. 21 * 22 */ SysTick_Handler(void)23void SysTick_Handler(void) 24 { 25 /* enter interrupt */ 26 rt_interrupt_enter(); 27 28 rt_tick_increase(); 29 30 /* leave interrupt */ 31 rt_interrupt_leave(); 32 } 33 clk_event_handler(nrfx_clock_evt_type_t event)34static void clk_event_handler(nrfx_clock_evt_type_t event){} 35 SysTick_Configuration(void)36void SysTick_Configuration(void) 37 { 38 nrfx_clock_init(clk_event_handler); 39 nrfx_clock_enable(); 40 nrfx_clock_lfclk_start(); 41 /* Set interrupt priority */ 42 NVIC_SetPriority(SysTick_IRQn, 0xf); 43 44 /* Configure SysTick to interrupt at the requested rate. */ 45 nrf_systick_load_set(SystemCoreClock / RT_TICK_PER_SECOND); 46 nrf_systick_val_clear(); 47 nrf_systick_csr_set(NRF_SYSTICK_CSR_CLKSOURCE_CPU | NRF_SYSTICK_CSR_TICKINT_ENABLE 48 | NRF_SYSTICK_CSR_ENABLE); 49 50 } 51 52 rt_hw_board_init(void)53void rt_hw_board_init(void) 54 { 55 rt_hw_interrupt_enable(0); 56 57 SysTick_Configuration(); 58 59 #if defined(RT_USING_HEAP) 60 rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END); 61 #endif 62 63 #ifdef RT_USING_SERIAL 64 rt_hw_uart_init(); 65 #endif 66 67 #if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) 68 rt_console_set_device(RT_CONSOLE_DEVICE_NAME); 69 #endif 70 71 #ifdef RT_USING_COMPONENTS_INIT 72 rt_components_board_init(); 73 #endif 74 75 #ifdef BSP_USING_SOFTDEVICE 76 extern uint32_t Image$$RW_IRAM1$$Base; 77 uint32_t const *const m_ram_start = &Image$$RW_IRAM1$$Base; 78 if ((uint32_t)m_ram_start == 0x20000000) 79 { 80 rt_kprintf("\r\n using softdevice the RAM couldn't be %p,please use the templete from package\r\n", m_ram_start); 81 while (1); 82 } 83 else 84 { 85 rt_kprintf("\r\n using softdevice the RAM at %p\r\n", m_ram_start); 86 } 87 #endif 88 89 } 90 91