application.c 1.9 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. */
  14. /**
  15. * @addtogroup STM32
  16. */
  17. /*@{*/
  18. #include <board.h>
  19. #include <rtthread.h>
  20. #ifdef RT_USING_DFS
  21. #include <dfs_fs.h>
  22. #include <dfs_init.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. {
  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. #ifdef RT_USING_FINSH
  65. /* initialize finsh */
  66. finsh_system_init();
  67. finsh_set_device(RT_CONSOLE_DEVICE_NAME);
  68. #endif
  69. }
  70. int rt_application_init(void)
  71. {
  72. rt_thread_t tid;
  73. tid = rt_thread_create("init",
  74. rt_init_thread_entry, RT_NULL,
  75. 2048, RT_THREAD_PRIORITY_MAX/3, 20);
  76. if (tid != RT_NULL) rt_thread_startup(tid);
  77. return 0;
  78. }
  79. /*@}*/