application.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Copyright (c) 2006-2018, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. *
  9. */
  10. /**
  11. * @addtogroup k64
  12. */
  13. /*@{*/
  14. #include <stdint.h>
  15. #include <stdio.h>
  16. #include "MK64F12.h"
  17. #include <board.h>
  18. #include <rtthread.h>
  19. #include "led.h"
  20. void rt_init_thread_entry(void* parameter)
  21. {
  22. #ifdef RT_USING_COMPONENTS_INIT
  23. /* initialization RT-Thread Components */
  24. rt_components_init();
  25. #endif
  26. }
  27. float f_var1;
  28. float f_var2;
  29. float f_var3;
  30. float f_var4;
  31. ALIGN(RT_ALIGN_SIZE)
  32. static char thread_led1_stack[1024];
  33. struct rt_thread thread_led1;
  34. static void rt_thread_entry_led1(void* parameter)
  35. {
  36. int n = 0;
  37. rt_hw_led_init();
  38. while (1)
  39. {
  40. //rt_kprintf("LED\t%d\tis shining\r\n",n);
  41. rt_hw_led_on(n);
  42. rt_thread_delay(RT_TICK_PER_SECOND/2);
  43. rt_hw_led_off(n);
  44. rt_thread_delay(RT_TICK_PER_SECOND/2);
  45. n++;
  46. if (n == LED_MAX)
  47. n = 0;
  48. }
  49. }
  50. int rt_application_init()
  51. {
  52. rt_thread_t init_thread;
  53. init_thread = rt_thread_create("init",
  54. rt_init_thread_entry, RT_NULL,
  55. 2048, RT_THREAD_PRIORITY_MAX/3, 20);
  56. if (init_thread != RT_NULL)
  57. rt_thread_startup(init_thread);
  58. //------- init led1 thread
  59. rt_thread_init(&thread_led1,
  60. "led_demo",
  61. rt_thread_entry_led1,
  62. RT_NULL,
  63. &thread_led1_stack[0],
  64. sizeof(thread_led1_stack),11,5);
  65. rt_thread_startup(&thread_led1);
  66. return 0;
  67. }
  68. /*@}*/