remove test code
[inav.git] / src / main / vcpf4 / usbd_desc.c
blobcdba125ba4e8ee592fe580a69f2bd9567a471fe1
1 /**
2 ******************************************************************************
3 * @file usbd_desc.c
4 * @author MCD Application Team
5 * @version V1.0.0
6 * @date 19-September-2011
7 * @brief This file provides the USBD descriptors and string formating method.
8 ******************************************************************************
9 * @attention
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>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
19 ******************************************************************************
22 /* Includes ------------------------------------------------------------------*/
23 #include "usbd_core.h"
24 #include "usbd_desc.h"
25 #include "usbd_req.h"
26 #include "usbd_conf.h"
27 #include "usb_regs.h"
28 #include "platform.h"
29 #include "build/version.h"
31 /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
32 * @{
36 /** @defgroup USBD_DESC
37 * @brief USBD descriptors module
38 * @{
41 /** @defgroup USBD_DESC_Private_TypesDefinitions
42 * @{
44 /**
45 * @}
49 /** @defgroup USBD_DESC_Private_Defines
50 * @{
53 #define USBD_VID 0x0483
55 #define USBD_PID 0x5740
57 /** @defgroup USB_String_Descriptors
58 * @{
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
66 #else
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
74 #else
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"
85 /**
86 * @}
90 /** @defgroup USBD_DESC_Private_Macros
91 * @{
93 /**
94 * @}
98 /** @defgroup USBD_DESC_Private_Variables
99 * @{
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
117 #endif
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 =
122 0x12, /*bLength */
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
141 #endif
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,
148 0x00,
149 0x02,
150 0x00,
151 0x00,
152 0x00,
153 0x40,
154 0x01,
155 0x00,
158 #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
159 #if defined ( __ICCARM__ ) /*!< IAR Compiler */
160 #pragma data_alignment=4
161 #endif
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),
172 * @}
176 /** @defgroup USBD_DESC_Private_FunctionPrototypes
177 * @{
180 * @}
184 /** @defgroup USBD_DESC_Private_Functions
185 * @{
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)
197 (void)speed;
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)
211 (void)speed;
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)
228 if (speed == 0)
229 USBD_GetString ((uint8_t*)USBD_PRODUCT_HS_STRING, USBD_StrDesc, length);
230 else
231 USBD_GetString ((uint8_t*)USBD_PRODUCT_FS_STRING, USBD_StrDesc, length);
233 return USBD_StrDesc;
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)
245 (void)speed;
246 USBD_GetString ((uint8_t*)USBD_MANUFACTURER_STRING, USBD_StrDesc, length);
247 return USBD_StrDesc;
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);
261 else
262 USBD_GetString ((uint8_t*)USBD_SERIALNUMBER_FS_STRING, USBD_StrDesc, length);
264 return USBD_StrDesc;
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);
278 else
279 USBD_GetString ((uint8_t*)USBD_CONFIGURATION_FS_STRING, USBD_StrDesc, length);
281 return USBD_StrDesc;
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)
294 if (speed == 0)
295 USBD_GetString ((uint8_t*)USBD_INTERFACE_HS_STRING, USBD_StrDesc, length);
296 else
297 USBD_GetString ((uint8_t*)USBD_INTERFACE_FS_STRING, USBD_StrDesc, length);
299 return USBD_StrDesc;
303 * @}
308 * @}
313 * @}
316 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/