application.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * File : app.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, 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://openlab.rt-thread.com/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2007-11-20 Yi.Qiu add rtgui application
  13. * 2008-6-28 Bernard no rtgui init
  14. */
  15. /**
  16. * @addtogroup mini2440
  17. */
  18. /*@{*/
  19. #include <board.h>
  20. #include <rtthread.h>
  21. #ifdef RT_USING_DFS
  22. /* dfs init */
  23. #include <dfs_init.h>
  24. /* dfs filesystem:EFS filesystem init */
  25. #include <dfs_efs.h>
  26. /* dfs Filesystem APIs */
  27. #include <dfs_fs.h>
  28. #endif
  29. #ifdef RT_USING_LWIP
  30. #include <netif/ethernetif.h>
  31. #endif
  32. void rt_init_thread_entry(void* parameter)
  33. {
  34. /* Filesystem Initialization */
  35. #ifdef RT_USING_DFS
  36. {
  37. /* init the device filesystem */
  38. dfs_init();
  39. #ifdef RT_USING_DFS_EFSL
  40. /* init the efsl filesystam*/
  41. efsl_init();
  42. /* mount sd card fat partition 1 as root directory */
  43. if (dfs_mount("sd0", "/", "efs", 0, 0) == 0)
  44. {
  45. rt_kprintf("File System initialized!\n");
  46. }
  47. else
  48. rt_kprintf("File System initialzation failed!\n");
  49. #elif defined(RT_USING_DFS_ELMFAT)
  50. /* init the elm chan FatFs filesystam*/
  51. elm_init();
  52. /* mount sd card fat partition 1 as root directory */
  53. if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
  54. {
  55. rt_kprintf("File System initialized!\n");
  56. }
  57. else
  58. rt_kprintf("File System initialzation failed!\n");
  59. #endif
  60. }
  61. #endif
  62. /* LwIP Initialization */
  63. #ifdef RT_USING_LWIP
  64. {
  65. extern void lwip_sys_init(void);
  66. eth_system_device_init();
  67. /* register ethernetif device */
  68. rt_hw_dm9000_init();
  69. /* re-init device driver */
  70. rt_device_init_all();
  71. /* init lwip system */
  72. lwip_sys_init();
  73. rt_kprintf("TCP/IP initialized!\n");
  74. }
  75. #endif
  76. }
  77. int rt_application_init()
  78. {
  79. rt_thread_t init_thread;
  80. #if (RT_THREAD_PRIORITY_MAX == 32)
  81. init_thread = rt_thread_create("init",
  82. rt_init_thread_entry, RT_NULL,
  83. 2048, 8, 20);
  84. #else
  85. init_thread = rt_thread_create("init",
  86. rt_init_thread_entry, RT_NULL,
  87. 2048, 80, 20);
  88. #endif
  89. if (init_thread != RT_NULL)
  90. rt_thread_startup(init_thread);
  91. return 0;
  92. }
  93. /*@}*/