application.c 3.1 KB

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