board.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright (c) 2006-2018, 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. */
  10. #include <board.h>
  11. #if defined(BSP_USING_SDRAM) && defined(RT_USING_MEMHEAP_AS_HEAP)
  12. #include "drv_sdram.h"
  13. extern void rt_hw_sdram_init(void);
  14. static struct rt_memheap system_heap;
  15. #endif
  16. void SysTick_Handler(void)
  17. {
  18. /* enter interrupt */
  19. rt_interrupt_enter();
  20. rt_tick_increase();
  21. /* leave interrupt */
  22. rt_interrupt_leave();
  23. }
  24. /**
  25. * This function will initial LPC40xx board.
  26. */
  27. void rt_hw_board_init()
  28. {
  29. /* NVIC Configuration */
  30. #define NVIC_VTOR_MASK 0x3FFFFF80
  31. #ifdef VECT_TAB_RAM
  32. /* Set the Vector Table base location at 0x10000000 */
  33. SCB->VTOR = (0x10000000 & NVIC_VTOR_MASK);
  34. #else /* VECT_TAB_FLASH */
  35. /* Set the Vector Table base location at 0x00000000 */
  36. SCB->VTOR = (0x00000000 & NVIC_VTOR_MASK);
  37. #endif
  38. /* init systick */
  39. SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND - 1);
  40. /* set pend exception priority */
  41. NVIC_SetPriority(PendSV_IRQn, (1 << __NVIC_PRIO_BITS) - 1);
  42. #ifdef RT_USING_HEAP
  43. #if defined(BSP_USING_SDRAM) && defined(RT_USING_MEMHEAP_AS_HEAP)
  44. rt_hw_sdram_init();
  45. rt_system_heap_init((void *)EXT_SDRAM_BEGIN, (void *)EXT_SDRAM_END);
  46. rt_memheap_init(&system_heap, "sdram", (void *)HEAP_BEGIN, ((rt_uint32_t)HEAP_END - (rt_uint32_t)HEAP_BEGIN));
  47. #else
  48. rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
  49. #endif
  50. #endif /* RT_USING_HEAP */
  51. #ifdef RT_USING_COMPONENTS_INIT
  52. rt_components_board_init();
  53. #endif
  54. #ifdef RT_USING_CONSOLE
  55. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  56. #endif
  57. }