board.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright (c) 2006-2022, Synwit Technology Co.,Ltd.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021-07-01 lik first version
  9. */
  10. #include "board.h"
  11. #ifdef RT_USING_MEMHEAP_AS_HEAP
  12. static struct rt_memheap system_heap;
  13. #endif
  14. static void bsp_clock_config(void)
  15. {
  16. SystemInit();
  17. SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
  18. SysTick->CTRL |= 0x00000004UL;
  19. }
  20. void SysTick_Handler(void)
  21. {
  22. /* enter interrupt */
  23. rt_interrupt_enter();
  24. rt_tick_increase();
  25. /* leave interrupt */
  26. rt_interrupt_leave();
  27. }
  28. void rt_hw_board_init()
  29. {
  30. bsp_clock_config();
  31. /* Heap initialization */
  32. #ifdef RT_USING_HEAP
  33. rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
  34. #endif
  35. #if defined(BSP_USING_SDRAM) && defined(RT_USING_MEMHEAP_AS_HEAP)
  36. swm_sdram_init();
  37. /* If RT_USING_MEMHEAP_AS_HEAP is enabled, SDRAM is initialized to the heap */
  38. rt_memheap_init(&system_heap, "sdram", (void *)SDRAMM_BASE, BSP_SDRAM_SIZE);
  39. #endif
  40. /* Pin driver initialization is open by default */
  41. #ifdef RT_USING_PIN
  42. swm_pin_init();
  43. #endif
  44. /* USART driver initialization is open by default */
  45. #ifdef RT_USING_SERIAL
  46. swm_uart_init();
  47. #endif
  48. /* Set the shell console output device */
  49. #if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
  50. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  51. #endif
  52. /* Board underlying hardware initialization */
  53. #ifdef RT_USING_COMPONENTS_INIT
  54. rt_components_board_init();
  55. #endif
  56. }