board.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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-15 Jonas first version
  9. */
  10. #include <stdint.h>
  11. #include <rthw.h>
  12. #include <rtthread.h>
  13. #include <hk32f0xx.h>
  14. #include <board.h>
  15. #ifdef RT_USING_FINSH
  16. #include <finsh.h>
  17. static void reboot(uint8_t argc, char **argv)
  18. {
  19. rt_hw_cpu_reset();
  20. }
  21. MSH_CMD_EXPORT(reboot, reboot system);
  22. #endif /* RT_USING_FINSH */
  23. /** System Clock Configuration
  24. */
  25. void SystemClock_Config(void)
  26. {
  27. SystemCoreClockUpdate();
  28. SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
  29. NVIC_SetPriority(SysTick_IRQn, 0);
  30. }
  31. /**
  32. * This is the timer interrupt service routine.
  33. *
  34. */
  35. void SysTick_Handler(void)
  36. {
  37. /* enter interrupt */
  38. rt_interrupt_enter();
  39. rt_tick_increase();
  40. /* leave interrupt */
  41. rt_interrupt_leave();
  42. }
  43. /**
  44. * This function will initial HK32 board.
  45. */
  46. void rt_hw_board_init()
  47. {
  48. SystemClock_Config();
  49. #ifdef RT_USING_COMPONENTS_INIT
  50. rt_components_board_init();
  51. #endif
  52. #if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
  53. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  54. #endif
  55. #ifdef BSP_USING_SRAM
  56. rt_system_heap_init((void *)EXT_SRAM_BEGIN, (void *)EXT_SRAM_END);
  57. #else
  58. rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
  59. #endif
  60. }