board.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. * 2019-08-05 Magicoe porting to LPC55S69-EVK bsp
  13. */
  14. #include <rthw.h>
  15. #include <rtthread.h>
  16. #include "board.h"
  17. #include "clock_config.h"
  18. #include "drv_uart.h"
  19. /**
  20. * This is the timer interrupt service routine.
  21. *
  22. */
  23. void SysTick_Handler(void)
  24. {
  25. /* enter interrupt */
  26. rt_interrupt_enter();
  27. rt_tick_increase();
  28. /* leave interrupt */
  29. rt_interrupt_leave();
  30. }
  31. /**
  32. * This function will initial LPC55Sxx board.
  33. */
  34. void rt_hw_board_init()
  35. {
  36. /* Hardware Initialization */
  37. BOARD_InitPins();
  38. CLOCK_EnableClock(kCLOCK_InputMux);
  39. CLOCK_EnableClock(kCLOCK_Gpio0);
  40. CLOCK_EnableClock(kCLOCK_Gpio1);
  41. GPIO_PortInit(GPIO, 0);
  42. GPIO_PortInit(GPIO, 1);
  43. /* NVIC Configuration */
  44. #define NVIC_VTOR_MASK 0x3FFFFF80
  45. #ifdef VECT_TAB_RAM
  46. /* Set the Vector Table base location at 0x10000000 */
  47. SCB->VTOR = (0x10000000 & NVIC_VTOR_MASK);
  48. #else /* VECT_TAB_FLASH */
  49. /* Set the Vector Table base location at 0x00000000 */
  50. SCB->VTOR = (0x00000000 & NVIC_VTOR_MASK);
  51. #endif
  52. BOARD_BootClockPLL150M();
  53. //BOARD_BootClockFROHF96M();
  54. /* init systick 1 systick = 1/(100M / 100) 100 systicks = 1s*/
  55. SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
  56. /* set pend exception priority */
  57. NVIC_SetPriority(PendSV_IRQn, (1 << __NVIC_PRIO_BITS) - 1);
  58. /*init uart device*/
  59. rt_hw_uart_init();
  60. #if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
  61. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  62. #endif
  63. #ifdef RT_USING_COMPONENTS_INIT
  64. /* initialization board with RT-Thread Components */
  65. rt_components_board_init();
  66. #endif
  67. #ifdef RT_USING_HEAP
  68. rt_kprintf("sram heap, begin: 0x%p, end: 0x%p\n", HEAP_BEGIN, HEAP_END);
  69. rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
  70. #endif
  71. }
  72. /**
  73. * This function will called when memory fault.
  74. */
  75. void MemManage_Handler(void)
  76. {
  77. extern void HardFault_Handler(void);
  78. rt_kprintf("Memory Fault!\n");
  79. HardFault_Handler();
  80. }