From 21ef733251473f1d7f43cab03d998210a000b844 Mon Sep 17 00:00:00 2001 From: Grissiom Date: Mon, 5 Jan 2015 21:30:42 +0800 Subject: [PATCH] lpc43xx: use the RIT timer as SysTick in M0 core --- bsp/lpc43xx/M0/applications/board.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/bsp/lpc43xx/M0/applications/board.c b/bsp/lpc43xx/M0/applications/board.c index 116c43304..c3377aac2 100644 --- a/bsp/lpc43xx/M0/applications/board.c +++ b/bsp/lpc43xx/M0/applications/board.c @@ -26,17 +26,34 @@ void RIT_OR_WWDT_IRQHandler(void) /* enter interrupt */ rt_interrupt_enter(); - rt_tick_increase(); + if (LPC_RITIMER->CTRL & 0x01) + { + rt_tick_increase(); + LPC_RITIMER->CTRL |= 0x01; + } /* leave interrupt */ rt_interrupt_leave(); } +extern void SystemCoreClockUpdate(void); + /** * This function will initial LPC43xx board. */ void rt_hw_board_init() { + SystemCoreClockUpdate(); + + /* Setup RIT timer. */ + LPC_RITIMER->COMPVAL = SystemCoreClock / RT_TICK_PER_SECOND - 1; + /* Enable auto-clear. */ + LPC_RITIMER->CTRL |= 1 << 1; + /* Reset the counter as the counter is enabled after reset. */ + LPC_RITIMER->COUNTER = 0; + NVIC_SetPriority(M0_RITIMER_OR_WWDT_IRQn, (1 << __NVIC_PRIO_BITS) - 1); + NVIC_EnableIRQ(M0_RITIMER_OR_WWDT_IRQn); + /* set pend exception priority */ NVIC_SetPriority(PendSV_IRQn, (1 << __NVIC_PRIO_BITS) - 1); -- GitLab