1
0

board.c 1.4 KB

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