board.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. * 2010-02-04 Magicoe ported to LPC17xx
  10. * 2010-05-02 Aozima update CMSIS to 130
  11. * 2017-08-02 XiaoYang porting to LPC54608 bsp
  12. */
  13. #include <rthw.h>
  14. #include <rtthread.h>
  15. #include "board.h"
  16. #include "clock_config.h"
  17. #include "drv_uart.h"
  18. /**
  19. * This is the timer interrupt service routine.
  20. *
  21. */
  22. void SysTick_Handler(void)
  23. {
  24. /* enter interrupt */
  25. rt_interrupt_enter();
  26. rt_tick_increase();
  27. /* leave interrupt */
  28. rt_interrupt_leave();
  29. }
  30. /**
  31. * This function will initial LPC54xx board.
  32. */
  33. void rt_hw_board_init()
  34. {
  35. /* Hardware Initialization */
  36. CLOCK_EnableClock(kCLOCK_InputMux);
  37. CLOCK_EnableClock(kCLOCK_Iocon);
  38. /* NVIC Configuration */
  39. #define NVIC_VTOR_MASK 0x3FFFFF80
  40. #ifdef VECT_TAB_RAM
  41. /* Set the Vector Table base location at 0x10000000 */
  42. SCB->VTOR = (0x10000000 & NVIC_VTOR_MASK);
  43. #else /* VECT_TAB_FLASH */
  44. /* Set the Vector Table base location at 0x00000000 */
  45. SCB->VTOR = (0x00000000 & NVIC_VTOR_MASK);
  46. #endif
  47. BOARD_BootClockFROHF48M();
  48. /* init systick 1 systick = 1/(100M / 100) 100��systick = 1s*/
  49. SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
  50. /* set pend exception priority */
  51. NVIC_SetPriority(PendSV_IRQn, (1 << __NVIC_PRIO_BITS) - 1);
  52. #ifdef RT_USING_HEAP
  53. rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
  54. #endif
  55. #ifdef RT_USING_COMPONENTS_INIT
  56. /* initialization board with RT-Thread Components */
  57. rt_components_board_init();
  58. #endif
  59. #if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
  60. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  61. #endif
  62. }
  63. void MemManage_Handler(void)
  64. {
  65. extern void HardFault_Handler(void);
  66. rt_kprintf("Memory Fault!\n");
  67. HardFault_Handler();
  68. }