application.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. rt_mmcsd_core_init();
  61. rt_mmcsd_blk_init();
  62. rt_hw_mmcsd_init();
  63. timeout = 0;
  64. while ((rt_device_find("sd0") == RT_NULL) && (timeout++ < RT_TICK_PER_SECOND*2))
  65. {
  66. rt_thread_delay(1);
  67. }
  68. if (timeout < RT_TICK_PER_SECOND*2)
  69. {
  70. /* mount sd card fat partition 1 as root directory */
  71. if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
  72. {
  73. rt_kprintf("File System initialized!\n");
  74. }
  75. else
  76. rt_kprintf("File System initialzation failed!%d\n", rt_get_errno());
  77. }
  78. else
  79. {
  80. rt_kprintf("No SD card found.\n");
  81. }
  82. #endif
  83. }
  84. #endif
  85. /* put user application code here */
  86. }
  87. /* NFSv3 Initialization */
  88. #if defined(RT_USING_DFS) && defined(RT_USING_LWIP) && defined(RT_USING_DFS_NFS)
  89. #include <dfs_nfs.h>
  90. void nfs_start(void)
  91. {
  92. nfs_init();
  93. if (dfs_mount(RT_NULL, "/nfs", "nfs", 0, RT_NFS_HOST_EXPORT) == 0)
  94. {
  95. rt_kprintf("NFSv3 File System initialized!\n");
  96. }
  97. else
  98. rt_kprintf("NFSv3 File System initialzation failed!\n");
  99. }
  100. #include "finsh.h"
  101. FINSH_FUNCTION_EXPORT(nfs_start, start net filesystem);
  102. #endif
  103. /*@}*/