application.c 2.8 KB

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