application.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * File : application.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. * 2009-01-05 Bernard the first version
  13. * 2014-04-27 Bernard make code cleanup.
  14. */
  15. #include <board.h>
  16. #include <rtthread.h>
  17. #ifndef RT_USING_HEAP
  18. /* if there is not enable heap, we should use static thread and stack. */
  19. ALIGN(8)
  20. static rt_uint8_t init_stack[512];
  21. static struct rt_thread init_thread;
  22. #endif
  23. void rt_init_thread_entry(void* parameter)
  24. {
  25. /* initialization RT-Thread Components */
  26. #ifdef RT_USING_COMPONENTS_INIT
  27. rt_components_init();
  28. #endif
  29. }
  30. int rt_application_init()
  31. {
  32. rt_thread_t tid;
  33. #ifdef RT_USING_HEAP
  34. tid = rt_thread_create("init",
  35. rt_init_thread_entry, RT_NULL,
  36. 2048, RT_THREAD_PRIORITY_MAX/3, 20);
  37. #else
  38. {
  39. rt_err_t result;
  40. tid = &init_thread;
  41. result = rt_thread_init(tid, "init", rt_init_thread_entry, RT_NULL,
  42. init_stack, sizeof(init_stack), RT_THREAD_PRIORITY_MAX / 3, 20);
  43. RT_ASSERT(result == RT_EOK);
  44. }
  45. #endif
  46. if (tid != RT_NULL)
  47. rt_thread_startup(tid);
  48. return 0;
  49. }