application.c 2.9 KB

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