1
0

application.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * Copyright (c) 2006-2018, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2009-01-05 Bernard the first version
  9. */
  10. /**
  11. * @addtogroup STM32
  12. */
  13. /*@{*/
  14. #include <board.h>
  15. #include <rtthread.h>
  16. #ifdef RT_USING_FINSH
  17. #include <shell.h>
  18. #include <finsh.h>
  19. #endif
  20. #ifdef RT_USING_DFS
  21. /* dfs init */
  22. #include <dfs.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 sdcard driver */
  40. #if STM32_USE_SDIO
  41. rt_hw_sdcard_init();
  42. #else
  43. rt_hw_msd_init();
  44. #endif
  45. /* init the device filesystem */
  46. dfs_init();
  47. #ifdef RT_USING_DFS_ELMFAT
  48. /* init the elm chan FatFs filesystam*/
  49. elm_init();
  50. /* mount sd card fat partition 1 as root directory */
  51. if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
  52. {
  53. rt_kprintf("File System initialized!\n");
  54. }
  55. else
  56. rt_kprintf("File System initialzation failed!\n");
  57. #endif
  58. }
  59. #endif
  60. /* LwIP Initialization */
  61. #ifdef RT_USING_LWIP
  62. {
  63. extern void lwip_sys_init(void);
  64. /* register ethernetif device */
  65. eth_system_device_init();
  66. /* initialize eth interface */
  67. rt_hw_stm32_eth_init();
  68. /* init lwip system */
  69. lwip_sys_init();
  70. rt_kprintf("TCP/IP initialized!\n");
  71. }
  72. #endif
  73. rt_hw_rtc_init();
  74. #ifdef RT_USING_FINSH
  75. /* init finsh */
  76. finsh_system_init();
  77. #endif
  78. }
  79. int rt_application_init()
  80. {
  81. rt_thread_t tid;
  82. tid = rt_thread_create("init",
  83. rt_init_thread_entry, RT_NULL,
  84. 2048, RT_THREAD_PRIORITY_MAX / 3, 20);
  85. if (tid != RT_NULL)
  86. rt_thread_startup(tid);
  87. return 0;
  88. }
  89. /*@}*/