1
0

application.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * File : application.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006-2015, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2011-01-13 weety first version
  23. * 2015-04-27 ArdaFu Port bsp from at91sam9260 to asm9260t
  24. */
  25. #include <rtthread.h>
  26. #include <rtdevice.h>
  27. #ifdef RT_USING_LED
  28. #include "led.h"
  29. void rt_led_thread_entry(void* parameter)
  30. {
  31. rt_uint8_t cnt = 0;
  32. led_init();
  33. while(1)
  34. {
  35. /* light on leds for one second */
  36. rt_thread_delay(40);
  37. cnt++;
  38. if(cnt & 0x01)
  39. led_on(1);
  40. else
  41. led_off(1);
  42. }
  43. }
  44. static void start_led_thread(void)
  45. {
  46. rt_thread_t led_thread;
  47. led_thread = rt_thread_create("led", rt_led_thread_entry, RT_NULL, 512,
  48. (RT_THREAD_PRIORITY_MAX / 8 * 5), 20);
  49. if(led_thread != RT_NULL)
  50. rt_thread_startup(led_thread);
  51. }
  52. #endif
  53. int main()
  54. {
  55. #ifdef RT_USING_LED
  56. start_led_thread();
  57. #endif
  58. return 0;
  59. }