application.c 3.0 KB

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