usb_conf.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. /**
  2. ******************************************************************************
  3. * @file usb_conf.h
  4. * @author MCD Application Team
  5. * @version V2.1.0
  6. * @date 19-March-2012
  7. * @brief General low level driver configuration
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>
  12. *
  13. * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  14. * You may not use this file except in compliance with the License.
  15. * You may obtain a copy of the License at:
  16. *
  17. * http://www.st.com/software_license_agreement_liberty_v2
  18. *
  19. * Unless required by applicable law or agreed to in writing, software
  20. * distributed under the License is distributed on an "AS IS" BASIS,
  21. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  22. * See the License for the specific language governing permissions and
  23. * limitations under the License.
  24. *
  25. ******************************************************************************
  26. */
  27. /* Define to prevent recursive inclusion -------------------------------------*/
  28. #ifndef __USB_CONF__H__
  29. #define __USB_CONF__H__
  30. /* Includes ------------------------------------------------------------------*/
  31. #include "stm32f4xx.h"
  32. #if 0 /* 不需要定义ST官方的板号 */
  33. #if defined(USE_STM322xG_EVAL)
  34. #include "stm322xg_eval.h"
  35. #include "stm322xg_eval_ioe.h"
  36. #include "stm322xg_eval_lcd.h"
  37. #include "stm322xg_eval_sdio_sd.h"
  38. #elif defined(USE_STM324xG_EVAL)
  39. #include "stm324xg_eval.h"
  40. #include "stm324xg_eval_ioe.h"
  41. #include "stm324xg_eval_lcd.h"
  42. #include "stm324xg_eval_sdio_sd.h"
  43. #include "stm32f4xx.h"
  44. #elif defined(USE_STM3210C_EVAL)
  45. #include "stm3210c_eval.h"
  46. #include "stm3210c_eval_ioe.h"
  47. #include "stm3210c_eval_lcd.h"
  48. #include "stm3210c_eval_spi_sd.h"
  49. #include "stm32f10x.h"
  50. #else
  51. #error "Missing define: Evaluation board (ie. USE_STM322xG_EVAL)"
  52. #endif
  53. #endif
  54. /** @addtogroup USB_OTG_DRIVER
  55. * @{
  56. */
  57. /** @defgroup USB_CONF
  58. * @brief USB low level driver configuration file
  59. * @{
  60. */
  61. /** @defgroup USB_CONF_Exported_Defines
  62. * @{
  63. */
  64. /* USB Core and PHY interface configuration.
  65. Tip: To avoid modifying these defines each time you need to change the USB
  66. configuration, you can declare the needed define in your toolchain
  67. compiler preprocessor.
  68. */
  69. /****************** USB OTG FS PHY CONFIGURATION *******************************
  70. * The USB OTG FS Core supports one on-chip Full Speed PHY.
  71. *
  72. * The USE_EMBEDDED_PHY symbol is defined in the project compiler preprocessor
  73. * when FS core is used.
  74. *******************************************************************************/
  75. #ifndef USE_USB_OTG_FS
  76. //#define USE_USB_OTG_FS
  77. #endif /* USE_USB_OTG_FS */
  78. #ifdef USE_USB_OTG_FS
  79. #define USB_OTG_FS_CORE
  80. #endif
  81. /****************** USB OTG HS PHY CONFIGURATION *******************************
  82. * The USB OTG HS Core supports two PHY interfaces:
  83. * (i) An ULPI interface for the external High Speed PHY: the USB HS Core will
  84. * operate in High speed mode
  85. * (ii) An on-chip Full Speed PHY: the USB HS Core will operate in Full speed mode
  86. *
  87. * You can select the PHY to be used using one of these two defines:
  88. * (i) USE_ULPI_PHY: if the USB OTG HS Core is to be used in High speed mode
  89. * (ii) USE_EMBEDDED_PHY: if the USB OTG HS Core is to be used in Full speed mode
  90. *
  91. * Notes:
  92. * - The USE_ULPI_PHY symbol is defined in the project compiler preprocessor as
  93. * default PHY when HS core is used.
  94. * - On STM322xG-EVAL and STM324xG-EVAL boards, only configuration(i) is available.
  95. * Configuration (ii) need a different hardware, for more details refer to your
  96. * STM32 device datasheet.
  97. *******************************************************************************/
  98. #ifndef USE_USB_OTG_HS
  99. //#define USE_USB_OTG_HS
  100. #endif /* USE_USB_OTG_HS */
  101. #ifndef USE_ULPI_PHY
  102. //#define USE_ULPI_PHY
  103. #endif /* USE_ULPI_PHY */
  104. #ifndef USE_EMBEDDED_PHY
  105. //#define USE_EMBEDDED_PHY
  106. #endif /* USE_EMBEDDED_PHY */
  107. #ifdef USE_USB_OTG_HS
  108. #define USB_OTG_HS_CORE
  109. #endif
  110. /*******************************************************************************
  111. * FIFO Size Configuration in Host mode
  112. *
  113. * (i) Receive data FIFO size = (Largest Packet Size / 4) + 1 or
  114. * 2x (Largest Packet Size / 4) + 1, If a
  115. * high-bandwidth channel or multiple isochronous
  116. * channels are enabled
  117. *
  118. * (ii) For the host nonperiodic Transmit FIFO is the largest maximum packet size
  119. * for all supported nonperiodic OUT channels. Typically, a space
  120. * corresponding to two Largest Packet Size is recommended.
  121. *
  122. * (iii) The minimum amount of RAM required for Host periodic Transmit FIFO is
  123. * the largest maximum packet size for all supported periodic OUT channels.
  124. * If there is at least one High Bandwidth Isochronous OUT endpoint,
  125. * then the space must be at least two times the maximum packet size for
  126. * that channel.
  127. *******************************************************************************/
  128. /****************** USB OTG HS CONFIGURATION **********************************/
  129. #ifdef USB_OTG_HS_CORE
  130. #define RX_FIFO_HS_SIZE 512
  131. #define TXH_NP_HS_FIFOSIZ 256
  132. #define TXH_P_HS_FIFOSIZ 256
  133. // #define USB_OTG_HS_LOW_PWR_MGMT_SUPPORT
  134. // #define USB_OTG_HS_SOF_OUTPUT_ENABLED
  135. #ifdef USE_ULPI_PHY
  136. #define USB_OTG_ULPI_PHY_ENABLED
  137. #endif
  138. #ifdef USE_EMBEDDED_PHY
  139. #define USB_OTG_EMBEDDED_PHY_ENABLED
  140. #endif
  141. #define USB_OTG_HS_INTERNAL_DMA_ENABLED
  142. #define USB_OTG_EXTERNAL_VBUS_ENABLED
  143. // #define USB_OTG_INTERNAL_VBUS_ENABLED
  144. #endif
  145. /****************** USB OTG FS CONFIGURATION **********************************/
  146. #ifdef USB_OTG_FS_CORE
  147. #define RX_FIFO_FS_SIZE 128
  148. #define TXH_NP_FS_FIFOSIZ 96
  149. #define TXH_P_FS_FIFOSIZ 96
  150. // #define USB_OTG_FS_LOW_PWR_MGMT_SUPPORT
  151. // #define USB_OTG_FS_SOF_OUTPUT_ENABLED
  152. #endif
  153. /****************** USB OTG MODE CONFIGURATION ********************************/
  154. #define USE_HOST_MODE
  155. //#define USE_DEVICE_MODE
  156. //#define USE_OTG_MODE
  157. #ifndef USB_OTG_FS_CORE
  158. #ifndef USB_OTG_HS_CORE
  159. #error "USB_OTG_HS_CORE or USB_OTG_FS_CORE should be defined"
  160. #endif
  161. #endif
  162. #ifndef USE_DEVICE_MODE
  163. #ifndef USE_HOST_MODE
  164. #error "USE_DEVICE_MODE or USE_HOST_MODE should be defined"
  165. #endif
  166. #endif
  167. #ifndef USE_USB_OTG_HS
  168. #ifndef USE_USB_OTG_FS
  169. #error "USE_USB_OTG_HS or USE_USB_OTG_FS should be defined"
  170. #endif
  171. #else // USE_USB_OTG_HS
  172. #ifndef USE_ULPI_PHY
  173. #ifndef USE_EMBEDDED_PHY
  174. #error "USE_ULPI_PHY or USE_EMBEDDED_PHY should be defined"
  175. #endif
  176. #endif
  177. #endif
  178. /****************** C Compilers dependant keywords ****************************/
  179. /* In HS mode and when the DMA is used, all variables and data structures dealing
  180. with the DMA during the transaction process should be 4-bytes aligned */
  181. #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
  182. #if defined(__GNUC__) /* GNU Compiler */
  183. #define __ALIGN_END __attribute__((aligned(4)))
  184. #define __ALIGN_BEGIN
  185. #else
  186. #define __ALIGN_END
  187. #if defined(__CC_ARM) /* ARM Compiler */
  188. #define __ALIGN_BEGIN __align(4)
  189. #elif defined(__ICCARM__) /* IAR Compiler */
  190. #define __ALIGN_BEGIN
  191. #elif defined(__TASKING__) /* TASKING Compiler */
  192. #define __ALIGN_BEGIN __align(4)
  193. #endif /* __CC_ARM */
  194. #endif /* __GNUC__ */
  195. #else
  196. #define __ALIGN_BEGIN
  197. #define __ALIGN_END
  198. #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
  199. /* __packed keyword used to decrease the data type alignment to 1-byte */
  200. #if defined(__CC_ARM) /* ARM Compiler */
  201. #define __packed __packed
  202. #elif defined(__ICCARM__) /* IAR Compiler */
  203. #define __packed __packed
  204. #elif defined(__GNUC__) /* GNU Compiler */
  205. #define __packed __attribute__((__packed__))
  206. #elif defined(__TASKING__) /* TASKING Compiler */
  207. #define __packed __unaligned
  208. #endif /* __CC_ARM */
  209. /**
  210. * @}
  211. */
  212. /** @defgroup USB_CONF_Exported_Types
  213. * @{
  214. */
  215. /**
  216. * @}
  217. */
  218. /** @defgroup USB_CONF_Exported_Macros
  219. * @{
  220. */
  221. /**
  222. * @}
  223. */
  224. /** @defgroup USB_CONF_Exported_Variables
  225. * @{
  226. */
  227. /**
  228. * @}
  229. */
  230. /** @defgroup USB_CONF_Exported_FunctionsPrototype
  231. * @{
  232. */
  233. /**
  234. * @}
  235. */
  236. #endif //__USB_CONF__H__
  237. /**
  238. * @}
  239. */
  240. /**
  241. * @}
  242. */
  243. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/