startup.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * File : startup.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2012, RT-Thread Development 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. * 2012-02-13 mojingxian first version
  13. */
  14. #include <rthw.h>
  15. #include <rtthread.h>
  16. #include "application.h"
  17. #include "board.h"
  18. #include "serial.h"
  19. #include "finsh.h"
  20. extern "asm" int rtt_heap_start;
  21. extern "asm" int rtt_heap_end;
  22. extern struct serial_device uart0;
  23. extern struct rt_device uart0_device;
  24. void rtthread_startup(void)
  25. {
  26. /* init hardware interrupt */
  27. rt_hw_interrupt_init();
  28. /* init board */
  29. rt_hw_board_init();
  30. /* show version */
  31. rt_show_version();
  32. /* init tick */
  33. rt_system_tick_init();
  34. /* init kernel object */
  35. rt_system_object_init();
  36. /* init timer system */
  37. rt_system_timer_init();
  38. #ifdef RT_USING_HEAP
  39. rt_system_heap_init((void*)&rtt_heap_start, (void*)&rtt_heap_end);
  40. #endif
  41. #ifdef RT_USING_MODULE
  42. /* init module system*/
  43. rt_system_module_init();
  44. #endif
  45. /* init scheduler system */
  46. rt_system_scheduler_init();
  47. #ifdef RT_USING_DEVICE
  48. /* register uart0 */
  49. rt_hw_serial_register(&uart0_device, "uart0",
  50. RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM,
  51. &uart0);
  52. rt_console_set_device("uart0");
  53. #endif
  54. /* init application */
  55. rt_application_init();
  56. #ifdef RT_USING_FINSH
  57. /* init finsh */
  58. extern int finsh_system_init(void);
  59. finsh_system_init();
  60. finsh_set_device("uart0");
  61. #endif
  62. rt_system_timer_thread_init();
  63. /* init idle thread */
  64. rt_thread_idle_init();
  65. /* start scheduler */
  66. rt_system_scheduler_start();
  67. /* never reach here */
  68. return ;
  69. }
  70. int main(void)
  71. {
  72. /* disable interrupt first */
  73. rt_hw_interrupt_disable();
  74. /* startup RT-Thread RTOS */
  75. rtthread_startup();
  76. return 0;
  77. }