board.c 1.8 KB

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