application.c 2.6 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. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2011-01-13 weety first version
  23. */
  24. /**
  25. * @addtogroup dm365
  26. */
  27. /*@{*/
  28. #include <rtthread.h>
  29. #ifdef RT_USING_DFS
  30. /* dfs Filesystem APIs */
  31. #include <dfs_fs.h>
  32. #endif
  33. #ifdef RT_USING_SDIO
  34. #include <drivers/mmcsd_core.h>
  35. #endif
  36. int main(void)
  37. {
  38. int timeout = 0;
  39. /* Filesystem Initialization */
  40. #ifdef RT_USING_DFS
  41. {
  42. #if defined(RT_USING_DFS_ROMFS)
  43. if (dfs_mount(RT_NULL, "/rom", "rom", 0, &romfs_root) == 0)
  44. {
  45. rt_kprintf("ROM File System initialized!\n");
  46. }
  47. else
  48. rt_kprintf("ROM File System initialzation failed!\n");
  49. #endif
  50. #if defined(RT_USING_DFS_UFFS)
  51. {
  52. /* mount flash device as flash directory */
  53. if(dfs_mount("nand0", "/nand0", "uffs", 0, 0) == 0)
  54. rt_kprintf("UFFS File System initialized!\n");
  55. else
  56. rt_kprintf("UFFS File System initialzation failed!\n");
  57. }
  58. #endif
  59. #ifdef RT_USING_SDIO
  60. timeout = 0;
  61. while ((rt_device_find("sd0") == RT_NULL) && (timeout++ < RT_TICK_PER_SECOND*2))
  62. {
  63. rt_thread_delay(1);
  64. }
  65. if (timeout < RT_TICK_PER_SECOND*2)
  66. {
  67. /* mount sd card fat partition 1 as root directory */
  68. if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
  69. {
  70. rt_kprintf("File System initialized!\n");
  71. }
  72. else
  73. rt_kprintf("File System initialzation failed!%d\n", rt_get_errno());
  74. }
  75. else
  76. {
  77. rt_kprintf("No SD card found.\n");
  78. }
  79. #endif
  80. }
  81. #endif
  82. /* put user application code here */
  83. }
  84. /* NFSv3 Initialization */
  85. #if defined(RT_USING_DFS) && defined(RT_USING_LWIP) && defined(RT_USING_DFS_NFS)
  86. #include <dfs_nfs.h>
  87. void nfs_start(void)
  88. {
  89. nfs_init();
  90. if (dfs_mount(RT_NULL, "/nfs", "nfs", 0, RT_NFS_HOST_EXPORT) == 0)
  91. {
  92. rt_kprintf("NFSv3 File System initialized!\n");
  93. }
  94. else
  95. rt_kprintf("NFSv3 File System initialzation failed!\n");
  96. }
  97. #include "finsh.h"
  98. FINSH_FUNCTION_EXPORT(nfs_start, start net filesystem);
  99. #endif
  100. /*@}*/