startup.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * File : startup.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2015, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2006-08-31 Bernard first implementation
  23. * 2015-08-01 xiaonong modify for STM32F7 version
  24. */
  25. #include <rthw.h>
  26. #include <rtthread.h>
  27. #include "board.h"
  28. #ifdef RT_USING_EXT_SDRAM
  29. #include "drv_sdram.h"
  30. #include "sram.h"
  31. #endif
  32. /**
  33. * @addtogroup STM32
  34. */
  35. /*@{*/
  36. extern int rt_application_init(void);
  37. #ifdef USE_FULL_ASSERT
  38. /**
  39. * @brief assert_failed
  40. * Reports the name of the source file and the source line number
  41. * where the assert_param error has occurred.
  42. * @param File: pointer to the source file name
  43. * @param Line: assert_param error line source number
  44. * @retval None
  45. */
  46. void assert_failed(uint8_t* file, uint32_t line)
  47. {
  48. /* User can add his own implementation to report the file name and line
  49. number,ex: printf("Wrong parameters value: file %s on line %d\r\n",
  50. file, line) */
  51. rt_kprintf("\n\r Wrong parameter value detected on\r\n");
  52. rt_kprintf(" file %s\r\n", file);
  53. rt_kprintf(" line %d\r\n", line);
  54. /* Infinite loop */
  55. while (1)
  56. {}
  57. }
  58. #endif
  59. /**
  60. * This function will startup RT-Thread RTOS.
  61. */
  62. void rtthread_startup(void)
  63. {
  64. /* init board */
  65. rt_hw_board_init();
  66. /* show version */
  67. rt_show_version();
  68. /* init tick */
  69. rt_system_tick_init();
  70. /* init kernel object */
  71. rt_system_object_init();
  72. /* init timer system */
  73. rt_system_timer_init();
  74. #ifdef RT_USING_EXT_SDRAM
  75. sdram_hw_init();
  76. rt_system_heap_init((void*)EXT_SDRAM_BEGIN, (void*)EXT_SDRAM_END);
  77. sram_init();
  78. #else
  79. rt_system_heap_init((void*)HEAP_BEGIN, (void*)HEAP_END);
  80. #endif
  81. /* init scheduler system */
  82. rt_system_scheduler_init();
  83. /* init application */
  84. rt_application_init();
  85. /* init timer thread */
  86. rt_system_timer_thread_init();
  87. /* init idle thread */
  88. rt_thread_idle_init();
  89. /* start scheduler */
  90. rt_system_scheduler_start();
  91. /* never reach here */
  92. return ;
  93. }
  94. int main(void)
  95. {
  96. /* disable interrupt first */
  97. //rt_hw_interrupt_disable();
  98. /* startup RT-Thread RTOS */
  99. rtthread_startup();
  100. return 0;
  101. }
  102. /*@}*/