application.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. * 2009-01-05 Bernard the first version
  13. */
  14. /**
  15. * @addtogroup LM3S
  16. */
  17. /*@{*/
  18. #include <rthw.h>
  19. #include <rtthread.h>
  20. #ifdef RT_USING_DFS
  21. /* dfs init */
  22. #include <dfs.h>
  23. /* dfs filesystem:ELM FatFs filesystem init */
  24. #include <dfs_elm.h>
  25. /* dfs Filesystem APIs */
  26. #include <dfs_fs.h>
  27. #endif
  28. #ifdef RT_USING_LWIP
  29. #include <lwip/sys.h>
  30. #include <lwip/api.h>
  31. #endif
  32. /* thread phase init */
  33. void rt_init_thread_entry(void *parameter)
  34. {
  35. /* Filesystem Initialization */
  36. #ifdef RT_USING_DFS
  37. {
  38. /* init the device filesystem */
  39. dfs_init();
  40. #ifdef RT_USING_DFS_ELMFAT
  41. /* init the elm chan FatFs filesystam*/
  42. elm_init();
  43. /* mount sd card fat partition 1 as root directory */
  44. if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
  45. {
  46. rt_kprintf("File System initialized!\n");
  47. }
  48. else
  49. rt_kprintf("File System initialzation failed!\n");
  50. #endif
  51. }
  52. #endif
  53. /* LwIP Initialization */
  54. #ifdef RT_USING_LWIP
  55. {
  56. extern void lwip_sys_init(void);
  57. /* init lwip system */
  58. lwip_sys_init();
  59. rt_kprintf("TCP/IP initialized!\n");
  60. }
  61. #endif
  62. }
  63. int rt_application_init()
  64. {
  65. rt_thread_t init_thread;
  66. init_thread = rt_thread_create("init",
  67. rt_init_thread_entry, RT_NULL,
  68. 1024, 21, 20);
  69. rt_thread_startup(init_thread);
  70. return 0;
  71. }
  72. /*@}*/