board.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (c) 2017-2019, MindMotion AE Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021-08-04 stackRyan first version
  9. */
  10. #include <rtthread.h>
  11. #include <rthw.h>
  12. #include <board.h>
  13. #include <drv_uart.h>
  14. extern uint32_t SystemCoreClock;
  15. extern void SystemInit(void);
  16. #ifdef RT_USING_FINSH
  17. #include <finsh.h>
  18. static void reboot(uint8_t argc, char **argv)
  19. {
  20. rt_hw_cpu_reset();
  21. }
  22. MSH_CMD_EXPORT(reboot, Reboot System);
  23. #endif /* RT_USING_FINSH */
  24. static void bsp_clock_config(void)
  25. {
  26. SystemInit();
  27. SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
  28. SysTick->CTRL |= 0x00000004UL;
  29. }
  30. void SysTick_Handler(void)
  31. {
  32. /* enter interrupt */
  33. rt_interrupt_enter();
  34. rt_tick_increase();
  35. /* leave interrupt */
  36. rt_interrupt_leave();
  37. }
  38. void rt_hw_board_init()
  39. {
  40. bsp_clock_config();
  41. #if defined(RT_USING_HEAP)
  42. rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
  43. #endif
  44. volatile uint16_t i=0;
  45. rt_hw_uart_init();
  46. i = UINT16_MAX;
  47. while(i--); //wait for a while after uart initiated.
  48. #ifdef RT_USING_COMPONENTS_INIT
  49. rt_components_board_init();
  50. #endif
  51. #if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
  52. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  53. #endif
  54. }