application.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2009-01-05 Bernard the first version
  9. */
  10. #include <rtthread.h>
  11. #ifdef RT_USING_DFS
  12. #include <dfs_fs.h>
  13. #include <dfs.h>
  14. #include "floppy.h"
  15. #ifdef RT_USING_MODULE
  16. #include <rtm.h>
  17. #endif
  18. extern int elm_init(void);
  19. #endif
  20. /* components initialization for simulator */
  21. void components_init(void)
  22. {
  23. #ifdef RT_USING_DFS
  24. rt_floppy_init();
  25. /* initialize the device file system */
  26. dfs_init();
  27. #ifdef RT_USING_DFS_ELMFAT
  28. /* initialize the elm chan FatFS file system*/
  29. elm_init();
  30. #endif
  31. #ifdef RT_USING_MODULE
  32. rt_system_dlmodule_init();
  33. #endif
  34. #endif
  35. }
  36. void rt_init_thread_entry(void *parameter)
  37. {
  38. components_init();
  39. /* File system Initialization */
  40. #ifdef RT_USING_DFS
  41. {
  42. #ifdef RT_USING_DFS_ELMFAT
  43. /* mount sd card fatfs as root directory */
  44. if (dfs_mount("floppy", "/", "elm", 0, 0) == 0)
  45. rt_kprintf("fatfs initialized!\n");
  46. else
  47. rt_kprintf("fatfs initialization failed!\n");
  48. #endif
  49. }
  50. #endif
  51. }
  52. int rt_application_init()
  53. {
  54. rt_thread_t tid;
  55. tid = rt_thread_create("init",
  56. rt_init_thread_entry, RT_NULL,
  57. 2048, RT_THREAD_PRIORITY_MAX / 3, 20);
  58. if (tid != RT_NULL)
  59. rt_thread_startup(tid);
  60. return 0;
  61. }