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