application.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * File : application.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://www.rt-thread.org/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. #include "led.h"
  22. #ifdef RT_USING_DFS
  23. /* dfs init */
  24. #include <dfs_init.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 <netif/ethernetif.h>
  32. #endif
  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_EFSL
  41. /* init the efsl filesystam*/
  42. efsl_init();
  43. /* mount sd card fat partition 1 as root directory */
  44. if (dfs_mount("sd0", "/", "efs", 0, 0) == 0)
  45. {
  46. rt_kprintf("File System initialized!\n");
  47. }
  48. else
  49. rt_kprintf("File System initialzation failed!\n");
  50. #elif defined(RT_USING_DFS_ELMFAT)
  51. /* init the elm chan FatFs filesystam*/
  52. elm_init();
  53. /* mount sd card fat partition 1 as root directory */
  54. if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
  55. {
  56. rt_kprintf("File System initialized!\n");
  57. }
  58. else
  59. rt_kprintf("File System initialzation failed!\n");
  60. #endif
  61. }
  62. #endif
  63. /* LwIP Initialization */
  64. #ifdef RT_USING_LWIP
  65. {
  66. extern void lwip_sys_init(void);
  67. eth_system_device_init();
  68. /* register ethernetif device */
  69. rt_hw_dm9000_init();
  70. /* re-init device driver */
  71. rt_device_init_all();
  72. /* init lwip system */
  73. lwip_sys_init();
  74. rt_kprintf("TCP/IP initialized!\n");
  75. }
  76. #endif
  77. }
  78. void rt_led_thread_entry(void* parameter)
  79. {
  80. while(1)
  81. {
  82. /* light on leds for one second */
  83. rt_hw_led_on(LED2|LED3);
  84. rt_hw_led_off(LED1|LED4);
  85. rt_thread_delay(100);
  86. /* light off leds for one second */
  87. rt_hw_led_off(LED2|LED3);
  88. rt_hw_led_on(LED1|LED4);
  89. rt_thread_delay(100);
  90. }
  91. }
  92. int rt_application_init()
  93. {
  94. rt_thread_t init_thread;
  95. rt_thread_t led_thread;
  96. #if (RT_THREAD_PRIORITY_MAX == 32)
  97. init_thread = rt_thread_create("init",
  98. rt_init_thread_entry, RT_NULL,
  99. 2048, 8, 20);
  100. led_thread = rt_thread_create("led",
  101. rt_led_thread_entry, RT_NULL,
  102. 512, 20, 20);
  103. #else
  104. init_thread = rt_thread_create("init",
  105. rt_init_thread_entry, RT_NULL,
  106. 2048, 80, 20);
  107. led_thread = rt_thread_create("led",
  108. rt_led_thread_entry, RT_NULL,
  109. 512, 200, 20);
  110. #endif
  111. if (init_thread != RT_NULL)
  112. rt_thread_startup(init_thread);
  113. if(led_thread != RT_NULL)
  114. rt_thread_startup(led_thread);
  115. return 0;
  116. }
  117. /*@}*/