board.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. #include "drv_sdram.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 LPC54xx board.
  33. */
  34. void rt_hw_board_init()
  35. {
  36. /* Hardware Initialization */
  37. CLOCK_EnableClock(kCLOCK_InputMux);
  38. CLOCK_EnableClock(kCLOCK_Iocon);
  39. /* NVIC Configuration */
  40. #define NVIC_VTOR_MASK 0x3FFFFF80
  41. #ifdef VECT_TAB_RAM
  42. /* Set the Vector Table base location at 0x10000000 */
  43. SCB->VTOR = (0x10000000 & NVIC_VTOR_MASK);
  44. #else /* VECT_TAB_FLASH */
  45. /* Set the Vector Table base location at 0x00000000 */
  46. SCB->VTOR = (0x00000000 & NVIC_VTOR_MASK);
  47. #endif
  48. BOARD_BootClockFROHF48M();
  49. /* init systick 1 systick = 1/(100M / 100) 100 systicks = 1s*/
  50. SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
  51. /* set pend exception priority */
  52. NVIC_SetPriority(PendSV_IRQn, (1 << __NVIC_PRIO_BITS) - 1);
  53. /*init uart device*/
  54. rt_hw_uart_init();
  55. #if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
  56. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  57. #endif
  58. #ifdef BSP_DRV_SDRAM
  59. lpc_sdram_hw_init();
  60. #endif
  61. #ifdef RT_USING_COMPONENTS_INIT
  62. /* initialization board with RT-Thread Components */
  63. rt_components_board_init();
  64. #endif
  65. }
  66. #ifdef PKG_USING_GUIENGINE
  67. #include <rtgui/driver.h>
  68. #include "drv_lcd.h"
  69. /* initialize for gui driver */
  70. int rtgui_lcd_init(void)
  71. {
  72. rt_device_t device;
  73. rt_hw_lcd_init();
  74. device = rt_device_find("lcd");
  75. /* set graphic device */
  76. rtgui_graphic_set_device(device);
  77. return 0;
  78. }
  79. INIT_DEVICE_EXPORT(rtgui_lcd_init);
  80. #endif
  81. void MemManage_Handler(void)
  82. {
  83. extern void HardFault_Handler(void);
  84. rt_kprintf("Memory Fault!\n");
  85. HardFault_Handler();
  86. }