board.c 1.8 KB

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