application.c 3.1 KB

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