application.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 "stm32f2x7_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. /* mount sd card fat partition 1 as root directory */
  45. if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
  46. {
  47. rt_kprintf("File System initialized!\n");
  48. }
  49. else
  50. rt_kprintf("File System initialzation failed!\n");
  51. #endif
  52. }
  53. #endif
  54. /* LwIP Initialization */
  55. #ifdef RT_USING_LWIP
  56. {
  57. extern void lwip_sys_init(void);
  58. /* register ethernetif device */
  59. eth_system_device_init();
  60. /* initialize eth interface */
  61. rt_hw_stm32_eth_init();
  62. /* init lwip system */
  63. lwip_sys_init();
  64. rt_kprintf("TCP/IP initialized!\n");
  65. }
  66. #endif
  67. }
  68. int rt_application_init()
  69. {
  70. rt_thread_t tid;
  71. tid = rt_thread_create("init",
  72. rt_init_thread_entry, RT_NULL,
  73. 2048, RT_THREAD_PRIORITY_MAX/3, 20);
  74. if (tid != RT_NULL)
  75. rt_thread_startup(tid);
  76. return 0;
  77. }
  78. /*@}*/