board.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (c) 2006-2023, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2023/03/15 flyingcys first version
  9. */
  10. #include <rthw.h>
  11. #include <rtthread.h>
  12. #include "board.h"
  13. #include "drv_uart.h"
  14. #define RT_HEAP_SIZE 1024
  15. static uint32_t user_heap[RT_HEAP_SIZE]; // heap default size: 4K(1024 * 4)
  16. /* This is the timer interrupt service routine. */
  17. static void systick_isr(void)
  18. {
  19. rt_tick_increase();
  20. }
  21. void rt_hw_board_init(void)
  22. {
  23. bflb_irq_initialize();
  24. CPU_Set_MTimer_CLK(ENABLE, CPU_Get_MTimer_Source_Clock() / 1000 / 1000 - 1);
  25. bflb_mtimer_config(HW_MTIMER_CLOCK * 2 / RT_TICK_PER_SECOND, systick_isr);
  26. #ifdef RT_USING_HEAP
  27. /* initialize memory system */
  28. rt_system_heap_init((void *)user_heap, (void *)user_heap + RT_HEAP_SIZE);
  29. #endif
  30. /* UART driver initialization is open by default */
  31. #ifdef RT_USING_SERIAL
  32. rt_hw_uart_init();
  33. #endif
  34. /* Set the shell console output device */
  35. #if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
  36. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  37. #endif
  38. #ifdef RT_USING_COMPONENTS_INIT
  39. rt_components_board_init();
  40. #endif
  41. }
  42. void rt_hw_cpu_reset(void)
  43. {
  44. GLB_SW_POR_Reset();
  45. }
  46. MSH_CMD_EXPORT_ALIAS(rt_hw_cpu_reset, reboot, reset machine);