board.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. * 2018-11-06 balanceTWK first version
  9. */
  10. #include <stdint.h>
  11. #include <rthw.h>
  12. #include <rtthread.h>
  13. #include <at32f4xx.h>
  14. #include <board.h>
  15. #ifdef BSP_USING_SRAM
  16. #include "drv_sram.h"
  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. /* 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 AT32 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 BSP_USING_SRAM
  73. rt_system_heap_init((void *)EXT_SRAM_BEGIN, (void *)EXT_SRAM_END);
  74. #else
  75. rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
  76. #endif
  77. }