application.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. #ifdef RT_USING_LWIP
  68. eth_system_device_init();
  69. /* register ethernetif device */
  70. #if STM32_ETH_IF == 0
  71. rt_hw_enc28j60_init();
  72. #elif STM32_ETH_IF == 1
  73. rt_hw_dm9000_init();
  74. #endif
  75. /* re-init device driver */
  76. rt_device_init_all();
  77. #endif
  78. /* init lwip system */
  79. lwip_sys_init();
  80. rt_kprintf("TCP/IP initialized!\n");
  81. }
  82. #endif
  83. }
  84. int rt_application_init()
  85. {
  86. rt_thread_t init_thread;
  87. #if (RT_THREAD_PRIORITY_MAX == 32)
  88. init_thread = rt_thread_create("init",
  89. rt_init_thread_entry, RT_NULL,
  90. 2048, 8, 20);
  91. #else
  92. init_thread = rt_thread_create("init",
  93. rt_init_thread_entry, RT_NULL,
  94. 2048, 80, 20);
  95. #endif
  96. if (init_thread != RT_NULL)
  97. rt_thread_startup(init_thread);
  98. return 0;
  99. }
  100. /*@}*/