APM:Libraries
usb_conf.h
Go to the documentation of this file.
1 
22 /* Define to prevent recursive inclusion -------------------------------------*/
23 #ifndef __USB_CONF__H__
24 #define __USB_CONF__H__
25 
26 /* Includes ------------------------------------------------------------------*/
27 #include "stm32f4xx.h"
28 
29 // USE_ULPI_PHY: if the USB OTG HS Core is to be used in High speed mode
30 // USE_EMBEDDED_PHY: if the USB OTG HS Core is to be used in Full speed mode
31 //#define USE_OTG_FS_CORE
32 //#define USE_USB_OTG_FS
33 //#define USE_EMBEDDED_PHY
34 
35 //#define VBUS_SENSING_ENABLED
36 
50 /* USB Core and PHY interface configuration.
51  Tip: To avoid modifying these defines each time you need to change the USB
52  configuration, you can declare the needed define in your toolchain
53  compiler preprocessor.
54  */
55 #ifndef USE_USB_OTG_FS
56  #define USE_USB_OTG_FS
57 #endif /* USE_USB_OTG_FS */
58 
59 #ifdef USE_USB_OTG_FS
60  #define USB_OTG_FS_CORE
61 #endif
62 
63 /*******************************************************************************
64 * FIFO Size Configuration in Device mode
65 *
66 * (i) Receive data FIFO size = RAM for setup packets +
67 * OUT endpoint control information +
68 * data OUT packets + miscellaneous
69 * Space = ONE 32-bits words
70 * --> RAM for setup packets = 10 spaces
71 * (n is the nbr of CTRL EPs the device core supports)
72 * --> OUT EP CTRL info = 1 space
73 * (one space for status information written to the FIFO along with each
74 * received packet)
75 * --> data OUT packets = (Largest Packet Size / 4) + 1 spaces
76 * (MINIMUM to receive packets)
77 * --> OR data OUT packets = at least 2*(Largest Packet Size / 4) + 1 spaces
78 * (if high-bandwidth EP is enabled or multiple isochronous EPs)
79 * --> miscellaneous = 1 space per OUT EP
80 * (one space for transfer complete status information also pushed to the
81 * FIFO with each endpoint's last packet)
82 *
83 * (ii)MINIMUM RAM space required for each IN EP Tx FIFO = MAX packet size for
84 * that particular IN EP. More space allocated in the IN EP Tx FIFO results
85 * in a better performance on the USB and can hide latencies on the AHB.
86 *
87 * (iii) TXn min size = 16 words. (n : Transmit FIFO index)
88 * (iv) When a TxFIFO is not used, the Configuration should be as follows:
89 * case 1 : n > m and Txn is not used (n,m : Transmit FIFO indexes)
90 * --> Txm can use the space allocated for Txn.
91 * case2 : n < m and Txn is not used (n,m : Transmit FIFO indexes)
92 * --> Txn should be configured with the minimum space of 16 words
93 * (v) The FIFO is used optimally when used TxFIFOs are allocated in the top
94 * of the FIFO.Ex: use EP1 and EP2 as IN instead of EP1 and EP3 as IN ones.
95 *******************************************************************************/
96 
97 
98 
99 /****************** USB OTG FS CONFIGURATION **********************************/
100 #ifdef USB_OTG_FS_CORE
101  #define RX_FIFO_FS_SIZE 128
102  #define TX0_FIFO_FS_SIZE 64
103  #define TX1_FIFO_FS_SIZE 128
104  #define TX2_FIFO_FS_SIZE 0
105  #define TX3_FIFO_FS_SIZE 0
106 
107  //#define USB_OTG_FS_LOW_PWR_MGMT_SUPPORT
108  //#define USB_OTG_FS_SOF_OUTPUT_ENABLED
109 #endif
110 
111 /****************** USB OTG MODE CONFIGURATION ********************************/
112 
113 //#define USE_HOST_MODE
114 #define USE_DEVICE_MODE
115 //#define USE_OTG_MODE
116 
117 
118 #ifndef USB_OTG_FS_CORE
119  #ifndef USB_OTG_HS_CORE
120  #error "USB_OTG_HS_CORE or USB_OTG_FS_CORE should be defined"
121  #endif
122 #endif
123 
124 
125 #ifndef USE_DEVICE_MODE
126  #ifndef USE_HOST_MODE
127  #error "USE_DEVICE_MODE or USE_HOST_MODE should be defined"
128  #endif
129 #endif
130 
131 #ifndef USE_USB_OTG_HS
132  #ifndef USE_USB_OTG_FS
133  #error "USE_USB_OTG_HS or USE_USB_OTG_FS should be defined"
134  #endif
135 #else //USE_USB_OTG_HS
136  #ifndef USE_ULPI_PHY
137  #ifndef USE_EMBEDDED_PHY
138  #ifndef USE_I2C_PHY
139  #error "USE_ULPI_PHY or USE_EMBEDDED_PHY or USE_I2C_PHY should be defined"
140  #endif
141  #endif
142  #endif
143 #endif
144 
145 /****************** C Compilers dependant keywords ****************************/
146 /* In HS mode and when the DMA is used, all variables and data structures dealing
147  with the DMA during the transaction process should be 4-bytes aligned */
148 #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
149  #if defined (__GNUC__) /* GNU Compiler */
150  #define __ALIGN_END __attribute__ ((aligned (4)))
151  #define __ALIGN_BEGIN
152  #else
153  #define __ALIGN_END
154  #if defined (__CC_ARM) /* ARM Compiler */
155  #define __ALIGN_BEGIN __align(4)
156  #elif defined (__ICCARM__) /* IAR Compiler */
157  #define __ALIGN_BEGIN
158  #elif defined (__TASKING__) /* TASKING Compiler */
159  #define __ALIGN_BEGIN __align(4)
160  #endif /* __CC_ARM */
161  #endif /* __GNUC__ */
162 #else
163  #define __ALIGN_BEGIN
164  #define __ALIGN_END
165 #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
166 
167 /* __packed keyword used to decrease the data type alignment to 1-byte */
168 #if defined (__CC_ARM) /* ARM Compiler */
169  #define __packed __packed
170 #elif defined (__ICCARM__) /* IAR Compiler */
171  #define __packed __packed
172 #elif defined ( __GNUC__ ) /* GNU Compiler */
173  #ifndef __packed
174  #define __packed __attribute__ ((__packed__))
175  #endif
176 #elif defined (__TASKING__) /* TASKING Compiler */
177  #define __packed __unaligned
178 #endif /* __CC_ARM */
179 
180 /****************** C Compilers dependant keywords ****************************/
181 /* In HS mode and when the DMA is used, all variables and data structures dealing
182  with the DMA during the transaction process should be 4-bytes aligned */
183 #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
184  #if defined (__GNUC__) /* GNU Compiler */
185  #define __ALIGN_END __attribute__ ((aligned (4)))
186  #define __ALIGN_BEGIN
187  #else
188  #define __ALIGN_END
189  #if defined (__CC_ARM) /* ARM Compiler */
190  #define __ALIGN_BEGIN __align(4)
191  #elif defined (__ICCARM__) /* IAR Compiler */
192  #define __ALIGN_BEGIN
193  #elif defined (__TASKING__) /* TASKING Compiler */
194  #define __ALIGN_BEGIN __align(4)
195  #endif /* __CC_ARM */
196  #endif /* __GNUC__ */
197 #else
198  #define __ALIGN_BEGIN
199  #define __ALIGN_END
200 #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
201 
202 /* __packed keyword used to decrease the data type alignment to 1-byte */
203 #if defined (__CC_ARM) /* ARM Compiler */
204  #define __packed __packed
205 #elif defined (__ICCARM__) /* IAR Compiler */
206  #define __packed __packed
207 #elif defined ( __GNUC__ ) /* GNU Compiler */
208  #ifndef __packed
209  #define __packed __attribute__((__packed__))
210  #endif
211 #elif defined (__TASKING__) /* TASKING Compiler */
212  #define __packed __unaligned
213 #endif /* __CC_ARM */
214 
215 #define MIN(a,b) (((a)<(b))?(a):(b))
216 
252 #endif //__USB_CONF__H__
253 
254 
263 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/