board.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. */
  12. #include <rthw.h>
  13. #include <rtthread.h>
  14. #include "uart.h"
  15. #include "board.h"
  16. #include "LPC177x_8x.h"
  17. #include "system_LPC177x_8x.h"
  18. #include "sdram.h"
  19. /**
  20. * @addtogroup LPC17xx
  21. */
  22. /*@{*/
  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 LPC17xx board.
  37. */
  38. void rt_hw_board_init()
  39. {
  40. /* NVIC Configuration */
  41. #define NVIC_VTOR_MASK 0x3FFFFF80
  42. #ifdef VECT_TAB_RAM
  43. /* Set the Vector Table base location at 0x10000000 */
  44. SCB->VTOR = (0x10000000 & NVIC_VTOR_MASK);
  45. #else /* VECT_TAB_FLASH */
  46. /* Set the Vector Table base location at 0x00000000 */
  47. SCB->VTOR = (0x00000000 & NVIC_VTOR_MASK);
  48. #endif
  49. /* init systick */
  50. SysTick_Config(SystemCoreClock/RT_TICK_PER_SECOND);
  51. /* set pend exception priority */
  52. NVIC_SetPriority(PendSV_IRQn, (1<<__NVIC_PRIO_BITS) - 1);
  53. #ifdef RT_USING_HEAP
  54. /* initialize memory system */
  55. #ifdef __CC_ARM
  56. rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)(0x10000000 + 1024*64));
  57. #elif __ICCARM__
  58. rt_system_heap_init(__segment_end("HEAP"), (void*)(0x10000000 + 1024*64));
  59. #else
  60. rt_system_heap_init((void*)&__bss_end, (void*)(0x10000000 + 1024*64));
  61. #endif
  62. #endif
  63. /* USART driver initialization is open by default */
  64. #ifdef RT_USING_SERIAL
  65. rt_hw_usart_init();
  66. #endif
  67. /* Set the shell console output device */
  68. #if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
  69. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  70. #endif
  71. /* Board underlying hardware initialization */
  72. #ifdef RT_USING_COMPONENTS_INIT
  73. rt_components_board_init();
  74. #endif
  75. #if LPC_EXT_SDRAM == 1
  76. {
  77. SDRAM_Init();
  78. }
  79. #endif
  80. }
  81. /*@}*/