board.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * File : board.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2014 RT-Thread Develop Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2009-01-05 Bernard first implementation
  13. * 2014-06-20 xiaonong ported to LPC43xx
  14. */
  15. #include <rthw.h>
  16. #include <rtthread.h>
  17. #include "board.h"
  18. #include "drv_uart.h"
  19. /** M0 does not have SysTick so we have to use RIT timer for it... */
  20. void RIT_OR_WWDT_IRQHandler(void)
  21. {
  22. /* enter interrupt */
  23. rt_interrupt_enter();
  24. if (LPC_RITIMER->CTRL & 0x01)
  25. {
  26. rt_tick_increase();
  27. LPC_RITIMER->CTRL |= 0x01;
  28. }
  29. /* leave interrupt */
  30. rt_interrupt_leave();
  31. }
  32. extern void SystemCoreClockUpdate(void);
  33. /**
  34. * This function will initial LPC43xx board.
  35. */
  36. void rt_hw_board_init()
  37. {
  38. SystemCoreClockUpdate();
  39. /* Setup RIT timer. */
  40. LPC_RITIMER->MASK = 0;
  41. LPC_RITIMER->COMPVAL = SystemCoreClock / RT_TICK_PER_SECOND;
  42. /* Enable auto-clear. */
  43. LPC_RITIMER->CTRL |= 1 << 1;
  44. /* Reset the counter as the counter is enabled after reset. */
  45. LPC_RITIMER->COUNTER = 0;
  46. NVIC_SetPriority(M0_RITIMER_OR_WWDT_IRQn, (1 << __NVIC_PRIO_BITS) - 1);
  47. NVIC_EnableIRQ(M0_RITIMER_OR_WWDT_IRQn);
  48. /* set pend exception priority */
  49. NVIC_SetPriority(PendSV_IRQn, (1 << __NVIC_PRIO_BITS) - 1);
  50. /* init uart device */
  51. rt_hw_uart_init();
  52. /* setup the console device */
  53. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  54. }