48
48
#define USBD_HID_INTERFACE_FS_STRING CONCATS(USB_PRODUCT, "HID Interface")
49
49
#endif /* USBD_USE_HID_COMPOSITE */
50
50
51
+ #ifdef USBD_USE_CDC
52
+ #define USBD_CDC_PID 0x5740
53
+ #define USBD_CDC_PRODUCT_HS_STRING CONCATS(USB_PRODUCT, "CDC in HS Mode")
54
+ #define USBD_CDC_PRODUCT_FS_STRING CONCATS(USB_PRODUCT, "CDC in FS Mode")
55
+ #define USBD_CDC_CONFIGURATION_HS_STRING CONCATS(USB_PRODUCT, "CDC Config")
56
+ #define USBD_CDC_INTERFACE_HS_STRING CONCATS(USB_PRODUCT, "CDC Interface")
57
+ #define USBD_CDC_CONFIGURATION_FS_STRING CONCATS(USB_PRODUCT, "CDC Config")
58
+ #define USBD_CDC_INTERFACE_FS_STRING CONCATS(USB_PRODUCT, "CDC Interface")
59
+ #endif /* USBD_USE_CDC */
60
+
51
61
/* Private macro -------------------------------------------------------------*/
52
62
/* Private function prototypes -----------------------------------------------*/
53
63
/* Common function */
@@ -62,6 +72,13 @@ uint8_t *USBD_HID_ProductStrDescriptor (USBD_SpeedTypeDef speed, uint16_t *lengt
62
72
uint8_t * USBD_HID_ConfigStrDescriptor (USBD_SpeedTypeDef speed , uint16_t * length );
63
73
uint8_t * USBD_HID_InterfaceStrDescriptor (USBD_SpeedTypeDef speed , uint16_t * length );
64
74
#endif /* USBD_USE_HID_COMPOSITE */
75
+ #ifdef USBD_USE_CDC
76
+ uint8_t * USBD_CDC_DeviceDescriptor (USBD_SpeedTypeDef speed , uint16_t * length );
77
+ uint8_t * USBD_CDC_ProductStrDescriptor (USBD_SpeedTypeDef speed , uint16_t * length );
78
+ uint8_t * USBD_CDC_ConfigStrDescriptor (USBD_SpeedTypeDef speed , uint16_t * length );
79
+ uint8_t * USBD_CDC_InterfaceStrDescriptor (USBD_SpeedTypeDef speed , uint16_t * length );
80
+ #endif /* USBD_USE_CDC */
81
+
65
82
#ifdef USB_SUPPORT_USER_STRING_DESC
66
83
uint8_t * USBD_Class_USRStringDesc (USBD_SpeedTypeDef speed , uint8_t idx , uint16_t * length );
67
84
#endif /* USB_SUPPORT_USER_STRING_DESC */
@@ -79,7 +96,7 @@ USBD_DescriptorsTypeDef HID_Desc = {
79
96
};
80
97
81
98
/* USB Standard Device Descriptor */
82
- __ALIGN_BEGIN uint8_t USBD_HID_DeviceDesc [USB_LEN_DEV_DESC ] __ALIGN_END = {
99
+ __ALIGN_BEGIN uint8_t USBD_HID_DeviceDesc [USB_LEN_DEV_DESC ] __ALIGN_END = {
83
100
0x12 , /* bLength */
84
101
USB_DESC_TYPE_DEVICE , /* bDescriptorType */
85
102
0x00 , /* bcdUSB */
@@ -101,6 +118,41 @@ __ALIGN_BEGIN uint8_t USBD_HID_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = {
101
118
}; /* USB_DeviceDescriptor */
102
119
#endif /* USBD_USE_HID_COMPOSITE */
103
120
121
+ #ifdef USBD_USE_CDC
122
+ USBD_DescriptorsTypeDef CDC_Desc =
123
+ {
124
+ USBD_CDC_DeviceDescriptor ,
125
+ USBD_LangIDStrDescriptor ,
126
+ USBD_ManufacturerStrDescriptor ,
127
+ USBD_CDC_ProductStrDescriptor ,
128
+ USBD_SerialStrDescriptor ,
129
+ USBD_CDC_ConfigStrDescriptor ,
130
+ USBD_CDC_InterfaceStrDescriptor ,
131
+ };
132
+
133
+ /* USB Standard Device Descriptor */
134
+ __ALIGN_BEGIN uint8_t USBD_CDC_DeviceDesc [USB_LEN_DEV_DESC ] __ALIGN_END = {
135
+ 0x12 , /* bLength */
136
+ USB_DESC_TYPE_DEVICE , /* bDescriptorType */
137
+ 0x00 , /* bcdUSB */
138
+ 0x02 ,
139
+ 0x00 , /* bDeviceClass */
140
+ 0x00 , /* bDeviceSubClass */
141
+ 0x00 , /* bDeviceProtocol */
142
+ USB_MAX_EP0_SIZE , /* bMaxPacketSize */
143
+ LOBYTE (USBD_VID ), /* idVendor */
144
+ HIBYTE (USBD_VID ), /* idVendor */
145
+ LOBYTE (USBD_CDC_PID ), /* idVendor */
146
+ HIBYTE (USBD_CDC_PID ), /* idVendor */
147
+ 0x00 , /* bcdDevice rel. 2.00 */
148
+ 0x02 ,
149
+ USBD_IDX_MFC_STR , /* Index of manufacturer string */
150
+ USBD_IDX_PRODUCT_STR , /* Index of product string */
151
+ USBD_IDX_SERIAL_STR , /* Index of serial number string */
152
+ USBD_MAX_NUM_CONFIGURATION /* bNumConfigurations */
153
+ }; /* USB_DeviceDescriptor */
154
+ #endif /* USBD_USE_CDC */
155
+
104
156
/* USB Standard Device Descriptor */
105
157
__ALIGN_BEGIN uint8_t USBD_LangIDDesc [USB_LEN_LANGID_STR_DESC ] __ALIGN_END = {
106
158
USB_LEN_LANGID_STR_DESC ,
@@ -135,7 +187,14 @@ uint8_t *USBD_HID_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
135
187
return (uint8_t * )USBD_HID_DeviceDesc ;
136
188
}
137
189
#endif
138
-
190
+ #ifdef USBD_USE_CDC
191
+ uint8_t * USBD_CDC_DeviceDescriptor (USBD_SpeedTypeDef speed , uint16_t * length )
192
+ {
193
+ UNUSED (speed );
194
+ * length = sizeof (USBD_CDC_DeviceDesc );
195
+ return (uint8_t * )USBD_CDC_DeviceDesc ;
196
+ }
197
+ #endif
139
198
/**
140
199
* @brief Returns the LangID string descriptor.
141
200
* @param speed: Current device speed
@@ -169,6 +228,20 @@ uint8_t *USBD_HID_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length
169
228
return USBD_StrDesc ;
170
229
}
171
230
#endif /* USBD_USE_HID_COMPOSITE */
231
+ #ifdef USBD_USE_CDC
232
+ uint8_t * USBD_CDC_ProductStrDescriptor (USBD_SpeedTypeDef speed , uint16_t * length )
233
+ {
234
+ if (speed == USBD_SPEED_HIGH )
235
+ {
236
+ USBD_GetString ((uint8_t * )USBD_CDC_PRODUCT_HS_STRING , USBD_StrDesc , length );
237
+ }
238
+ else
239
+ {
240
+ USBD_GetString ((uint8_t * )USBD_CDC_PRODUCT_FS_STRING , USBD_StrDesc , length );
241
+ }
242
+ return USBD_StrDesc ;
243
+ }
244
+ #endif /* USBD_USE_CDC */
172
245
173
246
/**
174
247
* @brief Returns the manufacturer string descriptor.
@@ -220,6 +293,20 @@ uint8_t *USBD_HID_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
220
293
return USBD_StrDesc ;
221
294
}
222
295
#endif /* USBD_USE_HID_COMPOSITE */
296
+ #ifdef USBD_USE_CDC
297
+ uint8_t * USBD_CDC_ConfigStrDescriptor (USBD_SpeedTypeDef speed , uint16_t * length )
298
+ {
299
+ if (speed == USBD_SPEED_HIGH )
300
+ {
301
+ USBD_GetString ((uint8_t * )USBD_CDC_CONFIGURATION_HS_STRING , USBD_StrDesc , length );
302
+ }
303
+ else
304
+ {
305
+ USBD_GetString ((uint8_t * )USBD_CDC_CONFIGURATION_FS_STRING , USBD_StrDesc , length );
306
+ }
307
+ return USBD_StrDesc ;
308
+ }
309
+ #endif /* USBD_USE_CDC */
223
310
224
311
/**
225
312
* @brief Returns the interface string descriptor.
@@ -241,6 +328,20 @@ uint8_t *USBD_HID_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *leng
241
328
return USBD_StrDesc ;
242
329
}
243
330
#endif /* USBD_USE_HID_COMPOSITE */
331
+ #ifdef USBD_USE_CDC
332
+ uint8_t * USBD_CDC_InterfaceStrDescriptor (USBD_SpeedTypeDef speed , uint16_t * length )
333
+ {
334
+ if (speed == USBD_SPEED_HIGH )
335
+ {
336
+ USBD_GetString ((uint8_t * )USBD_CDC_INTERFACE_HS_STRING , USBD_StrDesc , length );
337
+ }
338
+ else
339
+ {
340
+ USBD_GetString ((uint8_t * )USBD_CDC_INTERFACE_FS_STRING , USBD_StrDesc , length );
341
+ }
342
+ return USBD_StrDesc ;
343
+ }
344
+ #endif /* USBD_USE_CDC */
244
345
245
346
/**
246
347
* @brief Create the serial number string descriptor
0 commit comments