board.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright (c) 2006-2018, Synwit Technology Co.,Ltd.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2018-05-31 ZYH first version
  9. * 2018-12-10 Zohar_Lee format file
  10. */
  11. #include <board.h>
  12. #if defined(BSP_USING_EXT_SRAM) && defined(RT_USING_MEMHEAP_AS_HEAP)
  13. static struct rt_memheap system_heap;
  14. #endif
  15. static void bsp_clock_config(void)
  16. {
  17. SystemInit();
  18. SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
  19. SysTick->CTRL |= 0x00000004UL;
  20. }
  21. void SysTick_Handler(void)
  22. {
  23. /* enter interrupt */
  24. rt_interrupt_enter();
  25. rt_tick_increase();
  26. /* leave interrupt */
  27. rt_interrupt_leave();
  28. }
  29. #ifdef BSP_USING_EXT_SRAM
  30. extern int rt_hw_sram_init(void);
  31. #endif
  32. void rt_hw_board_init()
  33. {
  34. bsp_clock_config();
  35. #ifdef BSP_USING_EXT_SRAM
  36. rt_hw_sram_init();
  37. #endif
  38. #if defined(BSP_USING_EXT_SRAM) && defined(RT_USING_MEMHEAP_AS_HEAP)
  39. rt_system_heap_init((void *)EXT_SRAM_BEGIN, (void *)EXT_SRAM_END);
  40. rt_memheap_init(&system_heap, "sram", (void *)HEAP_BEGIN, HEAP_SIZE);
  41. #elif defined(RT_USING_HEAP)
  42. rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
  43. #endif
  44. #ifdef RT_USING_COMPONENTS_INIT
  45. rt_components_board_init();
  46. #endif
  47. #ifdef RT_USING_CONSOLE
  48. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  49. #endif
  50. }