application.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. *
  13. */
  14. /**
  15. * @addtogroup k64
  16. */
  17. /*@{*/
  18. #include <stdio.h>
  19. #include "MK64F12.h"
  20. #include <board.h>
  21. #include <rtthread.h>
  22. #include "led.h"
  23. #ifdef RT_USING_LWIP
  24. #include <lwip/sys.h>
  25. #include <lwip/api.h>
  26. #include <netif/ethernetif.h>
  27. #endif
  28. void rt_init_thread_entry(void* parameter)
  29. {
  30. #ifdef RT_USING_COMPONENTS_INIT
  31. /* initialization RT-Thread Components */
  32. rt_components_init();
  33. #endif
  34. }
  35. float f_var1;
  36. float f_var2;
  37. float f_var3;
  38. float f_var4;
  39. ALIGN(RT_ALIGN_SIZE)
  40. static char thread_led1_stack[1024];
  41. struct rt_thread thread_led1;
  42. static void rt_thread_entry_led1(void* parameter)
  43. {
  44. int n = 0;
  45. rt_hw_led_init();
  46. while (1)
  47. {
  48. //rt_kprintf("LED\t%d\tis shining\r\n",n);
  49. rt_hw_led_on(n);
  50. rt_thread_delay(RT_TICK_PER_SECOND/2);
  51. rt_hw_led_off(n);
  52. rt_thread_delay(RT_TICK_PER_SECOND/2);
  53. n++;
  54. if (n == LED_MAX)
  55. n = 0;
  56. }
  57. }
  58. int rt_application_init()
  59. {
  60. rt_thread_t init_thread;
  61. #if (RT_THREAD_PRIORITY_MAX == 32)
  62. init_thread = rt_thread_create("init",
  63. rt_init_thread_entry, RT_NULL,
  64. 2048, 8, 20);
  65. #else
  66. init_thread = rt_thread_create("init",
  67. rt_init_thread_entry, RT_NULL,
  68. 2048, 80, 20);
  69. #endif
  70. if (init_thread != RT_NULL)
  71. rt_thread_startup(init_thread);
  72. //------- init led1 thread
  73. rt_thread_init(&thread_led1,
  74. "led_demo",
  75. rt_thread_entry_led1,
  76. RT_NULL,
  77. &thread_led1_stack[0],
  78. sizeof(thread_led1_stack),11,5);
  79. rt_thread_startup(&thread_led1);
  80. return 0;
  81. }
  82. /*@}*/