application.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * File : app.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. *
  13. */
  14. /**
  15. * @addtogroup LPC122x
  16. */
  17. /*@{*/
  18. #include <rtthread.h>
  19. #include "tc_comm.h"
  20. /*
  21. * This is an example for delay thread
  22. */
  23. static struct rt_thread thread;
  24. static char thread_stack[THREAD_STACK_SIZE];
  25. static void thread_entry(void* parameter)
  26. {
  27. rt_tick_t tick;
  28. rt_kprintf("thread inited ok\n");
  29. tick = rt_tick_get();
  30. rt_kprintf("thread tick %d\n", tick);
  31. rt_kprintf("thread delay 10 tick\n");
  32. rt_thread_delay(10);
  33. if (rt_tick_get() - tick > 10)
  34. {
  35. tc_done(TC_STAT_FAILED);
  36. return;
  37. }
  38. tick = rt_tick_get();
  39. rt_kprintf("thread delay 15 tick\n");
  40. rt_thread_delay(15);
  41. if (rt_tick_get() - tick > 15)
  42. {
  43. tc_done(TC_STAT_FAILED);
  44. return;
  45. }
  46. rt_kprintf("thread exit\n");
  47. tc_done(TC_STAT_PASSED);
  48. }
  49. rt_err_t thread_delay_init()
  50. {
  51. rt_err_t result;
  52. result = rt_thread_init(&thread,
  53. "test",
  54. thread_entry, RT_NULL,
  55. &thread_stack[0], sizeof(thread_stack),
  56. THREAD_PRIORITY, 10);
  57. if (result == RT_EOK)
  58. rt_thread_startup(&thread);
  59. else
  60. tc_stat(TC_STAT_END | TC_STAT_FAILED);
  61. return result;
  62. }
  63. int rt_application_init()
  64. {
  65. thread_delay_init();
  66. return 0;
  67. }
  68. /*@}*/