application.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2006-06-05 Bernard the first version
  13. */
  14. #include <rtthread.h>
  15. #include <finsh.h>
  16. /**
  17. * @addtogroup LPC2148
  18. */
  19. /*@{*/
  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. #endif
  33. #ifdef RT_USING_RTGUI
  34. #include <rtgui/rtgui.h>
  35. #endif
  36. /* thread phase init */
  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. /* init the efsl filesystam*/
  45. efsl_init();
  46. /* mount sd card fat partition 1 as root directory */
  47. if (dfs_mount("sd0", "/", "efs", 0, 0) == 0)
  48. rt_kprintf("File System initialized!\n");
  49. else
  50. rt_kprintf("File System init failed!\n");
  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. /************** LED BLINK *******************/
  64. #include "lpc214x.h"
  65. #define LED1 ( 1<<16) //P1
  66. #define LED2 ( 1<<17) //P1
  67. #define LED3 ( 1<<18) //P1
  68. #define LED4 ( 1<<19) //P1
  69. char thread3_stack[512];
  70. struct rt_thread thread3;
  71. void thread3_entry(void* parameter)
  72. {
  73. volatile unsigned int i;
  74. IO1DIR |= LED1;
  75. while(1)
  76. {
  77. IO1CLR = LED1;
  78. rt_thread_delay(20);
  79. IO1SET = LED1;
  80. rt_thread_delay(20);
  81. }
  82. }
  83. char thread4_stack[512];
  84. struct rt_thread thread4;
  85. void thread4_entry(void* parameter)
  86. {
  87. volatile unsigned int i;
  88. IO1DIR |= LED2;
  89. while(1)
  90. {
  91. IO1CLR = LED2;
  92. rt_thread_delay(30);
  93. IO1SET = LED2;
  94. rt_thread_delay(30);
  95. }
  96. }
  97. /************** LED BLINK *******************/
  98. int rt_application_init()
  99. {
  100. rt_thread_init(&thread3,
  101. "led1",
  102. thread3_entry, RT_NULL,
  103. &thread3_stack[0], sizeof(thread3_stack),
  104. 20, 10);
  105. rt_thread_init(&thread4,
  106. "led2",
  107. thread4_entry, RT_NULL,
  108. &thread4_stack[0], sizeof(thread4_stack),
  109. 25, 8);
  110. rt_thread_startup(&thread3);
  111. rt_thread_startup(&thread4);
  112. {
  113. rt_thread_t init_thread;
  114. init_thread = rt_thread_create("init",
  115. rt_init_thread_entry, RT_NULL,
  116. 1024, 8, 5);
  117. rt_thread_startup(init_thread);
  118. }
  119. rt_kprintf("enter list() to get function list!\n");
  120. return 0;
  121. }
  122. /*@}*/