application.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. /**
  15. * @addtogroup STM32
  16. */
  17. /*@{*/
  18. #include <rtthread.h>
  19. #ifdef RT_USING_DFS
  20. /* dfs init */
  21. #include <dfs_init.h>
  22. /* dfs filesystem:EFS filesystem init */
  23. #include <dfs_efs.h>
  24. /* dfs filesystem:ELM FatFs filesystem init */
  25. #include <dfs_elm.h>
  26. /* dfs Filesystem APIs */
  27. #include <dfs_fs.h>
  28. #endif
  29. void rt_init_thread_entry(void* parameter)
  30. {
  31. /* Filesystem Initialization */
  32. #ifdef RT_USING_DFS
  33. {
  34. /* init the device filesystem */
  35. dfs_init();
  36. #ifdef RT_USING_DFS_EFSL
  37. /* init the efsl filesystam*/
  38. efsl_init();
  39. /* mount sd card fat partition 1 as root directory */
  40. if (dfs_mount("sd0", "/", "efs", 0, 0) == 0)
  41. rt_kprintf("File System initialized!\n");
  42. else
  43. rt_kprintf("File System init failed!\n");
  44. #elif defined(RT_USING_DFS_ELMFAT)
  45. /* init the elm FAT filesystam*/
  46. elm_init();
  47. /* mount sd card fat partition 1 as root directory */
  48. if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
  49. rt_kprintf("File System initialized!\n");
  50. else
  51. rt_kprintf("File System init failed!\n");
  52. #endif
  53. }
  54. #endif
  55. }
  56. int rt_application_init()
  57. {
  58. rt_thread_t init_thread;
  59. #if (RT_THREAD_PRIORITY_MAX == 32)
  60. init_thread = rt_thread_create("init",
  61. rt_init_thread_entry, RT_NULL,
  62. 2048, 8, 20);
  63. #else
  64. init_thread = rt_thread_create("init",
  65. rt_init_thread_entry, RT_NULL,
  66. 2048, 80, 20);
  67. #endif
  68. if (init_thread != RT_NULL)
  69. rt_thread_startup(init_thread);
  70. return 0;
  71. }
  72. /*@}*/