2 ******************************************************************************
4 * @author MCD Application Team
6 * @date 19-September-2011
7 * @brief This file provides the USBD descriptors and string formating method.
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 /* Includes ------------------------------------------------------------------*/
23 #include "usbd_core.h"
24 #include "usbd_desc.h"
26 #include "usbd_conf.h"
29 #include "build/version.h"
31 /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
36 /** @defgroup USBD_DESC
37 * @brief USBD descriptors module
41 /** @defgroup USBD_DESC_Private_TypesDefinitions
49 /** @defgroup USBD_DESC_Private_Defines
53 #define USBD_VID 0x0483
55 #define USBD_PID 0x5740
57 /** @defgroup USB_String_Descriptors
60 #define USBD_LANGID_STRING 0x409
61 #define USBD_MANUFACTURER_STRING FC_FIRMWARE_NAME
63 #ifdef USBD_PRODUCT_STRING
64 #define USBD_PRODUCT_HS_STRING USBD_PRODUCT_STRING
65 #define USBD_PRODUCT_FS_STRING USBD_PRODUCT_STRING
67 #define USBD_PRODUCT_HS_STRING "STM32 Virtual ComPort in HS mode"
68 #define USBD_PRODUCT_FS_STRING "STM32 Virtual ComPort in FS Mode"
69 #endif /* USBD_PRODUCT_STRING */
71 #ifdef USBD_SERIALNUMBER_STRING
72 #define USBD_SERIALNUMBER_HS_STRING USBD_SERIALNUMBER_STRING
73 #define USBD_SERIALNUMBER_FS_STRING USBD_SERIALNUMBER_STRING
75 // start of STM32 flash
76 #define USBD_SERIALNUMBER_HS_STRING "0x8000000"
77 #define USBD_SERIALNUMBER_FS_STRING "0x8000000"
78 #endif /* USBD_SERIALNUMBER_STRING */
80 #define USBD_CONFIGURATION_HS_STRING "VCP Config"
81 #define USBD_INTERFACE_HS_STRING "VCP Interface"
83 #define USBD_CONFIGURATION_FS_STRING "VCP Config"
84 #define USBD_INTERFACE_FS_STRING "VCP Interface"
90 /** @defgroup USBD_DESC_Private_Macros
98 /** @defgroup USBD_DESC_Private_Variables
102 USBD_DEVICE USR_desc
=
104 USBD_USR_DeviceDescriptor
,
105 USBD_USR_LangIDStrDescriptor
,
106 USBD_USR_ManufacturerStrDescriptor
,
107 USBD_USR_ProductStrDescriptor
,
108 USBD_USR_SerialStrDescriptor
,
109 USBD_USR_ConfigStrDescriptor
,
110 USBD_USR_InterfaceStrDescriptor
,
114 #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
115 #if defined ( __ICCARM__ ) /*!< IAR Compiler */
116 #pragma data_alignment=4
118 #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
119 /* USB Standard Device Descriptor */
120 __ALIGN_BEGIN
uint8_t USBD_DeviceDesc
[USB_SIZ_DEVICE_DESC
] __ALIGN_END
=
123 USB_DEVICE_DESCRIPTOR_TYPE
, /*bDescriptorType*/
124 0x00, 0x02, /*bcdUSB */
125 0x02, /*bDeviceClass*/
126 0x02, /*bDeviceSubClass*/
127 0x00, /*bDeviceProtocol*/
128 USB_OTG_MAX_EP0_SIZE
, /*bMaxPacketSize*/
129 LOBYTE(USBD_VID
), HIBYTE(USBD_VID
), /*idVendor*/
130 LOBYTE(USBD_PID
), HIBYTE(USBD_PID
), /*idProduct*/
131 0x00, 0x02, /*bcdDevice rel. 2.00*/
132 USBD_IDX_MFC_STR
, /*Index of manufacturer string*/
133 USBD_IDX_PRODUCT_STR
, /*Index of product string*/
134 USBD_IDX_SERIAL_STR
, /*Index of serial number string*/
135 USBD_CFG_MAX_NUM
/*bNumConfigurations*/
136 } ; /* USB_DeviceDescriptor */
138 #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
139 #if defined ( __ICCARM__ ) /*!< IAR Compiler */
140 #pragma data_alignment=4
142 #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
143 /* USB Standard Device Descriptor */
144 __ALIGN_BEGIN
uint8_t USBD_DeviceQualifierDesc
[USB_LEN_DEV_QUALIFIER_DESC
] __ALIGN_END
=
146 USB_LEN_DEV_QUALIFIER_DESC
,
147 USB_DESC_TYPE_DEVICE_QUALIFIER
,
158 #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
159 #if defined ( __ICCARM__ ) /*!< IAR Compiler */
160 #pragma data_alignment=4
162 #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
163 /* USB Standard Device Descriptor */
164 __ALIGN_BEGIN
uint8_t USBD_LangIDDesc
[USB_SIZ_STRING_LANGID
] __ALIGN_END
=
166 USB_SIZ_STRING_LANGID
,
167 USB_DESC_TYPE_STRING
,
168 LOBYTE(USBD_LANGID_STRING
),
169 HIBYTE(USBD_LANGID_STRING
),
176 /** @defgroup USBD_DESC_Private_FunctionPrototypes
184 /** @defgroup USBD_DESC_Private_Functions
189 * @brief USBD_USR_DeviceDescriptor
190 * return the device descriptor
191 * @param speed : current device speed
192 * @param length : pointer to data length variable
193 * @retval pointer to descriptor buffer
195 uint8_t * USBD_USR_DeviceDescriptor( uint8_t speed
, uint16_t *length
)
198 *length
= sizeof(USBD_DeviceDesc
);
199 return USBD_DeviceDesc
;
203 * @brief USBD_USR_LangIDStrDescriptor
204 * return the LangID string descriptor
205 * @param speed : current device speed
206 * @param length : pointer to data length variable
207 * @retval pointer to descriptor buffer
209 uint8_t * USBD_USR_LangIDStrDescriptor( uint8_t speed
, uint16_t *length
)
212 *length
= sizeof(USBD_LangIDDesc
);
213 return USBD_LangIDDesc
;
218 * @brief USBD_USR_ProductStrDescriptor
219 * return the product string descriptor
220 * @param speed : current device speed
221 * @param length : pointer to data length variable
222 * @retval pointer to descriptor buffer
224 uint8_t * USBD_USR_ProductStrDescriptor( uint8_t speed
, uint16_t *length
)
229 USBD_GetString ((uint8_t*)USBD_PRODUCT_HS_STRING
, USBD_StrDesc
, length
);
231 USBD_GetString ((uint8_t*)USBD_PRODUCT_FS_STRING
, USBD_StrDesc
, length
);
237 * @brief USBD_USR_ManufacturerStrDescriptor
238 * return the manufacturer string descriptor
239 * @param speed : current device speed
240 * @param length : pointer to data length variable
241 * @retval pointer to descriptor buffer
243 uint8_t * USBD_USR_ManufacturerStrDescriptor( uint8_t speed
, uint16_t *length
)
246 USBD_GetString ((uint8_t*)USBD_MANUFACTURER_STRING
, USBD_StrDesc
, length
);
251 * @brief USBD_USR_SerialStrDescriptor
252 * return the serial number string descriptor
253 * @param speed : current device speed
254 * @param length : pointer to data length variable
255 * @retval pointer to descriptor buffer
257 uint8_t * USBD_USR_SerialStrDescriptor( uint8_t speed
, uint16_t *length
)
259 if (speed
== USB_OTG_SPEED_HIGH
)
260 USBD_GetString ((uint8_t*)USBD_SERIALNUMBER_HS_STRING
, USBD_StrDesc
, length
);
262 USBD_GetString ((uint8_t*)USBD_SERIALNUMBER_FS_STRING
, USBD_StrDesc
, length
);
268 * @brief USBD_USR_ConfigStrDescriptor
269 * return the configuration string descriptor
270 * @param speed : current device speed
271 * @param length : pointer to data length variable
272 * @retval pointer to descriptor buffer
274 uint8_t * USBD_USR_ConfigStrDescriptor( uint8_t speed
, uint16_t *length
)
276 if (speed
== USB_OTG_SPEED_HIGH
)
277 USBD_GetString ((uint8_t*)USBD_CONFIGURATION_HS_STRING
, USBD_StrDesc
, length
);
279 USBD_GetString ((uint8_t*)USBD_CONFIGURATION_FS_STRING
, USBD_StrDesc
, length
);
286 * @brief USBD_USR_InterfaceStrDescriptor
287 * return the interface string descriptor
288 * @param speed : current device speed
289 * @param length : pointer to data length variable
290 * @retval pointer to descriptor buffer
292 uint8_t * USBD_USR_InterfaceStrDescriptor( uint8_t speed
, uint16_t *length
)
295 USBD_GetString ((uint8_t*)USBD_INTERFACE_HS_STRING
, USBD_StrDesc
, length
);
297 USBD_GetString ((uint8_t*)USBD_INTERFACE_FS_STRING
, USBD_StrDesc
, length
);
316 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/