application.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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_elm.h>
  23. #endif
  24. #ifdef RT_USING_LWIP
  25. #include <stm32_eth.h>
  26. #include <netif/ethernetif.h>
  27. extern int lwip_system_init(void);
  28. #endif
  29. #ifdef RT_USING_FINSH
  30. #include <shell.h>
  31. #include <finsh.h>
  32. #endif
  33. void rt_init_thread_entry(void* parameter)
  34. {
  35. {
  36. extern void rt_platform_init(void);
  37. rt_platform_init();
  38. }
  39. /* Filesystem Initialization */
  40. #if defined(RT_USING_DFS) && defined(RT_USING_DFS_ELMFAT)
  41. /* initialize the device file system */
  42. dfs_init();
  43. /* initialize the elm chan FatFS file system*/
  44. elm_init();
  45. /* mount sd card fat partition 1 as root directory */
  46. if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
  47. {
  48. rt_kprintf("File System initialized!\n");
  49. }
  50. else
  51. {
  52. rt_kprintf("File System initialzation failed!\n");
  53. }
  54. #endif /* RT_USING_DFS && RT_USING_DFS_ELMFAT */
  55. #ifdef RT_USING_LWIP
  56. /* initialize lwip stack */
  57. /* register ethernetif device */
  58. eth_system_device_init();
  59. /* initialize lwip system */
  60. lwip_system_init();
  61. rt_kprintf("TCP/IP initialized!\n");
  62. #endif
  63. #ifdef RT_USING_FINSH
  64. /* initialize finsh */
  65. finsh_system_init();
  66. finsh_set_device(RT_CONSOLE_DEVICE_NAME);
  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. /*@}*/