2 ******************************************************************************
4 * @author MCD Application Team
6 * @date 19-September-2011
7 * @brief General low level driver configuration
8 ******************************************************************************
11 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
18 * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
19 ******************************************************************************
22 /* Define to prevent recursive inclusion -------------------------------------*/
23 #ifndef __USB_CONF__H__
24 #define __USB_CONF__H__
26 /* Includes ------------------------------------------------------------------*/
27 #include "stm32f4xx.h"
30 /** @addtogroup USB_OTG_DRIVER
34 /** @defgroup USB_CONF
35 * @brief USB low level driver configuration file
39 /** @defgroup USB_CONF_Exported_Defines
43 /* USB Core and PHY interface configuration.
44 Tip: To avoid modifying these defines each time you need to change the USB
45 configuration, you can declare the needed define in your toolchain
46 compiler preprocessor.
48 #ifndef USE_USB_OTG_FS
49 //#define USE_USB_OTG_FS
50 #endif /* USE_USB_OTG_FS */
53 #define USB_OTG_FS_CORE
56 /*******************************************************************************
57 * FIFO Size Configuration in Device mode
59 * (i) Receive data FIFO size = RAM for setup packets +
60 * OUT endpoint control information +
61 * data OUT packets + miscellaneous
62 * Space = ONE 32-bits words
63 * --> RAM for setup packets = 10 spaces
64 * (n is the nbr of CTRL EPs the device core supports)
65 * --> OUT EP CTRL info = 1 space
66 * (one space for status information written to the FIFO along with each
68 * --> data OUT packets = (Largest Packet Size / 4) + 1 spaces
69 * (MINIMUM to receive packets)
70 * --> OR data OUT packets = at least 2*(Largest Packet Size / 4) + 1 spaces
71 * (if high-bandwidth EP is enabled or multiple isochronous EPs)
72 * --> miscellaneous = 1 space per OUT EP
73 * (one space for transfer complete status information also pushed to the
74 * FIFO with each endpoint's last packet)
76 * (ii)MINIMUM RAM space required for each IN EP Tx FIFO = MAX packet size for
77 * that particular IN EP. More space allocated in the IN EP Tx FIFO results
78 * in a better performance on the USB and can hide latencies on the AHB.
80 * (iii) TXn min size = 16 words. (n : Transmit FIFO index)
81 * (iv) When a TxFIFO is not used, the Configuration should be as follows:
82 * case 1 : n > m and Txn is not used (n,m : Transmit FIFO indexes)
83 * --> Txm can use the space allocated for Txn.
84 * case2 : n < m and Txn is not used (n,m : Transmit FIFO indexes)
85 * --> Txn should be configured with the minimum space of 16 words
86 * (v) The FIFO is used optimally when used TxFIFOs are allocated in the top
87 * of the FIFO.Ex: use EP1 and EP2 as IN instead of EP1 and EP3 as IN ones.
88 *******************************************************************************/
92 /****************** USB OTG FS CONFIGURATION **********************************/
93 #ifdef USB_OTG_FS_CORE
94 #define RX_FIFO_FS_SIZE 128
95 #define TX0_FIFO_FS_SIZE 64
96 #define TX1_FIFO_FS_SIZE 128
97 #define TX2_FIFO_FS_SIZE 0
98 #define TX3_FIFO_FS_SIZE 0
100 //#define USB_OTG_FS_LOW_PWR_MGMT_SUPPORT
101 //#define USB_OTG_FS_SOF_OUTPUT_ENABLED
104 /****************** USB OTG MODE CONFIGURATION ********************************/
106 //#define USE_HOST_MODE
107 #define USE_DEVICE_MODE
108 //#define USE_OTG_MODE
111 #ifndef USB_OTG_FS_CORE
112 #ifndef USB_OTG_HS_CORE
113 #error "USB_OTG_HS_CORE or USB_OTG_FS_CORE should be defined"
118 #ifndef USE_DEVICE_MODE
119 #ifndef USE_HOST_MODE
120 #error "USE_DEVICE_MODE or USE_HOST_MODE should be defined"
124 #ifndef USE_USB_OTG_HS
125 #ifndef USE_USB_OTG_FS
126 #error "USE_USB_OTG_HS or USE_USB_OTG_FS should be defined"
128 #else //USE_USB_OTG_HS
130 #ifndef USE_EMBEDDED_PHY
132 #error "USE_ULPI_PHY or USE_EMBEDDED_PHY or USE_I2C_PHY should be defined"
138 /****************** C Compilers dependant keywords ****************************/
139 /* In HS mode and when the DMA is used, all variables and data structures dealing
140 with the DMA during the transaction process should be 4-bytes aligned */
141 #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
142 #if defined (__GNUC__) /* GNU Compiler */
143 #define __ALIGN_END __attribute__ ((aligned (4)))
144 #define __ALIGN_BEGIN
147 #if defined (__CC_ARM) /* ARM Compiler */
148 #define __ALIGN_BEGIN __align(4)
149 #elif defined (__ICCARM__) /* IAR Compiler */
150 #define __ALIGN_BEGIN
151 #elif defined (__TASKING__) /* TASKING Compiler */
152 #define __ALIGN_BEGIN __align(4)
153 #endif /* __CC_ARM */
154 #endif /* __GNUC__ */
156 #define __ALIGN_BEGIN
158 #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
160 /* __packed keyword used to decrease the data type alignment to 1-byte */
161 #if defined (__CC_ARM) /* ARM Compiler */
162 #define __packed __packed
163 #elif defined (__ICCARM__) /* IAR Compiler */
164 #define __packed __packed
165 #elif defined ( __GNUC__ ) /* GNU Compiler */
166 #define __packed __attribute__ ((__packed__))
167 #elif defined (__TASKING__) /* TASKING Compiler */
168 #define __packed __unaligned
169 #endif /* __CC_ARM */
171 /****************** C Compilers dependant keywords ****************************/
172 /* In HS mode and when the DMA is used, all variables and data structures dealing
173 with the DMA during the transaction process should be 4-bytes aligned */
174 #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
175 #if defined (__GNUC__) /* GNU Compiler */
176 #define __ALIGN_END __attribute__ ((aligned (4)))
177 #define __ALIGN_BEGIN
180 #if defined (__CC_ARM) /* ARM Compiler */
181 #define __ALIGN_BEGIN __align(4)
182 #elif defined (__ICCARM__) /* IAR Compiler */
183 #define __ALIGN_BEGIN
184 #elif defined (__TASKING__) /* TASKING Compiler */
185 #define __ALIGN_BEGIN __align(4)
186 #endif /* __CC_ARM */
187 #endif /* __GNUC__ */
189 #define __ALIGN_BEGIN
191 #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
193 /* __packed keyword used to decrease the data type alignment to 1-byte */
194 #if defined (__CC_ARM) /* ARM Compiler */
195 #define __packed __packed
196 #elif defined (__ICCARM__) /* IAR Compiler */
197 #define __packed __packed
198 #elif defined ( __GNUC__ ) /* GNU Compiler */
199 #define __packed __attribute__ ((__packed__))
200 #elif defined (__TASKING__) /* TASKING Compiler */
201 #define __packed __unaligned
202 #endif /* __CC_ARM */
210 /** @defgroup USB_CONF_Exported_Types
218 /** @defgroup USB_CONF_Exported_Macros
225 /** @defgroup USB_CONF_Exported_Variables
232 /** @defgroup USB_CONF_Exported_FunctionsPrototype
240 #endif //__USB_CONF__H__
251 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/