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