application.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. */
  14. #include <rtthread.h>
  15. #include <stdio.h>
  16. #include <board.h>
  17. #include <components.h>
  18. void rt_init_thread_entry(void* parameter)
  19. {
  20. /* initialization RT-Thread Components */
  21. rt_components_init();
  22. rt_platform_init();
  23. /* Filesystem Initialization */
  24. #ifdef RT_USING_DFS
  25. {
  26. #ifdef RT_USING_DFS_ELMFAT
  27. /* mount sd card fat partition 1 as root directory */
  28. if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
  29. {
  30. rt_kprintf("fatfs initialized!\n");
  31. }
  32. else
  33. rt_kprintf("fatfs initialzation failed!\n");
  34. #endif
  35. #ifdef RT_USING_DFS_ELMFAT
  36. /* mount sd card fat partition 1 as root directory */
  37. if (dfs_mount("nand0", "/nand", "uffs", 0, 0) == 0)
  38. {
  39. rt_kprintf("uffs initialized!\n");
  40. }
  41. else
  42. rt_kprintf("uffs initialzation failed!\n");
  43. #endif
  44. #ifdef RT_USING_DFS_JFFS2
  45. /* mount sd card fat partition 1 as root directory */
  46. if (dfs_mount("nor", "/nor", "jffs2", 0, 0) == 0)
  47. {
  48. rt_kprintf("jffs2 initialized!\n");
  49. }
  50. else
  51. rt_kprintf("jffs2 initialzation failed!\n");
  52. #endif
  53. }
  54. #endif
  55. }
  56. void rt_test_thread_entry(void* parameter)
  57. {
  58. int i;
  59. for(i=0; i<10; i++)
  60. {
  61. rt_kprintf("hello, world\n");
  62. rt_thread_delay(100);
  63. }
  64. }
  65. int rt_application_init()
  66. {
  67. rt_thread_t tid;
  68. tid = rt_thread_create("init",
  69. rt_init_thread_entry, RT_NULL,
  70. 2048, RT_THREAD_PRIORITY_MAX/3, 20);
  71. if (tid != RT_NULL)
  72. rt_thread_startup(tid);
  73. tid = rt_thread_create("test",
  74. rt_test_thread_entry, RT_NULL,
  75. 2048, RT_THREAD_PRIORITY_MAX * 3 /4, 20);
  76. if (tid != RT_NULL)
  77. rt_thread_startup(tid);
  78. return 0;
  79. }
  80. #ifndef _CRT_TERMINATE_DEFINED
  81. #define _CRT_TERMINATE_DEFINED
  82. _CRTIMP __declspec(noreturn) void __cdecl exit(__in int _Code);
  83. _CRTIMP __declspec(noreturn) void __cdecl _exit(__in int _Code);
  84. _CRTIMP void __cdecl abort(void);
  85. #endif
  86. void rt_hw_exit(void)
  87. {
  88. rt_kprintf("RT-Thread, bye\n");
  89. exit(0);
  90. }
  91. FINSH_FUNCTION_EXPORT_ALIAS(rt_hw_exit, exit, exit rt-thread);
  92. /*@}*/