board.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * Copyright (c) 2006-2018, RT-Thread Development Team
  3. * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0
  6. *
  7. * Change Logs:
  8. * Date Author Notes
  9. * 2009-01-05 Bernard first implementation
  10. * 2010-02-04 Magicoe ported to LPC17xx
  11. * 2010-05-02 Aozima update CMSIS to 130
  12. * 2017-08-02 XiaoYang porting to LPC54608 bsp
  13. * 2019-08-05 Magicoe porting to LPC55S69-EVK bsp
  14. * 2020-01-01 Karl Add PKG_USING_TFM support
  15. */
  16. #include <rthw.h>
  17. #include <rtthread.h>
  18. #include "board.h"
  19. #include "clock_config.h"
  20. #include "drv_uart.h"
  21. /**
  22. * This is the timer interrupt service routine.
  23. *
  24. */
  25. void SysTick_Handler(void)
  26. {
  27. /* enter interrupt */
  28. rt_interrupt_enter();
  29. rt_tick_increase();
  30. /* leave interrupt */
  31. rt_interrupt_leave();
  32. }
  33. /**
  34. * This function will initial LPC55Sxx board.
  35. */
  36. void rt_hw_board_init()
  37. {
  38. /* Hardware Initialization */
  39. BOARD_InitPins();
  40. CLOCK_EnableClock(kCLOCK_InputMux);
  41. CLOCK_EnableClock(kCLOCK_Gpio0);
  42. CLOCK_EnableClock(kCLOCK_Gpio1);
  43. GPIO_PortInit(GPIO, 0);
  44. GPIO_PortInit(GPIO, 1);
  45. /* NVIC Configuration */
  46. #define NVIC_VTOR_MASK 0x3FFFFF80
  47. #ifdef VECT_TAB_RAM
  48. /* Set the Vector Table base location at 0x10000000 */
  49. SCB->VTOR = (0x10000000 & NVIC_VTOR_MASK);
  50. #else /* VECT_TAB_FLASH */
  51. #ifdef PKG_USING_TFM
  52. /* Set the Vector Table base location at 0x00020000 when RTT with TF-M*/
  53. SCB->VTOR = (0x00020000 & NVIC_VTOR_MASK);
  54. #else
  55. /* Set the Vector Table base location at 0x00000000 */
  56. SCB->VTOR = (0x00000000 & NVIC_VTOR_MASK);
  57. #endif
  58. #endif
  59. #ifndef PKG_USING_TFM
  60. /* This init has finished in secure side of TF-M */
  61. BOARD_BootClockPLL150M();
  62. #endif
  63. //BOARD_BootClockFROHF96M();
  64. /* init systick 1 systick = 1/(100M / 100) 100¸ösystick = 1s*/
  65. SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
  66. /* set pend exception priority */
  67. NVIC_SetPriority(PendSV_IRQn, (1 << __NVIC_PRIO_BITS) - 1);
  68. /*init uart device*/
  69. rt_hw_uart_init();
  70. #ifdef RT_USING_CONSOLE
  71. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  72. #endif
  73. #ifdef RT_USING_COMPONENTS_INIT
  74. /* initialization board with RT-Thread Components */
  75. rt_components_board_init();
  76. #endif
  77. #ifdef RT_USING_HEAP
  78. rt_kprintf("sram heap, begin: 0x%p, end: 0x%p\n", HEAP_BEGIN, HEAP_END);
  79. rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
  80. #endif
  81. }
  82. /**
  83. * This function will called when memory fault.
  84. */
  85. void MemManage_Handler(void)
  86. {
  87. extern void HardFault_Handler(void);
  88. rt_kprintf("Memory Fault!\n");
  89. HardFault_Handler();
  90. }