board.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * File : board.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2009 RT-Thread Develop Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2009-01-05 Bernard first implementation
  13. * 2010-02-04 Magicoe ported to LPC17xx
  14. * 2010-05-02 Aozima update CMSIS to 130
  15. * 2017-08-02 XiaoYang porting to LPC54608 bsp
  16. */
  17. #include <rthw.h>
  18. #include <rtthread.h>
  19. #include "board.h"
  20. #include "clock_config.h"
  21. #include "drv_uart.h"
  22. #include "drv_sdram.h"
  23. /**
  24. * This is the timer interrupt service routine.
  25. *
  26. */
  27. void SysTick_Handler(void)
  28. {
  29. /* enter interrupt */
  30. rt_interrupt_enter();
  31. rt_tick_increase();
  32. /* leave interrupt */
  33. rt_interrupt_leave();
  34. }
  35. /**
  36. * This function will initial LPC54xx board.
  37. */
  38. void rt_hw_board_init()
  39. {
  40. /* Hardware Initialization */
  41. CLOCK_EnableClock(kCLOCK_InputMux);
  42. CLOCK_EnableClock(kCLOCK_Iocon);
  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_BootClockFROHF48M();
  53. /* init systick 1 systick = 1/(100M / 100) 100¸ösystick = 1s*/
  54. SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
  55. /* set pend exception priority */
  56. NVIC_SetPriority(PendSV_IRQn, (1 << __NVIC_PRIO_BITS) - 1);
  57. /*init uart device*/
  58. rt_hw_uart_init();
  59. #ifdef RT_USING_CONSOLE
  60. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  61. #endif
  62. #ifdef BSP_DRV_SDRAM
  63. lpc_sdram_hw_init();
  64. #endif
  65. #ifdef RT_USING_COMPONENTS_INIT
  66. /* initialization board with RT-Thread Components */
  67. rt_components_board_init();
  68. #endif
  69. }
  70. #ifdef PKG_USING_GUIENGINE
  71. #include <rtgui/driver.h>
  72. #include "drv_lcd.h"
  73. /* initialize for gui driver */
  74. int rtgui_lcd_init(void)
  75. {
  76. rt_device_t device;
  77. rt_hw_lcd_init();
  78. device = rt_device_find("lcd");
  79. /* set graphic device */
  80. rtgui_graphic_set_device(device);
  81. return 0;
  82. }
  83. INIT_DEVICE_EXPORT(rtgui_lcd_init);
  84. #endif
  85. void MemManage_Handler(void)
  86. {
  87. extern void HardFault_Handler(void);
  88. rt_kprintf("Memory Fault!\n");
  89. HardFault_Handler();
  90. }