application.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * File : application.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2009, 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. * 2010-04-09 fify modified for M16C
  14. *
  15. * For : Renesas M16C
  16. * Toolchain : IAR's EW for M16C v3.401
  17. */
  18. #include <rtthread.h>
  19. #include "bsp.h"
  20. static struct rt_thread led;
  21. ALIGN(RT_ALIGN_SIZE)
  22. static rt_uint8_t led_stack[256];
  23. static void rt_thread_entry_led(void* parameter)
  24. {
  25. while (1)
  26. {
  27. /* led off */
  28. led_off();
  29. rt_thread_delay(100); /* sleep 1 second and switch to other thread */
  30. /* led on */
  31. led_on();
  32. rt_thread_delay(100);
  33. }
  34. }
  35. int rt_application_init(void)
  36. {
  37. /* create led thread */
  38. rt_thread_init(&led,
  39. "led",
  40. rt_thread_entry_led, RT_NULL,
  41. &led_stack[0], sizeof(led_stack),
  42. 5, 32);
  43. if (&led != RT_NULL)
  44. rt_thread_startup(&led);
  45. return 0;
  46. }