1
0

application.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. #ifdef RT_USING_DFS
  18. /* dfs init */
  19. #include <dfs.h>
  20. /* dfs filesystem:ELM filesystem init */
  21. #include <dfs_elm.h>
  22. /* dfs Filesystem APIs */
  23. #include <dfs_fs.h>
  24. #include <dfs_posix.h>
  25. #endif
  26. #ifdef PKG_USING_GUIENGINE
  27. #include "rtgui_demo.h"
  28. #include <rtgui/driver.h>
  29. #endif
  30. void rt_init_thread_entry(void* parameter)
  31. {
  32. /* initialization RT-Thread Components */
  33. #ifdef RT_USING_COMPONENTS_INIT
  34. rt_components_init();
  35. #endif
  36. #ifdef RT_USING_DFS
  37. #ifdef RT_USING_DFS_ELMFAT
  38. /* mount spi flash as root directory */
  39. if (dfs_mount("W25Q64", "/", "elm", 0, 0) == 0)
  40. {
  41. rt_kprintf("spi flash mount to / !\n");
  42. }
  43. else
  44. {
  45. rt_kprintf("spi flash mount to / failed!\n");
  46. }
  47. /* mount sd card fat partition 0 as root directory */
  48. if (dfs_mount("sd0", "/sd0", "elm", 0, 0) == 0)
  49. {
  50. rt_kprintf("sd0 mount to /sd0 !\n");
  51. }
  52. else
  53. {
  54. rt_kprintf("sd0 mount to /sd0 failed!\n");
  55. }
  56. #endif /* RT_USING_DFS_ELMFAT */
  57. #endif /* DFS */
  58. #ifdef PKG_USING_GUIENGINE
  59. {
  60. rt_device_t device;
  61. device = rt_device_find("lcd");
  62. /* re-set graphic device */
  63. rtgui_graphic_set_device(device);
  64. rt_gui_demo_init();
  65. }
  66. #endif
  67. }
  68. int rt_application_init()
  69. {
  70. rt_thread_t tid;
  71. tid = rt_thread_create("init",
  72. rt_init_thread_entry, RT_NULL,
  73. 2048, RT_THREAD_PRIORITY_MAX/3, 20);
  74. if (tid != RT_NULL)
  75. rt_thread_startup(tid);
  76. return 0;
  77. }