application.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. #ifdef RT_USING_DFS
  18. /* dfs init */
  19. #include <dfs_init.h>
  20. /* dfs filesystem:ELM filesystem init */
  21. #include <dfs_elm.h>
  22. /* dfs Filesystem APIs */
  23. #include <dfs_fs.h>
  24. #endif
  25. void rt_init_thread_entry(void* parameter)
  26. {
  27. #ifdef RT_USING_COMPONENTS_INIT
  28. /* initialization RT-Thread Components */
  29. rt_components_init();
  30. #endif
  31. rt_platform_init();
  32. /* Filesystem Initialization */
  33. #ifdef RT_USING_DFS
  34. {
  35. #ifdef RT_USING_DFS_ELMFAT
  36. /* mount sd card fat partition 1 as root directory */
  37. if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
  38. {
  39. rt_kprintf("fatfs initialized!\n");
  40. }
  41. else
  42. rt_kprintf("fatfs initialzation failed!\n");
  43. #endif
  44. #ifdef RT_USING_DFS_ELMFAT
  45. /* mount sd card fat partition 1 as root directory */
  46. if (dfs_mount("nand0", "/nand", "uffs", 0, 0) == 0)
  47. {
  48. rt_kprintf("uffs initialized!\n");
  49. }
  50. else
  51. rt_kprintf("uffs initialzation failed!\n");
  52. #endif
  53. #ifdef RT_USING_DFS_JFFS2
  54. /* mount sd card fat partition 1 as root directory */
  55. if (dfs_mount("nor", "/nor", "jffs2", 0, 0) == 0)
  56. {
  57. rt_kprintf("jffs2 initialized!\n");
  58. }
  59. else
  60. rt_kprintf("jffs2 initialzation failed!\n");
  61. #endif
  62. }
  63. #endif
  64. }
  65. void rt_test_thread_entry(void* parameter)
  66. {
  67. int i;
  68. for(i=0; i<10; i++)
  69. {
  70. rt_kprintf("hello, world\n");
  71. rt_thread_delay(100);
  72. }
  73. }
  74. #include <finsh.h>
  75. int rt_application_init()
  76. {
  77. rt_thread_t thread;
  78. #if (RT_THREAD_PRIORITY_MAX == 32)
  79. thread = rt_thread_create("init",
  80. rt_init_thread_entry, RT_NULL,
  81. 2048, 8, 20);
  82. #else
  83. thread = rt_thread_create("init",
  84. rt_init_thread_entry, RT_NULL,
  85. 2048, 80, 20);
  86. #endif
  87. if (thread != RT_NULL)
  88. rt_thread_startup(thread);
  89. thread = rt_thread_create("test",
  90. rt_test_thread_entry, RT_NULL,
  91. 2048, 9, 20);
  92. if (thread != RT_NULL)
  93. rt_thread_startup(thread);
  94. return 0;
  95. }
  96. /*@}*/