board.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021-01-04 iysheng first version
  9. */
  10. #include <stdint.h>
  11. #include <rthw.h>
  12. #include <rtthread.h>
  13. #include <gd32f10x.h>
  14. #include <board.h>
  15. #include <drv_usart.h>
  16. /*
  17. * System Clock Configuration
  18. */
  19. void SystemClock_Config(void)
  20. {
  21. SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
  22. NVIC_SetPriority(SysTick_IRQn, 0);
  23. }
  24. /*
  25. * This is the timer interrupt service routine.
  26. */
  27. void SysTick_Handler(void)
  28. {
  29. /* enter interrupt */
  30. rt_interrupt_enter();
  31. rt_tick_increase();
  32. /* leave interrupt */
  33. rt_interrupt_leave();
  34. }
  35. /**
  36. * This function will initial GD32 board.
  37. */
  38. void rt_hw_board_init()
  39. {
  40. /* NVIC Configuration */
  41. #define NVIC_VTOR_MASK 0x3FFFFF80
  42. #ifdef VECT_TAB_RAM
  43. /* Set the Vector Table base location at 0x10000000 */
  44. SCB->VTOR = (0x10000000 & NVIC_VTOR_MASK);
  45. #else /* VECT_TAB_FLASH */
  46. /* Set the Vector Table base location at 0x08000000 */
  47. SCB->VTOR = (0x08000000 & NVIC_VTOR_MASK);
  48. #endif
  49. SystemClock_Config();
  50. #ifdef RT_USING_COMPONENTS_INIT
  51. rt_components_board_init();
  52. #endif
  53. #ifdef RT_USING_CONSOLE
  54. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  55. #endif
  56. #ifdef BSP_USING_SDRAM
  57. rt_system_heap_init((void *)EXT_SDRAM_BEGIN, (void *)EXT_SDRAM_END);
  58. #else
  59. rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
  60. #endif
  61. }
  62. /*@}*/