application.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. #include "stm32_eth.h"
  28. #endif
  29. void rt_init_thread_entry(void* parameter)
  30. {
  31. /* LwIP Initialization */
  32. #ifdef RT_USING_LWIP
  33. {
  34. extern void lwip_sys_init(void);
  35. /* register ethernetif device */
  36. eth_system_device_init();
  37. rt_hw_stm32_eth_init();
  38. /* re-init device driver */
  39. rt_device_init_all();
  40. /* init lwip system */
  41. lwip_sys_init();
  42. rt_kprintf("TCP/IP initialized!\n");
  43. }
  44. #endif
  45. //FS
  46. //GUI
  47. }
  48. float f_var1;
  49. float f_var2;
  50. float f_var3;
  51. float f_var4;
  52. ALIGN(RT_ALIGN_SIZE)
  53. static char thread_led1_stack[1024];
  54. struct rt_thread thread_led1;
  55. static void rt_thread_entry_led1(void* parameter)
  56. {
  57. int n = 0;
  58. rt_hw_led_init();
  59. while (1)
  60. {
  61. //rt_kprintf("LED\t%d\tis shining\r\n",n);
  62. rt_hw_led_on(n);
  63. rt_thread_delay(RT_TICK_PER_SECOND/2);
  64. rt_hw_led_off(n);
  65. rt_thread_delay(RT_TICK_PER_SECOND/2);
  66. n++;
  67. if (n == LED_MAX)
  68. n = 0;
  69. }
  70. }
  71. int rt_application_init()
  72. {
  73. rt_thread_t init_thread;
  74. #if (RT_THREAD_PRIORITY_MAX == 32)
  75. init_thread = rt_thread_create("init",
  76. rt_init_thread_entry, RT_NULL,
  77. 2048, 8, 20);
  78. #else
  79. init_thread = rt_thread_create("init",
  80. rt_init_thread_entry, RT_NULL,
  81. 2048, 80, 20);
  82. #endif
  83. if (init_thread != RT_NULL)
  84. rt_thread_startup(init_thread);
  85. //------- init led1 thread
  86. rt_thread_init(&thread_led1,
  87. "led_demo",
  88. rt_thread_entry_led1,
  89. RT_NULL,
  90. &thread_led1_stack[0],
  91. sizeof(thread_led1_stack),11,5);
  92. rt_thread_startup(&thread_led1);
  93. return 0;
  94. }
  95. /*@}*/