application.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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:ELM filesystem init */
  24. #include <dfs_elm.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. #include "stm32_eth.h"
  33. #endif
  34. void rt_init_thread_entry(void* parameter)
  35. {
  36. /* Filesystem Initialization */
  37. #ifdef RT_USING_DFS
  38. {
  39. /* init the device filesystem */
  40. dfs_init();
  41. #ifdef RT_USING_DFS_ELMFAT
  42. /* init the elm chan FatFs filesystam*/
  43. elm_init();
  44. /* init sdcard driver */
  45. rt_hw_msd_init();
  46. /* mount sd card fat partition 1 as root directory */
  47. if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
  48. {
  49. rt_kprintf("File System initialized!\n");
  50. }
  51. else
  52. rt_kprintf("File System initialzation failed!\n");
  53. #endif
  54. }
  55. #endif
  56. /* LwIP Initialization */
  57. #ifdef RT_USING_LWIP
  58. {
  59. extern void lwip_sys_init(void);
  60. /* register ethernetif device */
  61. eth_system_device_init();
  62. rt_hw_stm32_eth_init();
  63. /* re-init device driver */
  64. rt_device_init_all();
  65. /* init lwip system */
  66. lwip_sys_init();
  67. rt_kprintf("TCP/IP initialized!\n");
  68. }
  69. #endif
  70. }
  71. int rt_application_init()
  72. {
  73. rt_thread_t init_thread;
  74. #if (RT_THREAD_PRIORITY_MAX == 32)
  75. init_thread = rt_thread_create("init",
  76. rt_init_thread_entry, RT_NULL,
  77. 2048, 8, 20);
  78. #else
  79. init_thread = rt_thread_create("init",
  80. rt_init_thread_entry, RT_NULL,
  81. 2048, 80, 20);
  82. #endif
  83. if (init_thread != RT_NULL)
  84. rt_thread_startup(init_thread);
  85. return 0;
  86. }
  87. /*@}*/