board.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * File : board.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2009 RT-Thread Develop Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2009-01-05 Bernard first implementation
  13. */
  14. #include <stdint.h>
  15. #include <rthw.h>
  16. #include <rtthread.h>
  17. #include <gd32f4xx.h>
  18. #include <board.h>
  19. #include <drv_usart.h>
  20. /**
  21. * @brief This function is executed in case of error occurrence.
  22. * @param None
  23. * @retval None
  24. */
  25. void Error_Handler(void)
  26. {
  27. /* USER CODE BEGIN Error_Handler */
  28. /* User can add his own implementation to report the HAL error return state */
  29. while (1)
  30. {
  31. }
  32. /* USER CODE END Error_Handler */
  33. }
  34. /** System Clock Configuration
  35. */
  36. void SystemClock_Config(void)
  37. {
  38. SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
  39. NVIC_SetPriority(SysTick_IRQn, 0);
  40. }
  41. /**
  42. * This is the timer interrupt service routine.
  43. *
  44. */
  45. void SysTick_Handler(void)
  46. {
  47. /* enter interrupt */
  48. rt_interrupt_enter();
  49. rt_tick_increase();
  50. /* leave interrupt */
  51. rt_interrupt_leave();
  52. }
  53. /**
  54. * This function will initial GD32 board.
  55. */
  56. void rt_hw_board_init()
  57. {
  58. /* NVIC Configuration */
  59. #define NVIC_VTOR_MASK 0x3FFFFF80
  60. #ifdef VECT_TAB_RAM
  61. /* Set the Vector Table base location at 0x10000000 */
  62. SCB->VTOR = (0x10000000 & NVIC_VTOR_MASK);
  63. #else /* VECT_TAB_FLASH */
  64. /* Set the Vector Table base location at 0x08000000 */
  65. SCB->VTOR = (0x08000000 & NVIC_VTOR_MASK);
  66. #endif
  67. SystemClock_Config();
  68. #ifdef RT_USING_COMPONENTS_INIT
  69. rt_components_board_init();
  70. #endif
  71. #ifdef RT_USING_CONSOLE
  72. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  73. #endif
  74. #ifdef BSP_USING_SDRAM
  75. rt_system_heap_init((void *)EXT_SDRAM_BEGIN, (void *)EXT_SDRAM_END);
  76. #else
  77. rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
  78. #endif
  79. }
  80. /*@}*/