application.c 3.4 KB

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