application.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * File : application.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, 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. * 2009-01-05 Bernard the first version
  13. */
  14. #include <rtthread.h>
  15. #include <stdio.h>
  16. #include <board.h>
  17. #include <components.h>
  18. void rt_init_thread_entry(void *parameter)
  19. {
  20. #ifdef RT_USING_LWIP
  21. #ifdef RT_USING_TAPNETIF
  22. tap_netif_hw_init();
  23. #else
  24. pcap_netif_hw_init();
  25. #endif
  26. #endif
  27. rt_platform_init();
  28. /* initialization RT-Thread Components */
  29. rt_components_init();
  30. #ifdef RT_USING_RTGUI
  31. /* start sdl thread to simulate an LCD. SDL may depend on DFS and should be
  32. * called after rt_components_init. */
  33. rt_hw_sdl_start();
  34. #endif /* RT_USING_RTGUI */
  35. #if defined(RT_USING_COMPONENTS_INIT) && defined(__GNUC__) && defined(RT_USING_FINSH)
  36. finsh_set_device(RT_CONSOLE_DEVICE_NAME);
  37. #endif
  38. /* File system Initialization */
  39. #ifdef RT_USING_DFS
  40. {
  41. #ifdef RT_USING_DFS_WINSHAREDIR
  42. {
  43. extern rt_err_t rt_win_sharedir_init(const char *name);
  44. extern int dfs_win32_init(void);
  45. rt_win_sharedir_init("wdd");
  46. dfs_win32_init();
  47. if (dfs_mount("wdd", "/", "wdir", 0, 0) == 0)
  48. rt_kprintf("win32 share directory initialized!\n");
  49. else
  50. rt_kprintf("win32 share directory initialized failed!\n");
  51. }
  52. #endif
  53. #ifdef RT_USING_DFS_ELMFAT
  54. /* mount sd card fatfs as root directory */
  55. #ifdef _WIN32
  56. if (dfs_mount("sd0", "/disk/sd", "elm", 0, 0) == 0)
  57. #else
  58. if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
  59. #endif
  60. rt_kprintf("fatfs initialized!\n");
  61. else
  62. rt_kprintf("fatfs initialization failed!\n");
  63. #endif
  64. #ifdef RT_USING_DFS_UFFS
  65. /* mount uffs as the nand flash file system */
  66. if (dfs_mount("nand0", "/disk/nand", "uffs", 0, 0) == 0)
  67. rt_kprintf("uffs initialized!\n");
  68. else
  69. rt_kprintf("uffs initialization failed!\n");
  70. #endif
  71. #ifdef RT_USING_DFS_JFFS2
  72. /* mount jffs2 as the nor flash file system */
  73. if (dfs_mount("nor", "/disk/nor", "jffs2", 0, 0) == 0)
  74. rt_kprintf("jffs2 initialized!\n");
  75. else
  76. rt_kprintf("jffs2 initialization failed!\n");
  77. #endif
  78. }
  79. #endif
  80. }
  81. static void rt_test_thread_entry(void *parameter)
  82. {
  83. int i;
  84. for (i = 0; i < 5; i++)
  85. {
  86. rt_kprintf("hello, world\n");
  87. rt_thread_delay(RT_TICK_PER_SECOND);
  88. }
  89. }
  90. int rt_application_init()
  91. {
  92. rt_thread_t tid;
  93. tid = rt_thread_create("init",
  94. rt_init_thread_entry, RT_NULL,
  95. 2048, RT_THREAD_PRIORITY_MAX / 3, 20);
  96. if (tid != RT_NULL)
  97. rt_thread_startup(tid);
  98. tid = rt_thread_create("test",
  99. rt_test_thread_entry, RT_NULL,
  100. 2048, RT_THREAD_PRIORITY_MAX * 3 / 4, 20);
  101. if (tid != RT_NULL)
  102. rt_thread_startup(tid);
  103. return 0;
  104. }
  105. /*@}*/