1
0

application.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. * 2018-08-17 whj remove finsh_set_device add components
  10. */
  11. /**
  12. * @addtogroup STM32
  13. */
  14. /*@{*/
  15. #include <board.h>
  16. #include <rtthread.h>
  17. #ifdef RT_USING_DFS
  18. #include <dfs_fs.h>
  19. #include <dfs_elm.h>
  20. #endif
  21. #ifdef RT_USING_LWIP
  22. #include <stm32_eth.h>
  23. #include <netif/ethernetif.h>
  24. extern int lwip_system_init(void);
  25. #endif
  26. #ifdef RT_USING_FINSH
  27. #include <shell.h>
  28. #include <finsh.h>
  29. #endif
  30. void rt_init_thread_entry(void* parameter)
  31. {
  32. #ifdef RT_USING_COMPONENTS_INIT
  33. /* initialization RT-Thread Components */
  34. rt_components_init();
  35. #endif
  36. {
  37. extern void rt_platform_init(void);
  38. rt_platform_init();
  39. }
  40. /* Filesystem Initialization */
  41. #if defined(RT_USING_DFS) && defined(RT_USING_DFS_ELMFAT)
  42. /* initialize the device file system */
  43. dfs_init();
  44. /* initialize the elm chan FatFS file system*/
  45. elm_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. {
  53. rt_kprintf("File System initialzation failed!\n");
  54. }
  55. #endif /* RT_USING_DFS && RT_USING_DFS_ELMFAT */
  56. #ifdef RT_USING_LWIP
  57. /* initialize lwip stack */
  58. /* register ethernetif device */
  59. eth_system_device_init();
  60. /* initialize lwip system */
  61. lwip_system_init();
  62. rt_kprintf("TCP/IP initialized!\n");
  63. #endif
  64. }
  65. int rt_application_init(void)
  66. {
  67. rt_thread_t tid;
  68. tid = rt_thread_create("init",
  69. rt_init_thread_entry, RT_NULL,
  70. 2048, RT_THREAD_PRIORITY_MAX/3, 20);
  71. if (tid != RT_NULL) rt_thread_startup(tid);
  72. return 0;
  73. }
  74. /*@}*/