application.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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_init.h>
  23. /* dfs filesystem:FAT filesystem init */
  24. #include <dfs_fat.h>
  25. /* dfs filesystem:EFS filesystem init */
  26. #include <dfs_efs.h>
  27. /* dfs Filesystem APIs */
  28. #include <dfs_fs.h>
  29. #endif
  30. #ifdef RT_USING_LWIP
  31. #include <lwip/sys.h>
  32. #include <lwip/api.h>
  33. #endif
  34. char thread1_stack[0x120];
  35. struct rt_thread thread1;
  36. void thread1_entry(void* parameter)
  37. {
  38. rt_uint32_t i = 0;
  39. while (1)
  40. {
  41. rt_kprintf("thread1 --> %d\n", ++i);
  42. rt_thread_delay(100);
  43. }
  44. }
  45. void thread_test()
  46. {
  47. rt_thread_init(&thread1,
  48. "thread1",
  49. thread1_entry, RT_NULL,
  50. &thread1_stack[0], sizeof(thread1_stack),
  51. 20, 15);
  52. rt_thread_startup(&thread1);
  53. }
  54. #ifdef RT_USING_FINSH
  55. #include <finsh.h>
  56. FINSH_FUNCTION_EXPORT(thread_test, test a basic thread)
  57. #endif
  58. /* thread phase init */
  59. void rt_init_thread_entry(void *parameter)
  60. {
  61. /* Filesystem Initialization */
  62. #ifdef RT_USING_DFS
  63. {
  64. /* init the device filesystem */
  65. dfs_init();
  66. /* init the efsl filesystam*/
  67. efsl_init();
  68. /* mount sd card fat partition 1 as root directory */
  69. if (dfs_mount("sd0", "/", "efs", 0, 0) == 0)
  70. rt_kprintf("File System initialized!\n");
  71. else
  72. rt_kprintf("File System init failed!\n");
  73. }
  74. #endif
  75. /* LwIP Initialization */
  76. #ifdef RT_USING_LWIP
  77. {
  78. extern void lwip_sys_init(void);
  79. /* init lwip system */
  80. lwip_sys_init();
  81. rt_kprintf("TCP/IP initialized!\n");
  82. ftpd_start();
  83. }
  84. #endif
  85. }
  86. int rt_application_init()
  87. {
  88. rt_thread_t init_thread;
  89. init_thread = rt_thread_create("init",
  90. rt_init_thread_entry, RT_NULL,
  91. 2048, 21, 20);
  92. rt_thread_startup(init_thread);
  93. return 0;
  94. }
  95. /*@}*/