application.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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 <board.h>
  19. #include <rtthread.h>
  20. #ifdef RT_USING_DFS
  21. /* dfs init */
  22. #include <dfs_init.h>
  23. /* dfs filesystem:EFS filesystem init */
  24. #include <dfs_efs.h>
  25. /* dfs Filesystem APIs */
  26. #include <dfs_fs.h>
  27. #endif
  28. #ifdef RT_USING_LWIP
  29. #include <lwip/sys.h>
  30. #include <lwip/api.h>
  31. #include <netif/ethernetif.h>
  32. #endif
  33. void rt_init_thread_entry(void* parameter)
  34. {
  35. /* Filesystem Initialization */
  36. #ifdef RT_USING_DFS
  37. {
  38. /* init the device filesystem */
  39. dfs_init();
  40. #ifdef RT_USING_DFS_EFSL
  41. /* init the efsl filesystam*/
  42. efsl_init();
  43. /* mount sd card fat partition 1 as root directory */
  44. if (dfs_mount("sd0", "/", "efs", 0, 0) == 0)
  45. {
  46. rt_kprintf("File System initialized!\n");
  47. }
  48. else
  49. rt_kprintf("File System initialzation failed!\n");
  50. #elif defined(RT_USING_DFS_ELMFAT)
  51. /* init the elm chan FatFs filesystam*/
  52. elm_init();
  53. /* mount sd card fat partition 1 as root directory */
  54. if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
  55. {
  56. rt_kprintf("File System initialized!\n");
  57. }
  58. else
  59. rt_kprintf("File System initialzation failed!\n");
  60. #endif
  61. }
  62. #endif
  63. /* LwIP Initialization */
  64. #ifdef RT_USING_LWIP
  65. {
  66. extern void lwip_sys_init(void);
  67. /* register ethernetif device */
  68. eth_system_device_init();
  69. #ifdef STM32F10X_CL
  70. rt_hw_stm32_eth_init();
  71. #else
  72. /* STM32F103 */
  73. #if STM32_ETH_IF == 0
  74. rt_hw_enc28j60_init();
  75. #elif STM32_ETH_IF == 1
  76. rt_hw_dm9000_init();
  77. #endif
  78. #endif
  79. /* re-init device driver */
  80. rt_device_init_all();
  81. /* init lwip system */
  82. lwip_sys_init();
  83. rt_kprintf("TCP/IP initialized!\n");
  84. }
  85. #endif
  86. }
  87. int rt_application_init()
  88. {
  89. rt_thread_t init_thread;
  90. #if (RT_THREAD_PRIORITY_MAX == 32)
  91. init_thread = rt_thread_create("init",
  92. rt_init_thread_entry, RT_NULL,
  93. 2048, 8, 20);
  94. #else
  95. init_thread = rt_thread_create("init",
  96. rt_init_thread_entry, RT_NULL,
  97. 2048, 80, 20);
  98. #endif
  99. if (init_thread != RT_NULL)
  100. rt_thread_startup(init_thread);
  101. return 0;
  102. }
  103. /*@}*/