application.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. /* 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. #ifdef _WIN32
  44. if (dfs_mount("sd0", "/disk/sd", "elm", 0, 0) == 0)
  45. #else
  46. if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
  47. #endif
  48. rt_kprintf("fatfs initialized!\n");
  49. else
  50. rt_kprintf("fatfs initialization failed!\n");
  51. #endif
  52. #ifdef RT_USING_DFS_UFFS
  53. /* mount uffs as the nand flash file system */
  54. if (dfs_mount("nand0", "/disk/nand", "uffs", 0, 0) == 0)
  55. rt_kprintf("uffs initialized!\n");
  56. else
  57. rt_kprintf("uffs initialization failed!\n");
  58. #endif
  59. #ifdef RT_USING_DFS_JFFS2
  60. /* mount jffs2 as the nor flash file system */
  61. if (dfs_mount("nor", "/disk/nor", "jffs2", 0, 0) == 0)
  62. rt_kprintf("jffs2 initialized!\n");
  63. else
  64. rt_kprintf("jffs2 initialization failed!\n");
  65. #endif
  66. }
  67. #endif
  68. }
  69. static void rt_test_thread_entry(void *parameter)
  70. {
  71. int i;
  72. for (i = 0; i < 5; i++)
  73. {
  74. rt_kprintf("hello, world\n");
  75. rt_thread_delay(RT_TICK_PER_SECOND);
  76. }
  77. }
  78. int rt_application_init()
  79. {
  80. rt_thread_t tid;
  81. tid = rt_thread_create("init",
  82. rt_init_thread_entry, RT_NULL,
  83. 2048, RT_THREAD_PRIORITY_MAX / 3, 20);
  84. if (tid != RT_NULL)
  85. rt_thread_startup(tid);
  86. tid = rt_thread_create("test",
  87. rt_test_thread_entry, RT_NULL,
  88. 2048, RT_THREAD_PRIORITY_MAX * 3 / 4, 20);
  89. if (tid != RT_NULL)
  90. rt_thread_startup(tid);
  91. return 0;
  92. }
  93. /*@}*/