application.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. void rt_init_thread_entry(void* parameter)
  28. {
  29. /* Initialization RT-Thread Components */
  30. rt_components_init();
  31. }
  32. #ifdef RT_USING_LED
  33. #include "led.h"
  34. void rt_led_thread_entry(void* parameter)
  35. {
  36. rt_uint8_t cnt = 0;
  37. led_init();
  38. while(1)
  39. {
  40. /* light on leds for one second */
  41. rt_thread_delay(40);
  42. cnt++;
  43. if(cnt & 0x01)
  44. led_on(1);
  45. else
  46. led_off(1);
  47. }
  48. }
  49. static void start_led_thread(void)
  50. {
  51. rt_thread_t led_thread;
  52. led_thread = rt_thread_create("led", rt_led_thread_entry, RT_NULL, 512,
  53. (RT_THREAD_PRIORITY_MAX / 8 * 5), 20);
  54. if(led_thread != RT_NULL)
  55. rt_thread_startup(led_thread);
  56. }
  57. #endif
  58. int rt_application_init()
  59. {
  60. rt_thread_t init_thread;
  61. init_thread = rt_thread_create("init", rt_init_thread_entry, RT_NULL, 2048,
  62. (RT_THREAD_PRIORITY_MAX / 8 * 2), 20);
  63. if(init_thread != RT_NULL)
  64. rt_thread_startup(init_thread);
  65. #ifdef RT_USING_LED
  66. start_led_thread();
  67. #endif
  68. return 0;
  69. }