1
0

application.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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_FINSH
  21. #include <shell.h>
  22. #include <finsh.h>
  23. #endif
  24. #ifdef RT_USING_DFS
  25. /* dfs init */
  26. #include <dfs.h>
  27. /* dfs filesystem:ELM filesystem init */
  28. #include <dfs_elm.h>
  29. /* dfs Filesystem APIs */
  30. #include <dfs_fs.h>
  31. #endif
  32. #ifdef RT_USING_LWIP
  33. #include <lwip/sys.h>
  34. #include <lwip/api.h>
  35. #include <netif/ethernetif.h>
  36. #include "stm32f2x7_eth.h"
  37. #endif
  38. void rt_init_thread_entry(void *parameter)
  39. {
  40. /* Filesystem Initialization */
  41. #ifdef RT_USING_DFS
  42. {
  43. /* init sdcard driver */
  44. #if STM32_USE_SDIO
  45. rt_hw_sdcard_init();
  46. #else
  47. rt_hw_msd_init();
  48. #endif
  49. /* init the device filesystem */
  50. dfs_init();
  51. #ifdef RT_USING_DFS_ELMFAT
  52. /* init the elm chan FatFs filesystam*/
  53. elm_init();
  54. /* mount sd card fat partition 1 as root directory */
  55. if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
  56. {
  57. rt_kprintf("File System initialized!\n");
  58. }
  59. else
  60. rt_kprintf("File System initialzation failed!\n");
  61. #endif
  62. }
  63. #endif
  64. /* LwIP Initialization */
  65. #ifdef RT_USING_LWIP
  66. {
  67. extern void lwip_sys_init(void);
  68. /* register ethernetif device */
  69. eth_system_device_init();
  70. /* initialize eth interface */
  71. rt_hw_stm32_eth_init();
  72. /* init lwip system */
  73. lwip_sys_init();
  74. rt_kprintf("TCP/IP initialized!\n");
  75. }
  76. #endif
  77. rt_hw_rtc_init();
  78. #ifdef RT_USING_FINSH
  79. /* init finsh */
  80. finsh_system_init();
  81. #endif
  82. }
  83. int rt_application_init()
  84. {
  85. rt_thread_t tid;
  86. tid = rt_thread_create("init",
  87. rt_init_thread_entry, RT_NULL,
  88. 2048, RT_THREAD_PRIORITY_MAX / 3, 20);
  89. if (tid != RT_NULL)
  90. rt_thread_startup(tid);
  91. return 0;
  92. }
  93. /*@}*/