application.c 3.0 KB

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