application.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * File : application.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2015, 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. * 2009-01-05 Bernard the first version
  23. */
  24. #include <rtthread.h>
  25. #include <stdio.h>
  26. #include <board.h>
  27. #ifdef RT_USING_DFS
  28. #include <dfs_fs.h>
  29. #endif
  30. #include "init.h"
  31. void rt_init_thread_entry(void *parameter)
  32. {
  33. components_init();
  34. /* File system Initialization */
  35. #ifdef RT_USING_DFS
  36. {
  37. #ifdef RT_USING_DFS_WINSHAREDIR
  38. {
  39. extern rt_err_t rt_win_sharedir_init(const char *name);
  40. extern int dfs_win32_init(void);
  41. rt_win_sharedir_init("wdd");
  42. dfs_win32_init();
  43. if (dfs_mount("wdd", "/", "wdir", 0, 0) == 0)
  44. rt_kprintf("win32 share directory initialized!\n");
  45. else
  46. rt_kprintf("win32 share directory initialized failed!\n");
  47. }
  48. #endif
  49. #ifdef RT_USING_DFS_ELMFAT
  50. /* mount sd card fatfs as root directory */
  51. #ifdef _WIN32
  52. if (dfs_mount("sd0", "/disk/sd", "elm", 0, 0) == 0)
  53. #else
  54. if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
  55. #endif
  56. rt_kprintf("fatfs initialized!\n");
  57. else
  58. rt_kprintf("fatfs initialization failed!\n");
  59. #endif
  60. #ifdef RT_USING_DFS_UFFS
  61. /* mount uffs as the nand flash file system */
  62. if (dfs_mount("nand0", "/disk/nand", "uffs", 0, 0) == 0)
  63. rt_kprintf("uffs initialized!\n");
  64. else
  65. rt_kprintf("uffs initialization failed!\n");
  66. #endif
  67. #ifdef RT_USING_DFS_JFFS2
  68. /* mount jffs2 as the nor flash file system */
  69. if (dfs_mount("nor", "/disk/nor", "jffs2", 0, 0) == 0)
  70. rt_kprintf("jffs2 initialized!\n");
  71. else
  72. rt_kprintf("jffs2 initialization failed!\n");
  73. #endif
  74. }
  75. #endif
  76. }
  77. int rt_application_init()
  78. {
  79. rt_thread_t tid;
  80. tid = rt_thread_create("init",
  81. rt_init_thread_entry, RT_NULL,
  82. 2048, RT_THREAD_PRIORITY_MAX / 3, 20);
  83. if (tid != RT_NULL)
  84. rt_thread_startup(tid);
  85. return 0;
  86. }