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 * 2014-06-20 xiaonong ported to LPC43xx 10 */ 11 12 #include <rthw.h> 13 #include <rtthread.h> 14 15 #include "board.h" 16 #include "drv_uart.h" 17 18 19 /** M0 does not have SysTick so we have to use RIT timer for it... */ RIT_OR_WWDT_IRQHandler(void)20void RIT_OR_WWDT_IRQHandler(void) 21 { 22 /* enter interrupt */ 23 rt_interrupt_enter(); 24 25 if (LPC_RITIMER->CTRL & 0x01) 26 { 27 rt_tick_increase(); 28 LPC_RITIMER->CTRL |= 0x01; 29 } 30 31 /* leave interrupt */ 32 rt_interrupt_leave(); 33 } 34 35 extern void SystemCoreClockUpdate(void); 36 37 /** 38 * This function will initial LPC43xx board. 39 */ rt_hw_board_init()40void rt_hw_board_init() 41 { 42 SystemCoreClockUpdate(); 43 44 /* Setup RIT timer. */ 45 LPC_RITIMER->MASK = 0; 46 LPC_RITIMER->COMPVAL = SystemCoreClock / RT_TICK_PER_SECOND; 47 /* Enable auto-clear. */ 48 LPC_RITIMER->CTRL |= 1 << 1; 49 /* Reset the counter as the counter is enabled after reset. */ 50 LPC_RITIMER->COUNTER = 0; 51 NVIC_SetPriority(M0_RITIMER_OR_WWDT_IRQn, (1 << __NVIC_PRIO_BITS) - 1); 52 NVIC_EnableIRQ(M0_RITIMER_OR_WWDT_IRQn); 53 54 /* set pend exception priority */ 55 NVIC_SetPriority(PendSV_IRQn, (1 << __NVIC_PRIO_BITS) - 1); 56 57 /* init uart device */ 58 rt_hw_uart_init(); 59 60 /* setup the console device */ 61 rt_console_set_device(RT_CONSOLE_DEVICE_NAME); 62 } 63 64