1
0

board.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * Copyright (c) 2006-2025, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. */
  7. #include <rthw.h>
  8. #include <rtthread.h>
  9. #include "board.h"
  10. #include "gd32e23x.h"
  11. #ifdef RT_USING_SERIAL
  12. #if defined(RT_USING_SERIAL_V2)
  13. #include "drv_usart_v2.h"
  14. #else
  15. #include "drv_usart.h"
  16. #endif
  17. #endif
  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. rt_kprintf("\nError_Handler triggered! System halted.\n");
  26. while (1)
  27. {
  28. }
  29. }
  30. /**
  31. * @brief This is the timer interrupt service routine.
  32. *
  33. */
  34. void SysTick_Handler(void)
  35. {
  36. /* enter interrupt */
  37. rt_interrupt_enter();
  38. rt_tick_increase();
  39. /* leave interrupt */
  40. rt_interrupt_leave();
  41. }
  42. /**
  43. * @brief This function will initial GD32 board.
  44. * @note This function is called from the RT-Thread startup code.
  45. */
  46. void rt_hw_board_init(void)
  47. {
  48. #ifdef VECT_TAB_RAM
  49. SCB->VTOR = 0x20000000;
  50. #else /* VECT_TAB_FLASH is the default */
  51. SCB->VTOR = 0x08000000;
  52. #endif
  53. SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
  54. NVIC_SetPriority(SysTick_IRQn, (1 << __NVIC_PRIO_BITS) - 1);
  55. #ifdef RT_USING_HEAP
  56. rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
  57. #endif
  58. #ifdef RT_USING_SERIAL
  59. rt_hw_usart_init();
  60. #endif
  61. #ifdef RT_USING_CONSOLE
  62. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  63. #endif
  64. #ifdef RT_USING_COMPONENTS_INIT
  65. rt_components_board_init();
  66. #endif
  67. }