application.c 2.0 KB

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