usb_conf_template.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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 "usb_conf.h"
  32. /** @addtogroup USB_OTG_DRIVER
  33. * @{
  34. */
  35. /** @defgroup USB_CONF
  36. * @brief USB low level driver configuration file
  37. * @{
  38. */
  39. /** @defgroup USB_CONF_Exported_Defines
  40. * @{
  41. */
  42. /* USB Core and PHY interface configuration.
  43. Tip: To avoid modifying these defines each time you need to change the USB
  44. configuration, you can declare the needed define in your toolchain
  45. compiler preprocessor.
  46. */
  47. /****************** USB OTG FS PHY CONFIGURATION *******************************
  48. * The USB OTG FS Core supports one on-chip Full Speed PHY.
  49. *
  50. * The USE_EMBEDDED_PHY symbol is defined in the project compiler preprocessor
  51. * when FS core is used.
  52. *******************************************************************************/
  53. #ifndef USE_USB_OTG_FS
  54. //#define USE_USB_OTG_FS
  55. #endif /* USE_USB_OTG_FS */
  56. #ifdef USE_USB_OTG_FS
  57. #define USB_OTG_FS_CORE
  58. #endif
  59. /****************** USB OTG HS PHY CONFIGURATION *******************************
  60. * The USB OTG HS Core supports two PHY interfaces:
  61. * (i) An ULPI interface for the external High Speed PHY: the USB HS Core will
  62. * operate in High speed mode
  63. * (ii) An on-chip Full Speed PHY: the USB HS Core will operate in Full speed mode
  64. *
  65. * You can select the PHY to be used using one of these two defines:
  66. * (i) USE_ULPI_PHY: if the USB OTG HS Core is to be used in High speed mode
  67. * (ii) USE_EMBEDDED_PHY: if the USB OTG HS Core is to be used in Full speed mode
  68. *
  69. * Notes:
  70. * - The USE_ULPI_PHY symbol is defined in the project compiler preprocessor as
  71. * default PHY when HS core is used.
  72. * - On STM322xG-EVAL and STM324xG-EVAL boards, only configuration(i) is available.
  73. * Configuration (ii) need a different hardware, for more details refer to your
  74. * STM32 device datasheet.
  75. *******************************************************************************/
  76. #ifndef USE_USB_OTG_HS
  77. //#define USE_USB_OTG_HS
  78. #endif /* USE_USB_OTG_HS */
  79. #ifndef USE_ULPI_PHY
  80. //#define USE_ULPI_PHY
  81. #endif /* USE_ULPI_PHY */
  82. #ifndef USE_EMBEDDED_PHY
  83. //#define USE_EMBEDDED_PHY
  84. #endif /* USE_EMBEDDED_PHY */
  85. #ifdef USE_USB_OTG_HS
  86. #define USB_OTG_HS_CORE
  87. #endif
  88. /*******************************************************************************
  89. * FIFO Size Configuration in Device mode
  90. *
  91. * (i) Receive data FIFO size = RAM for setup packets +
  92. * OUT endpoint control information +
  93. * data OUT packets + miscellaneous
  94. * Space = ONE 32-bits words
  95. * --> RAM for setup packets = 10 spaces
  96. * (n is the nbr of CTRL EPs the device core supports)
  97. * --> OUT EP CTRL info = 1 space
  98. * (one space for status information written to the FIFO along with each
  99. * received packet)
  100. * --> data OUT packets = (Largest Packet Size / 4) + 1 spaces
  101. * (MINIMUM to receive packets)
  102. * --> OR data OUT packets = at least 2*(Largest Packet Size / 4) + 1 spaces
  103. * (if high-bandwidth EP is enabled or multiple isochronous EPs)
  104. * --> miscellaneous = 1 space per OUT EP
  105. * (one space for transfer complete status information also pushed to the
  106. * FIFO with each endpoint's last packet)
  107. *
  108. * (ii)MINIMUM RAM space required for each IN EP Tx FIFO = MAX packet size for
  109. * that particular IN EP. More space allocated in the IN EP Tx FIFO results
  110. * in a better performance on the USB and can hide latencies on the AHB.
  111. *
  112. * (iii) TXn min size = 16 words. (n : Transmit FIFO index)
  113. * (iv) When a TxFIFO is not used, the Configuration should be as follows:
  114. * case 1 : n > m and Txn is not used (n,m : Transmit FIFO indexes)
  115. * --> Txm can use the space allocated for Txn.
  116. * case2 : n < m and Txn is not used (n,m : Transmit FIFO indexes)
  117. * --> Txn should be configured with the minimum space of 16 words
  118. * (v) The FIFO is used optimally when used TxFIFOs are allocated in the top
  119. * of the FIFO.Ex: use EP1 and EP2 as IN instead of EP1 and EP3 as IN ones.
  120. *******************************************************************************/
  121. /*******************************************************************************
  122. * FIFO Size Configuration in Host mode
  123. *
  124. * (i) Receive data FIFO size = (Largest Packet Size / 4) + 1 or
  125. * 2x (Largest Packet Size / 4) + 1, If a
  126. * high-bandwidth channel or multiple isochronous
  127. * channels are enabled
  128. *
  129. * (ii) For the host nonperiodic Transmit FIFO is the largest maximum packet size
  130. * for all supported nonperiodic OUT channels. Typically, a space
  131. * corresponding to two Largest Packet Size is recommended.
  132. *
  133. * (iii) The minimum amount of RAM required for Host periodic Transmit FIFO is
  134. * the largest maximum packet size for all supported periodic OUT channels.
  135. * If there is at least one High Bandwidth Isochronous OUT endpoint,
  136. * then the space must be at least two times the maximum packet size for
  137. * that channel.
  138. *******************************************************************************/
  139. /****************** USB OTG HS CONFIGURATION **********************************/
  140. #ifdef USB_OTG_HS_CORE
  141. #define RX_FIFO_HS_SIZE 512
  142. #define TX0_FIFO_HS_SIZE 512
  143. #define TX1_FIFO_HS_SIZE 512
  144. #define TX2_FIFO_HS_SIZE 0
  145. #define TX3_FIFO_HS_SIZE 0
  146. #define TX4_FIFO_HS_SIZE 0
  147. #define TX5_FIFO_HS_SIZE 0
  148. #define TXH_NP_HS_FIFOSIZ 96
  149. #define TXH_P_HS_FIFOSIZ 96
  150. // #define USB_OTG_HS_LOW_PWR_MGMT_SUPPORT
  151. // #define USB_OTG_HS_SOF_OUTPUT_ENABLED
  152. // #define USB_OTG_INTERNAL_VBUS_ENABLED
  153. #define USB_OTG_EXTERNAL_VBUS_ENABLED
  154. #ifdef USE_ULPI_PHY
  155. #define USB_OTG_ULPI_PHY_ENABLED
  156. #endif
  157. #ifdef USE_EMBEDDED_PHY
  158. #define USB_OTG_EMBEDDED_PHY_ENABLED
  159. #endif
  160. #define USB_OTG_HS_INTERNAL_DMA_ENABLED
  161. #define USB_OTG_HS_DEDICATED_EP1_ENABLED
  162. #endif
  163. /****************** USB OTG FS CONFIGURATION **********************************/
  164. #ifdef USB_OTG_FS_CORE
  165. #define RX_FIFO_FS_SIZE 128
  166. #define TX0_FIFO_FS_SIZE 64
  167. #define TX1_FIFO_FS_SIZE 128
  168. #define TX2_FIFO_FS_SIZE 0
  169. #define TX3_FIFO_FS_SIZE 0
  170. #define TXH_NP_HS_FIFOSIZ 96
  171. #define TXH_P_HS_FIFOSIZ 96
  172. // #define USB_OTG_FS_LOW_PWR_MGMT_SUPPORT
  173. // #define USB_OTG_FS_SOF_OUTPUT_ENABLED
  174. #endif
  175. /****************** USB OTG MISC CONFIGURATION ********************************/
  176. //#define VBUS_SENSING_ENABLED
  177. /****************** USB OTG MODE CONFIGURATION ********************************/
  178. //#define USE_HOST_MODE
  179. #define USE_DEVICE_MODE
  180. //#define USE_OTG_MODE
  181. #ifndef USB_OTG_FS_CORE
  182. #ifndef USB_OTG_HS_CORE
  183. #error "USB_OTG_HS_CORE or USB_OTG_FS_CORE should be defined"
  184. #endif
  185. #endif
  186. #ifndef USE_DEVICE_MODE
  187. #ifndef USE_HOST_MODE
  188. #error "USE_DEVICE_MODE or USE_HOST_MODE should be defined"
  189. #endif
  190. #endif
  191. #ifndef USE_USB_OTG_HS
  192. #ifndef USE_USB_OTG_FS
  193. #error "USE_USB_OTG_HS or USE_USB_OTG_FS should be defined"
  194. #endif
  195. #else //USE_USB_OTG_HS
  196. #ifndef USE_ULPI_PHY
  197. #ifndef USE_EMBEDDED_PHY
  198. #error "USE_ULPI_PHY or USE_EMBEDDED_PHY should be defined"
  199. #endif
  200. #endif
  201. #endif
  202. /****************** C Compilers dependant keywords ****************************/
  203. /* In HS mode and when the DMA is used, all variables and data structures dealing
  204. with the DMA during the transaction process should be 4-bytes aligned */
  205. #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
  206. #if defined (__GNUC__) /* GNU Compiler */
  207. #define __ALIGN_END __attribute__ ((aligned (4)))
  208. #define __ALIGN_BEGIN
  209. #else
  210. #define __ALIGN_END
  211. #if defined (__CC_ARM) /* ARM Compiler */
  212. #define __ALIGN_BEGIN __align(4)
  213. #elif defined (__ICCARM__) /* IAR Compiler */
  214. #define __ALIGN_BEGIN
  215. #elif defined (__TASKING__) /* TASKING Compiler */
  216. #define __ALIGN_BEGIN __align(4)
  217. #endif /* __CC_ARM */
  218. #endif /* __GNUC__ */
  219. #else
  220. #define __ALIGN_BEGIN
  221. #define __ALIGN_END
  222. #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
  223. /* __packed keyword used to decrease the data type alignment to 1-byte */
  224. #if defined (__CC_ARM) /* ARM Compiler */
  225. #define __packed __packed
  226. #elif defined (__ICCARM__) /* IAR Compiler */
  227. #define __packed __packed
  228. #elif defined ( __GNUC__ ) /* GNU Compiler */
  229. #define __packed __attribute__ ((__packed__))
  230. #elif defined (__TASKING__) /* TASKING Compiler */
  231. #define __packed __unaligned
  232. #endif /* __CC_ARM */
  233. /**
  234. * @}
  235. */
  236. /** @defgroup USB_CONF_Exported_Types
  237. * @{
  238. */
  239. /**
  240. * @}
  241. */
  242. /** @defgroup USB_CONF_Exported_Macros
  243. * @{
  244. */
  245. /**
  246. * @}
  247. */
  248. /** @defgroup USB_CONF_Exported_Variables
  249. * @{
  250. */
  251. /**
  252. * @}
  253. */
  254. /** @defgroup USB_CONF_Exported_FunctionsPrototype
  255. * @{
  256. */
  257. /**
  258. * @}
  259. */
  260. #endif //__USB_CONF__H__
  261. /**
  262. * @}
  263. */
  264. /**
  265. * @}
  266. */
  267. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/