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 /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
34 /** @defgroup USBD_DESC
35 * @brief USBD descriptors module
39 /** @defgroup USBD_DESC_Private_TypesDefinitions
47 /** @defgroup USBD_DESC_Private_Defines
51 #define USBD_VID 0x0483
52 #define USBD_PID 0x5710
54 #define USBD_LANGID_STRING 0x409
55 #define USBD_MANUFACTURER_STRING "STMicroelectronics"
57 #define USBD_PRODUCT_HS_STRING "Joystick in HS mode"
58 #define USBD_SERIALNUMBER_HS_STRING "00000000011B"
60 #define USBD_PRODUCT_FS_STRING "Joystick in FS Mode"
61 #define USBD_SERIALNUMBER_FS_STRING "00000000011C"
63 #define USBD_CONFIGURATION_HS_STRING "HID Config"
64 #define USBD_INTERFACE_HS_STRING "HID Interface"
66 #define USBD_CONFIGURATION_FS_STRING "HID Config"
67 #define USBD_INTERFACE_FS_STRING "HID Interface"
73 /** @defgroup USBD_DESC_Private_Macros
81 /** @defgroup USBD_DESC_Private_Variables
85 USBD_DEVICE USR_desc =
87 USBD_USR_DeviceDescriptor,
88 USBD_USR_LangIDStrDescriptor,
89 USBD_USR_ManufacturerStrDescriptor,
90 USBD_USR_ProductStrDescriptor,
91 USBD_USR_SerialStrDescriptor,
92 USBD_USR_ConfigStrDescriptor,
93 USBD_USR_InterfaceStrDescriptor,
97 #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
98 #if defined ( __ICCARM__ ) /*!< IAR Compiler */
99 #pragma data_alignment=4
101 #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
102 /* USB Standard Device Descriptor */
103 __ALIGN_BEGIN uint8_t USBD_DeviceDesc[USB_SIZ_DEVICE_DESC] __ALIGN_END =
106 USB_DEVICE_DESCRIPTOR_TYPE, /*bDescriptorType*/
109 0x00, /*bDeviceClass*/
110 0x00, /*bDeviceSubClass*/
111 0x00, /*bDeviceProtocol*/
112 USB_OTG_MAX_EP0_SIZE, /*bMaxPacketSize*/
113 LOBYTE(USBD_VID), /*idVendor*/
114 HIBYTE(USBD_VID), /*idVendor*/
115 LOBYTE(USBD_PID), /*idVendor*/
116 HIBYTE(USBD_PID), /*idVendor*/
117 0x00, /*bcdDevice rel. 2.00*/
119 USBD_IDX_MFC_STR, /*Index of manufacturer string*/
120 USBD_IDX_PRODUCT_STR, /*Index of product string*/
121 USBD_IDX_SERIAL_STR, /*Index of serial number string*/
122 USBD_CFG_MAX_NUM /*bNumConfigurations*/
123 } ; /* USB_DeviceDescriptor */
125 #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
126 #if defined ( __ICCARM__ ) /*!< IAR Compiler */
127 #pragma data_alignment=4
129 #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
130 /* USB Standard Device Descriptor */
131 __ALIGN_BEGIN uint8_t USBD_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] __ALIGN_END =
133 USB_LEN_DEV_QUALIFIER_DESC,
134 USB_DESC_TYPE_DEVICE_QUALIFIER,
145 #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
146 #if defined ( __ICCARM__ ) /*!< IAR Compiler */
147 #pragma data_alignment=4
149 #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
150 /* USB Standard Device Descriptor */
151 __ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_SIZ_STRING_LANGID] __ALIGN_END =
153 USB_SIZ_STRING_LANGID,
154 USB_DESC_TYPE_STRING,
155 LOBYTE(USBD_LANGID_STRING),
156 HIBYTE(USBD_LANGID_STRING),
163 /** @defgroup USBD_DESC_Private_FunctionPrototypes
171 /** @defgroup USBD_DESC_Private_Functions
176 * @brief USBD_USR_DeviceDescriptor
177 * return the device descriptor
178 * @param speed : current device speed
179 * @param length : pointer to data length variable
180 * @retval pointer to descriptor buffer
182 uint8_t * USBD_USR_DeviceDescriptor( uint8_t speed , uint16_t *length)
184 *length = sizeof(USBD_DeviceDesc);
185 return USBD_DeviceDesc;
189 * @brief USBD_USR_LangIDStrDescriptor
190 * return the LangID string 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_LangIDStrDescriptor( uint8_t speed , uint16_t *length)
197 *length = sizeof(USBD_LangIDDesc);
198 return USBD_LangIDDesc;
203 * @brief USBD_USR_ProductStrDescriptor
204 * return the product 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_ProductStrDescriptor( uint8_t speed , uint16_t *length)
215 USBD_GetString (USBD_PRODUCT_HS_STRING, USBD_StrDesc, length);
219 USBD_GetString (USBD_PRODUCT_FS_STRING, USBD_StrDesc, length);
225 * @brief USBD_USR_ManufacturerStrDescriptor
226 * return the manufacturer string descriptor
227 * @param speed : current device speed
228 * @param length : pointer to data length variable
229 * @retval pointer to descriptor buffer
231 uint8_t * USBD_USR_ManufacturerStrDescriptor( uint8_t speed , uint16_t *length)
233 USBD_GetString (USBD_MANUFACTURER_STRING, USBD_StrDesc, length);
238 * @brief USBD_USR_SerialStrDescriptor
239 * return the serial number string descriptor
240 * @param speed : current device speed
241 * @param length : pointer to data length variable
242 * @retval pointer to descriptor buffer
244 uint8_t * USBD_USR_SerialStrDescriptor( uint8_t speed , uint16_t *length)
246 if(speed == USB_OTG_SPEED_HIGH)
248 USBD_GetString (USBD_SERIALNUMBER_HS_STRING, USBD_StrDesc, length);
252 USBD_GetString (USBD_SERIALNUMBER_FS_STRING, USBD_StrDesc, length);
258 * @brief USBD_USR_ConfigStrDescriptor
259 * return the configuration string descriptor
260 * @param speed : current device speed
261 * @param length : pointer to data length variable
262 * @retval pointer to descriptor buffer
264 uint8_t * USBD_USR_ConfigStrDescriptor( uint8_t speed , uint16_t *length)
266 if(speed == USB_OTG_SPEED_HIGH)
268 USBD_GetString (USBD_CONFIGURATION_HS_STRING, USBD_StrDesc, length);
272 USBD_GetString (USBD_CONFIGURATION_FS_STRING, USBD_StrDesc, length);
279 * @brief USBD_USR_InterfaceStrDescriptor
280 * return the interface string descriptor
281 * @param speed : current device speed
282 * @param length : pointer to data length variable
283 * @retval pointer to descriptor buffer
285 uint8_t * USBD_USR_InterfaceStrDescriptor( uint8_t speed , uint16_t *length)
289 USBD_GetString (USBD_INTERFACE_HS_STRING, USBD_StrDesc, length);
293 USBD_GetString (USBD_INTERFACE_FS_STRING, USBD_StrDesc, length);
312 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/