application.c 1.6 KB

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