application.c 1.8 KB

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