board.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright (c) 2006-2018, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2009-01-05 Bernard first implementation
  9. * 2018-08-17 whj add to new rt_console_set_device
  10. */
  11. #include <rthw.h>
  12. #include <rtthread.h>
  13. #include "board.h"
  14. #include "usart.h"
  15. /**
  16. * @addtogroup STM32
  17. */
  18. /*@{*/
  19. /*******************************************************************************
  20. * Function Name : NVIC_Configuration
  21. * Description : Configures Vector Table base location.
  22. * Input : None
  23. * Output : None
  24. * Return : None
  25. *******************************************************************************/
  26. void NVIC_Configuration(void)
  27. {
  28. #ifdef VECT_TAB_RAM
  29. /* Set the Vector Table base location at 0x20000000 */
  30. NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);
  31. #else /* VECT_TAB_FLASH */
  32. /* Set the Vector Table base location at 0x08000000 */
  33. NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);
  34. #endif
  35. }
  36. /**
  37. * This is the timer interrupt service routine.
  38. *
  39. */
  40. void SysTick_Handler(void)
  41. {
  42. /* enter interrupt */
  43. rt_interrupt_enter();
  44. rt_tick_increase();
  45. /* leave interrupt */
  46. rt_interrupt_leave();
  47. }
  48. /**
  49. * This function will initial STM32 board.
  50. */
  51. void rt_hw_board_init(void)
  52. {
  53. /* NVIC Configuration */
  54. NVIC_Configuration();
  55. /* Configure the SysTick */
  56. SysTick_Config( SystemCoreClock / RT_TICK_PER_SECOND );
  57. #ifdef RT_USING_HEAP
  58. rt_system_heap_init((void*)STM32_SRAM_BEGIN, (void*)STM32_SRAM_END);
  59. #endif
  60. rt_components_board_init();
  61. rt_hw_usart_init();
  62. #ifdef RT_USING_CONSOLE
  63. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  64. #endif
  65. }
  66. /*@}*/