1
0

board.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 <board.h>
  18. /**
  19. * @brief This function is executed in case of error occurrence.
  20. * @param None
  21. * @retval None
  22. */
  23. void Error_Handler(void)
  24. {
  25. /* USER CODE BEGIN Error_Handler */
  26. /* User can add his own implementation to report the HAL error return state */
  27. while (1)
  28. {
  29. }
  30. /* USER CODE END Error_Handler */
  31. }
  32. /** System Clock Configuration
  33. */
  34. void SystemClock_Config(void)
  35. {
  36. SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
  37. NVIC_SetPriority(SysTick_IRQn, 0);
  38. }
  39. /**
  40. * This is the timer interrupt service routine.
  41. *
  42. */
  43. void SysTick_Handler(void)
  44. {
  45. /* enter interrupt */
  46. rt_interrupt_enter();
  47. rt_tick_increase();
  48. /* leave interrupt */
  49. rt_interrupt_leave();
  50. }
  51. /**
  52. * This function will initial GD32 board.
  53. */
  54. void rt_hw_board_init()
  55. {
  56. /* NVIC Configuration */
  57. #define NVIC_VTOR_MASK 0x3FFFFF80
  58. #ifdef VECT_TAB_RAM
  59. /* Set the Vector Table base location at 0x10000000 */
  60. SCB->VTOR = (0x10000000 & NVIC_VTOR_MASK);
  61. #else /* VECT_TAB_FLASH */
  62. /* Set the Vector Table base location at 0x08000000 */
  63. SCB->VTOR = (0x08000000 & NVIC_VTOR_MASK);
  64. #endif
  65. SystemClock_Config();
  66. #ifdef RT_USING_COMPONENTS_INIT
  67. rt_components_board_init();
  68. #endif
  69. #ifdef RT_USING_CONSOLE
  70. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  71. #endif
  72. #ifdef RT_USING_HEAP
  73. rt_system_heap_init((void*)HEAP_BEGIN, (void*)HEAP_END);
  74. #endif
  75. }
  76. /*@}*/