board.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. * 2021-12-18 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. NVIC_SetPriority(SysTick_IRQn, 0);
  34. }
  35. /**
  36. * This is the timer interrupt service routine.
  37. *
  38. */
  39. void SysTick_Handler(void)
  40. {
  41. /* enter interrupt */
  42. rt_interrupt_enter();
  43. rt_tick_increase();
  44. /* leave interrupt */
  45. rt_interrupt_leave();
  46. }
  47. /**
  48. * This function will initial GD32 board.
  49. */
  50. void rt_hw_board_init()
  51. {
  52. /* NVIC Configuration */
  53. #define NVIC_VTOR_MASK 0x3FFFFF80
  54. #ifdef VECT_TAB_RAM
  55. /* Set the Vector Table base location at 0x10000000 */
  56. SCB->VTOR = (0x10000000 & NVIC_VTOR_MASK);
  57. #else /* VECT_TAB_FLASH */
  58. /* Set the Vector Table base location at 0x08000000 */
  59. SCB->VTOR = (0x08000000 & NVIC_VTOR_MASK);
  60. #endif
  61. SystemClock_Config();
  62. #ifdef RT_USING_COMPONENTS_INIT
  63. rt_components_board_init();
  64. #endif
  65. #ifdef RT_USING_CONSOLE
  66. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  67. #endif
  68. #ifdef BSP_USING_SDRAM
  69. rt_system_heap_init((void *)EXT_SDRAM_BEGIN, (void *)EXT_SDRAM_END);
  70. #else
  71. rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
  72. #endif
  73. }
  74. /*@}*/