application.c 2.4 KB

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