application.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * File : application.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2013, 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 <board.h>
  19. #include <rtthread.h>
  20. #ifdef RT_USING_DFS
  21. #include <dfs_fs.h>
  22. #endif
  23. #ifdef RT_USING_COMPONENTS_INIT
  24. #include <components.h>
  25. #endif /* RT_USING_COMPONENTS_INIT */
  26. void rt_init_thread_entry(void* parameter)
  27. {
  28. {
  29. extern void rt_platform_init(void);
  30. rt_platform_init();
  31. }
  32. #ifdef RT_USING_COMPONENTS_INIT
  33. /* initialization RT-Thread Components */
  34. rt_components_init();
  35. #endif
  36. /* Filesystem Initialization */
  37. #if defined(RT_USING_DFS) && defined(RT_USING_DFS_ELMFAT)
  38. {
  39. /* mount sd card fat partition 1 as root directory */
  40. if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
  41. {
  42. rt_kprintf("File System initialized!\n");
  43. }
  44. else
  45. {
  46. rt_kprintf("File System initialzation failed!\n");
  47. }
  48. }
  49. #endif /* RT_USING_DFS && RT_USING_DFS_ELMFAT */
  50. }
  51. int rt_application_init(void)
  52. {
  53. rt_thread_t init_thread;
  54. #if (RT_THREAD_PRIORITY_MAX == 32)
  55. init_thread = rt_thread_create("init",
  56. rt_init_thread_entry, RT_NULL,
  57. 2048, 8, 20);
  58. #else
  59. init_thread = rt_thread_create("init",
  60. rt_init_thread_entry, RT_NULL,
  61. 2048, 80, 20);
  62. #endif
  63. if (init_thread != RT_NULL)
  64. {
  65. rt_thread_startup(init_thread);
  66. }
  67. return 0;
  68. }
  69. /*@}*/