APM:Libraries
device_desc.c
Go to the documentation of this file.
1 
32 /* Includes ------------------------------------------------------------------*/
33 #include "usbd_core.h"
34 #include "usbd_desc.h"
35 #include "usbd_req.h"
36 #include "usbd_conf.h"
37 #include "usb_regs.h"
38 
61 #define USBD_VID 0x0483
62 #define USBD_PID 0x5720
63 
64 #define USBD_LANGID_STRING 0x409
65 #define USBD_MANUFACTURER_STRING "STMicroelectronics"
66 
67 
68 #define USBD_PRODUCT_HS_STRING "Mass Storage in HS Mode"
69 #define USBD_SERIALNUMBER_HS_STRING "00000000001A"
70 #define USBD_PRODUCT_FS_STRING "Mass Storage in FS Mode"
71 #define USBD_SERIALNUMBER_FS_STRING "00000000001B"
72 #define USBD_CONFIGURATION_HS_STRING "MSC Config"
73 #define USBD_INTERFACE_HS_STRING "MSC Interface"
74 #define USBD_CONFIGURATION_FS_STRING "MSC Config"
75 #define USBD_INTERFACE_FS_STRING "MSC Interface"
76 
89 uint8_t * USBD_MSC_DeviceDescriptor( uint8_t speed , uint16_t *length);
90 uint8_t * USBD_MSC_LangIDStrDescriptor( uint8_t speed , uint16_t *length);
91 uint8_t * USBD_MSC_ManufacturerStrDescriptor ( uint8_t speed , uint16_t *length);
92 uint8_t * USBD_MSC_ProductStrDescriptor ( uint8_t speed , uint16_t *length);
93 uint8_t * USBD_MSC_SerialStrDescriptor( uint8_t speed , uint16_t *length);
94 uint8_t * USBD_MSC_ConfigStrDescriptor( uint8_t speed , uint16_t *length);
95 uint8_t * USBD_MSC_InterfaceStrDescriptor( uint8_t speed , uint16_t *length);
96 
97 #ifdef USB_SUPPORT_USER_STRING_DESC
98 uint8_t * USBD_MSC_USRStringDesc (uint8_t speed, uint8_t idx , uint16_t *length);
99 #endif /* USB_SUPPORT_USER_STRING_DESC */
100 
106 {
114 
115 };
116 
117 #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
118  #if defined ( __ICCARM__ )
119  #pragma data_alignment=4
120  #endif
121 #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
122 /* USB Standard Device Descriptor */
123 const __ALIGN_BEGIN uint8_t USBD_MSC_DeviceDesc[USB_SIZ_DEVICE_DESC] __ALIGN_END =
124  {
125  0x12, /*bLength */
126  USB_DEVICE_DESCRIPTOR_TYPE, /*bDescriptorType*/
127  0x00, /*bcdUSB */
128  0x02,
129  0x00, /*bDeviceClass*/
130  0x00, /*bDeviceSubClass*/
131  0x00, /*bDeviceProtocol*/
132  USB_OTG_MAX_EP0_SIZE, /*bMaxPacketSize*/
133  LOBYTE(USBD_VID), /*idVendor*/
134  HIBYTE(USBD_VID), /*idVendor*/
135  LOBYTE(USBD_PID), /*idVendor*/
136  HIBYTE(USBD_PID), /*idVendor*/
137  0x00, /*bcdDevice rel. 2.00*/
138  0x02,
139  USBD_IDX_MFC_STR, /*Index of manufacturer string*/
140  USBD_IDX_PRODUCT_STR, /*Index of product string*/
141  USBD_IDX_SERIAL_STR, /*Index of serial number string*/
142  USBD_CFG_MAX_NUM /*bNumConfigurations*/
143  } ; /* USB_DeviceDescriptor */
144 
145 #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
146  #if defined ( __ICCARM__ )
147  #pragma data_alignment=4
148  #endif
149 #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
150 /* USB Standard Device Descriptor */
151 __ALIGN_BEGIN uint8_t USBD_MSC_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] __ALIGN_END =
152 {
155  0x00,
156  0x02,
157  0x00,
158  0x00,
159  0x00,
160  0x40,
161  0x01,
162  0x00,
163 };
164 
165 #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
166  #if defined ( __ICCARM__ )
167  #pragma data_alignment=4
168  #endif
169 #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
170 /* USB Standard Device Descriptor */
171 const __ALIGN_BEGIN uint8_t USBD_MSC_LangIDDesc[USB_SIZ_STRING_LANGID] __ALIGN_END =
172 {
177 };
202 uint8_t * USBD_MSC_DeviceDescriptor( uint8_t speed , uint16_t *length)
203 {
204  *length = sizeof(USBD_MSC_DeviceDesc);
205  return (uint8_t *)USBD_MSC_DeviceDesc;
206 }
207 
215 uint8_t * USBD_MSC_LangIDStrDescriptor( uint8_t speed , uint16_t *length)
216 {
217  *length = sizeof(USBD_MSC_LangIDDesc);
218  return (uint8_t *)USBD_MSC_LangIDDesc;
219 }
220 
221 
229 uint8_t * USBD_MSC_ProductStrDescriptor( uint8_t speed , uint16_t *length)
230 {
231 
232 
233  if(speed == 0)
234  {
235  USBD_GetString ((uint8_t *)USBD_PRODUCT_HS_STRING, USBD_StrDesc, length);
236  }
237  else
238  {
239  USBD_GetString ((uint8_t *)USBD_PRODUCT_FS_STRING, USBD_StrDesc, length);
240  }
241  return USBD_StrDesc;
242 }
243 
251 uint8_t * USBD_MSC_ManufacturerStrDescriptor( uint8_t speed , uint16_t *length)
252 {
254  return USBD_StrDesc;
255 }
256 
264 uint8_t * USBD_MSC_SerialStrDescriptor( uint8_t speed , uint16_t *length)
265 {
266  if(speed == USB_OTG_SPEED_HIGH)
267  {
269  }
270  else
271  {
273  }
274  return USBD_StrDesc;
275 }
276 
284 uint8_t * USBD_MSC_ConfigStrDescriptor( uint8_t speed , uint16_t *length)
285 {
286  if(speed == USB_OTG_SPEED_HIGH)
287  {
289  }
290  else
291  {
293  }
294  return USBD_StrDesc;
295 }
296 
297 
305 uint8_t * USBD_MSC_InterfaceStrDescriptor( uint8_t speed , uint16_t *length)
306 {
307  if(speed == 0)
308  {
310  }
311  else
312  {
314  }
315  return USBD_StrDesc;
316 }
317 
332 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
333 
#define USBD_INTERFACE_HS_STRING
Definition: device_desc.c:73
const __ALIGN_BEGIN uint8_t USBD_MSC_DeviceDesc [USB_SIZ_DEVICE_DESC] __ALIGN_END
Definition: device_desc.c:123
const USBD_DEVICE USR_MSC_desc
Definition: device_desc.c:105
header file for the usbd_req.c file
#define USB_LEN_DEV_QUALIFIER_DESC
Definition: usbd_def.h:53
#define USBD_PID
Definition: device_desc.c:62
#define USB_DESC_TYPE_DEVICE_QUALIFIER
Definition: usbd_def.h:94
#define USBD_CONFIGURATION_HS_STRING
Definition: device_desc.c:72
uint8_t * USBD_MSC_ConfigStrDescriptor(uint8_t speed, uint16_t *length)
USBD_MSC_ConfigStrDescriptor return the configuration string descriptor.
Definition: device_desc.c:284
#define USBD_CFG_MAX_NUM
Definition: usbd_conf.h:38
#define USBD_IDX_PRODUCT_STR
Definition: usbd_def.h:62
uint8_t * USBD_MSC_ProductStrDescriptor(uint8_t speed, uint16_t *length)
USBD_MSC_ProductStrDescriptor return the product string descriptor.
Definition: device_desc.c:229
#define USBD_IDX_SERIAL_STR
Definition: usbd_def.h:63
#define USB_OTG_MAX_EP0_SIZE
Definition: usb_regs.h:71
uint8_t * USBD_MSC_DeviceDescriptor(uint8_t speed, uint16_t *length)
USBD_MSC_DeviceDescriptor return the device descriptor.
Definition: device_desc.c:202
#define USBD_PRODUCT_HS_STRING
Definition: device_desc.c:68
#define USB_OTG_SPEED_HIGH
Definition: usb_defines.h:61
hardware registers
uint8_t * USBD_MSC_InterfaceStrDescriptor(uint8_t speed, uint16_t *length)
USBD_MSC_InterfaceStrDescriptor return the interface string descriptor.
Definition: device_desc.c:305
#define USBD_INTERFACE_FS_STRING
Definition: device_desc.c:75
#define USBD_SERIALNUMBER_FS_STRING
Definition: device_desc.c:71
uint8_t USBD_StrDesc[USB_MAX_STR_DESC_SIZ]
Definition: usbd_req.c:101
#define __ALIGN_BEGIN
Definition: usb_conf.h:198
#define USB_SIZ_DEVICE_DESC
Definition: usbd_desc.h:53
uint8_t * USBD_MSC_SerialStrDescriptor(uint8_t speed, uint16_t *length)
USBD_MSC_SerialStrDescriptor return the serial number string descriptor.
Definition: device_desc.c:264
#define USBD_SERIALNUMBER_HS_STRING
Definition: device_desc.c:69
#define USBD_MANUFACTURER_STRING
Definition: device_desc.c:65
#define USB_DEVICE_DESCRIPTOR_TYPE
Definition: usbd_cdc_core.h:57
#define USBD_CONFIGURATION_FS_STRING
Definition: device_desc.c:74
#define HIBYTE(x)
Definition: usbd_def.h:126
#define LOBYTE(x)
Definition: usbd_def.h:125
#define USB_SIZ_STRING_LANGID
Definition: usbd_desc.h:54
void USBD_GetString(const uint8_t *desc, uint8_t *unicode, uint16_t *len)
USBD_GetString Convert Ascii string into unicode one.
Definition: usbd_req.c:819
USB Device configuration file.
#define USBD_VID
Definition: device_desc.c:61
#define USBD_IDX_MFC_STR
Definition: usbd_def.h:61
uint8_t * USBD_MSC_LangIDStrDescriptor(uint8_t speed, uint16_t *length)
USBD_MSC_LangIDStrDescriptor return the LangID string descriptor.
Definition: device_desc.c:215
uint8_t * USBD_MSC_ManufacturerStrDescriptor(uint8_t speed, uint16_t *length)
USBD_MSC_ManufacturerStrDescriptor return the manufacturer string descriptor.
Definition: device_desc.c:251
#define USB_DESC_TYPE_STRING
Definition: usbd_def.h:91
#define USBD_LANGID_STRING
Definition: device_desc.c:64
Header file for usbd_core.c.
#define USBD_PRODUCT_FS_STRING
Definition: device_desc.c:70
header file for the usbd_desc.c file