startup.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * File : startup.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2017, 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. * 2012-09-03 prife first implementation
  23. */
  24. #include <rthw.h>
  25. #include <rtthread.h>
  26. #include "board.h"
  27. /**
  28. * @addtogroup win32
  29. */
  30. /*@{*/
  31. extern int rt_application_init(void);
  32. extern rt_uint8_t *heap;
  33. /**
  34. * This function will startup RT-Thread RTOS.
  35. */
  36. void rtthread_startup(void)
  37. {
  38. /* init board */
  39. rt_hw_board_init();
  40. /* show version */
  41. rt_show_version();
  42. /* init timer system */
  43. rt_system_timer_init();
  44. #ifdef RT_USING_HEAP
  45. /* init memory system */
  46. rt_system_heap_init((void *)heap, (void *)&heap[RT_HEAP_SIZE - 1]);
  47. #endif
  48. /* init scheduler system */
  49. rt_system_scheduler_init();
  50. /* init application */
  51. rt_application_init();
  52. /* init timer thread */
  53. rt_system_timer_thread_init();
  54. /* init idle thread */
  55. rt_thread_idle_init();
  56. /* start scheduler */
  57. rt_system_scheduler_start();
  58. /* never reach here */
  59. return ;
  60. }
  61. int main(void)
  62. {
  63. /* disable interrupt first */
  64. rt_hw_interrupt_disable();
  65. /* startup RT-Thread RTOS */
  66. rtthread_startup();
  67. return 0;
  68. }
  69. /*@}*/