board.c 935 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. * 2021-08-05 mazhiyuan first version
  9. */
  10. #include <board.h>
  11. extern uint32_t SystemCoreClock;
  12. extern void SystemInit(void);
  13. static void bsp_clock_config(void)
  14. {
  15. SystemInit();
  16. SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
  17. SysTick->CTRL |= 0x00000004UL;
  18. }
  19. void SysTick_Handler(void)
  20. {
  21. /* enter interrupt */
  22. rt_interrupt_enter();
  23. rt_tick_increase();
  24. /* leave interrupt */
  25. rt_interrupt_leave();
  26. }
  27. void rt_hw_board_init()
  28. {
  29. bsp_clock_config();
  30. #if defined(RT_USING_HEAP)
  31. rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
  32. #endif
  33. #ifdef RT_USING_COMPONENTS_INIT
  34. rt_components_board_init();
  35. #endif
  36. #if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
  37. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  38. #endif
  39. }