application.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Copyright (c) 2006-2018, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2009-01-05 Bernard the first version
  9. * 2014-04-27 Bernard make code cleanup.
  10. */
  11. #include <board.h>
  12. #include <rtthread.h>
  13. #ifdef RT_USING_DFS
  14. /* dfs init */
  15. #include <dfs.h>
  16. /* dfs filesystem:ELM filesystem init */
  17. #include <dfs_elm.h>
  18. /* dfs Filesystem APIs */
  19. #include <dfs_fs.h>
  20. #include <dfs_posix.h>
  21. #endif
  22. #ifdef PKG_USING_GUIENGINE
  23. #include "rtgui_demo.h"
  24. #include <rtgui/driver.h>
  25. #endif
  26. void rt_init_thread_entry(void* parameter)
  27. {
  28. /* initialization RT-Thread Components */
  29. #ifdef RT_USING_COMPONENTS_INIT
  30. rt_components_init();
  31. #endif
  32. #ifdef RT_USING_DFS
  33. #ifdef RT_USING_DFS_ELMFAT
  34. /* mount spi flash as root directory */
  35. if (dfs_mount("W25Q64", "/", "elm", 0, 0) == 0)
  36. {
  37. rt_kprintf("spi flash mount to / !\n");
  38. }
  39. else
  40. {
  41. rt_kprintf("spi flash mount to / failed!\n");
  42. }
  43. /* mount sd card fat partition 0 as root directory */
  44. if (dfs_mount("sd0", "/sd0", "elm", 0, 0) == 0)
  45. {
  46. rt_kprintf("sd0 mount to /sd0 !\n");
  47. }
  48. else
  49. {
  50. rt_kprintf("sd0 mount to /sd0 failed!\n");
  51. }
  52. #endif /* RT_USING_DFS_ELMFAT */
  53. #endif /* DFS */
  54. #ifdef PKG_USING_GUIENGINE
  55. {
  56. rt_device_t device;
  57. device = rt_device_find("lcd");
  58. /* re-set graphic device */
  59. rtgui_graphic_set_device(device);
  60. rt_gui_demo_init();
  61. }
  62. #endif
  63. }
  64. int rt_application_init()
  65. {
  66. rt_thread_t tid;
  67. tid = rt_thread_create("init",
  68. rt_init_thread_entry, RT_NULL,
  69. 2048, RT_THREAD_PRIORITY_MAX/3, 20);
  70. if (tid != RT_NULL)
  71. rt_thread_startup(tid);
  72. return 0;
  73. }