board.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Copyright (c) 2006-2025 RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021-08-20 BruceOu first implementation
  9. */
  10. #include <stdint.h>
  11. #include <rthw.h>
  12. #include <rtthread.h>
  13. #include <board.h>
  14. /**
  15. * @brief This function is executed in case of error occurrence.
  16. * @param None
  17. * @retval None
  18. */
  19. void Error_Handler(void)
  20. {
  21. /* USER CODE BEGIN Error_Handler */
  22. /* User can add his own implementation to report the HAL error return state */
  23. while (1)
  24. {
  25. }
  26. /* USER CODE END Error_Handler */
  27. }
  28. /** System Clock Configuration
  29. */
  30. void SystemClock_Config(void)
  31. {
  32. SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
  33. }
  34. /**
  35. * This is the timer interrupt service routine.
  36. *
  37. */
  38. void SysTick_Handler(void)
  39. {
  40. /* enter interrupt */
  41. rt_interrupt_enter();
  42. rt_tick_increase();
  43. /* leave interrupt */
  44. rt_interrupt_leave();
  45. }
  46. /**
  47. * This function will initial GD32 board.
  48. */
  49. void rt_hw_board_init()
  50. {
  51. /* NVIC Configuration */
  52. #define NVIC_VTOR_MASK 0x3FFFFF80
  53. #ifdef VECT_TAB_RAM
  54. /* Set the Vector Table base location at 0x10000000 */
  55. SCB->VTOR = (0x10000000 & NVIC_VTOR_MASK);
  56. #else /* VECT_TAB_FLASH */
  57. /* Set the Vector Table base location at 0x08000000 */
  58. SCB->VTOR = (0x08000000 & NVIC_VTOR_MASK);
  59. #endif
  60. /* Enable IChace */
  61. rt_hw_cpu_icache_enable();
  62. /* Enable DChace */
  63. rt_hw_cpu_dcache_enable();
  64. SystemClock_Config();
  65. #ifdef RT_USING_SERIAL
  66. rt_hw_usart_init();
  67. #endif
  68. #ifdef RT_USING_HEAP
  69. rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
  70. #endif
  71. #ifdef RT_USING_CONSOLE
  72. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  73. #endif
  74. #ifdef RT_USING_COMPONENTS_INIT
  75. rt_components_board_init();
  76. #endif
  77. }