application.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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-06-29 lgnq the first version
  14. *
  15. * For : NEC V850E
  16. * Toolchain : IAR Embedded Workbench for V850 v3.71
  17. */
  18. #include <rtthread.h>
  19. #include "board.h"
  20. #include "CG_macrodriver.h"
  21. #include "CG_system.h"
  22. #include "CG_port.h"
  23. #include "CG_timer.h"
  24. /* Start user code for include. Do not edit comment generated here */
  25. /* End user code. Do not edit comment generated here */
  26. #include "CG_userdefine.h"
  27. static struct rt_thread led;
  28. #if defined(__ICCM16C__) || defined(__ICCV850__)
  29. #pragma data_alignment=4
  30. #endif
  31. static rt_uint8_t led_stack[256];
  32. static void rt_thread_entry_led(void* parameter)
  33. {
  34. while (1)
  35. {
  36. /* led off */
  37. led_off();
  38. rt_thread_delay(20); /* sleep 1 second and switch to other thread */
  39. /* led on */
  40. led_on();
  41. rt_thread_delay(40);
  42. }
  43. }
  44. int rt_application_init(void)
  45. {
  46. /* create led thread */
  47. rt_thread_init(&led,
  48. "led",
  49. rt_thread_entry_led, RT_NULL,
  50. &led_stack[0], sizeof(led_stack),
  51. 5, 32);
  52. if (&led != RT_NULL)
  53. rt_thread_startup(&led);
  54. return 0;
  55. }