application.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. /**
  15. * @addtogroup STM32
  16. */
  17. /*@{*/
  18. #include <rtthread.h>
  19. #include <finsh.h>
  20. #include <stm32f10x.h>
  21. #include "board.h"
  22. #include "netbuffer.h"
  23. #include "lcd.h"
  24. #ifdef RT_USING_DFS
  25. /* dfs init */
  26. #include <dfs_init.h>
  27. /* dfs filesystem:FAT filesystem init */
  28. #include <dfs_fat.h>
  29. /* dfs filesystem:EFS filesystem init */
  30. #include <dfs_efs.h>
  31. /* dfs filesystem:ELM FatFs filesystem init */
  32. #include <dfs_elm.h>
  33. /* dfs Filesystem APIs */
  34. #include <dfs_fs.h>
  35. #endif
  36. #ifdef RT_USING_LWIP
  37. #include <lwip/sys.h>
  38. #include <lwip/api.h>
  39. #include <netif/ethernetif.h>
  40. #endif
  41. #ifdef RT_USING_RTGUI
  42. extern void radio_rtgui_init(void);
  43. #endif
  44. /* thread phase init */
  45. void rt_init_thread_entry(void *parameter)
  46. {
  47. /* Filesystem Initialization */
  48. #ifdef RT_USING_DFS
  49. {
  50. /* init the device filesystem */
  51. dfs_init();
  52. #ifdef RT_USING_DFS_EFSL
  53. /* init the efsl filesystam*/
  54. efsl_init();
  55. /* mount sd card fat partition 1 as root directory */
  56. if (dfs_mount("sd0", "/", "efs", 0, 0) == 0)
  57. rt_kprintf("File System initialized!\n");
  58. else
  59. rt_kprintf("File System init failed!\n");
  60. #elif defined(RT_USING_DFS_ELMFAT)
  61. /* init the elm FAT filesystam*/
  62. elm_init();
  63. /* mount sd card fat partition 1 as root directory */
  64. if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
  65. rt_kprintf("File System initialized!\n");
  66. else
  67. rt_kprintf("File System init failed!\n");
  68. #endif
  69. }
  70. #endif
  71. /* RTGUI Initialization */
  72. #ifdef RT_USING_RTGUI
  73. {
  74. extern void rt_hw_key_init(void);
  75. radio_rtgui_init();
  76. rt_hw_key_init();
  77. }
  78. #endif
  79. /* LwIP Initialization */
  80. #ifdef RT_USING_LWIP
  81. {
  82. extern void lwip_sys_init(void);
  83. extern void rt_hw_dm9000_init(void);
  84. eth_system_device_init();
  85. /* register ethernetif device */
  86. rt_hw_dm9000_init();
  87. /* init all device */
  88. rt_device_init_all();
  89. /* init lwip system */
  90. lwip_sys_init();
  91. rt_kprintf("TCP/IP initialized!\n");
  92. }
  93. #endif
  94. #if STM32_EXT_SRAM
  95. /* init netbuf worker */
  96. net_buf_init(320 * 1024);
  97. #endif
  98. }
  99. int rt_application_init()
  100. {
  101. rt_thread_t init_thread;
  102. rt_hw_lcd_init();
  103. #if (RT_THREAD_PRIORITY_MAX == 32)
  104. init_thread = rt_thread_create("init",
  105. rt_init_thread_entry, RT_NULL,
  106. 2048, 8, 20);
  107. #else
  108. init_thread = rt_thread_create("init",
  109. rt_init_thread_entry, RT_NULL,
  110. 2048, 80, 20);
  111. #endif
  112. if (init_thread != RT_NULL) rt_thread_startup(init_thread);
  113. return 0;
  114. }
  115. /*@}*/