board.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2022-12-08 WangShun the first version
  9. * 2022-12-13 WangShun put the rt_system_heap_init in head
  10. */
  11. #include <stdint.h>
  12. #include <rthw.h>
  13. #include <rtthread.h>
  14. #include "udma_uart_driver.h"
  15. #include "hal_udma_ctrl_reg_defs.h"
  16. #include "hal_udma_uart_reg_defs.h"
  17. #include "core-v-mcu-config.h"
  18. #include "drv_usart.h"
  19. #include "string.h"
  20. extern void rt_systick_config(void);
  21. #if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP)
  22. #define RT_HEAP_SIZE (64*1024)
  23. static rt_uint8_t rt_heap[RT_HEAP_SIZE];
  24. void *rt_heap_begin_get(void)
  25. {
  26. return rt_heap;
  27. }
  28. void *rt_heap_end_get(void)
  29. {
  30. return rt_heap + RT_HEAP_SIZE;
  31. }
  32. #endif
  33. void rt_hw_board_init()
  34. {
  35. /*Initialize heap first, or system_ Semaphore in init cannot be created*/
  36. #if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP)
  37. rt_system_heap_init(rt_heap_begin_get(), rt_heap_end_get());
  38. #endif
  39. /* System Clock Update */
  40. extern void system_init(void);
  41. system_init();
  42. /* System Tick Configuration */
  43. rt_systick_config();
  44. volatile uint32_t mtvec = 0;
  45. __asm volatile( "csrr %0, mtvec" : "=r"( mtvec ) );
  46. __asm volatile( "csrs mie, %0" :: "r"(0x880) );
  47. /* USART driver initialization is open by default */
  48. #ifdef RT_USING_SERIAL
  49. rt_hw_usart_init();
  50. #endif
  51. #ifdef RT_USING_CONSOLE
  52. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  53. #endif
  54. /* Call components board initial (use INIT_BOARD_EXPORT()) */
  55. #ifdef RT_USING_COMPONENTS_INIT
  56. rt_components_board_init();
  57. #endif
  58. }