application.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. #endif
  70. }
  71. #endif
  72. /* RTGUI Initialization */
  73. #ifdef RT_USING_RTGUI
  74. {
  75. extern void rt_hw_key_init(void);
  76. radio_rtgui_init();
  77. rt_hw_key_init();
  78. }
  79. #endif
  80. /* LwIP Initialization */
  81. #ifdef RT_USING_LWIP
  82. {
  83. extern void lwip_sys_init(void);
  84. extern void rt_hw_dm9000_init(void);
  85. eth_system_device_init();
  86. /* register ethernetif device */
  87. rt_hw_dm9000_init();
  88. /* init all device */
  89. rt_device_init_all();
  90. /* init lwip system */
  91. lwip_sys_init();
  92. rt_kprintf("TCP/IP initialized!\n");
  93. }
  94. #endif
  95. #if STM32_EXT_SRAM
  96. /* init netbuf worker */
  97. net_buf_init(320 * 1024);
  98. #endif
  99. /* start RTC */
  100. rt_hw_rtc_init();
  101. }
  102. int rt_application_init()
  103. {
  104. rt_thread_t init_thread;
  105. rt_hw_lcd_init();
  106. #if (RT_THREAD_PRIORITY_MAX == 32)
  107. init_thread = rt_thread_create("init",
  108. rt_init_thread_entry, RT_NULL,
  109. 2048, 8, 20);
  110. #else
  111. init_thread = rt_thread_create("init",
  112. rt_init_thread_entry, RT_NULL,
  113. 2048, 80, 20);
  114. #endif
  115. if (init_thread != RT_NULL) rt_thread_startup(init_thread);
  116. return 0;
  117. }
  118. /*@}*/