application.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. #include <drivers/mtd_nand.h>
  18. #include "finsh.h"
  19. #include "time.h"
  20. #ifdef RT_USING_DFS
  21. /* dfs init */
  22. #include <dfs_init.h>
  23. /* dfs filesystem:ELM filesystem init */
  24. #include <dfs_elm.h>
  25. /* dfs Filesystem APIs */
  26. #include <dfs_fs.h>
  27. #include <dfs_posix.h>
  28. #endif
  29. #ifdef RT_USING_LWIP
  30. #include <lwip/sys.h>
  31. #include <lwip/api.h>
  32. #include <netif/ethernetif.h>
  33. #include "drv_eth.h"
  34. #endif
  35. #ifdef RT_USING_GDB
  36. #include <gdb_stub.h>
  37. #endif
  38. #ifdef RT_USING_GUIENGINE
  39. #include "rtgui_demo.h"
  40. #include <rtgui/driver.h>
  41. #endif
  42. //rt_module_t module_ptr;
  43. #define DATA_PATH "/Data"
  44. void rt_init_thread_entry(void* parameter)
  45. {
  46. /* initialization RT-Thread Components */
  47. #ifdef RT_USING_COMPONENTS_INIT
  48. rt_components_init();
  49. #endif
  50. /* GDB STUB */
  51. #ifdef RT_USING_GDB
  52. gdb_set_device("uart6");
  53. gdb_start();
  54. #endif
  55. #ifdef RT_USING_DFS
  56. #ifdef RT_USING_DFS_UFFS
  57. /* mount nand flash partition 0 as root directory */
  58. if (dfs_mount("nand0", "/", "uffs", 0, 0) == 0)
  59. {
  60. mkdir("/sdcard",0);
  61. rt_kprintf("uffs initialized!\n");
  62. }
  63. else
  64. {
  65. rt_kprintf("uffs initialzation failed!\n");
  66. }
  67. #endif /* RT_USING_DFS_UFFS */
  68. #ifdef RT_USING_DFS_ELMFAT
  69. /* mount sd card fat partition 0 as root directory */
  70. if (dfs_mount("sd0", "/sdcard", "elm", 0, 0) == 0)
  71. {
  72. rt_kprintf("File System initialized!\n");
  73. }
  74. else
  75. {
  76. rt_kprintf("File System initialzation failed!\n");
  77. }
  78. /* mount sd card fat partition 0 as root directory */
  79. if (dfs_mount("W25Q256", "/spi", "elm", 0, 0) == 0)
  80. {
  81. rt_kprintf("spi flash mount to /spi !\n");
  82. }
  83. else
  84. {
  85. rt_kprintf("spi flash mount to /spi failed!\n");
  86. }
  87. #endif /* RT_USING_DFS_ELMFAT */
  88. #endif /* DFS */
  89. #ifdef RT_USING_GUIENGINE
  90. {
  91. rt_device_t device;
  92. device = rt_device_find("lcd");
  93. /* re-set graphic device */
  94. rtgui_graphic_set_device(device);
  95. rt_gui_demo_init();
  96. }
  97. #endif
  98. }
  99. int rt_application_init()
  100. {
  101. rt_thread_t tid;
  102. tid = rt_thread_create("init",
  103. rt_init_thread_entry, RT_NULL,
  104. 2048, RT_THREAD_PRIORITY_MAX/3, 20);
  105. if (tid != RT_NULL)
  106. rt_thread_startup(tid);
  107. return 0;
  108. }