1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
100
101
102
103
104
105
106
107
108
114
119
120
126
127
132
133
139
140
154
155
161
162
168
169
175
176
190
191
197
198
212
213
219
220
/* ... */
#include "usbd_core.h"
#include "usbd_desc.h"
#include "usbd_conf.h"
Includes
#define USBD_VCP_VID 0x0483
#define USBD_VCP_PID 0x5740
#define USBD_VCP_LANGID_STRING 0x409
#define USBD_VCP_MANUFACTURER_STRING "STMicroelectronics"
#define USBD_VCP_PRODUCT_HS_STRING "STM32 Virtual ComPort in HS Mode"
#define USBD_VCP_SERIALNUMBER_HS_STRING "00000000001A"
#define USBD_VCP_PRODUCT_FS_STRING "STM32 Virtual ComPort in FS Mode"
#define USBD_VCP_SERIALNUMBER_FS_STRING "00000000001B"
#define USBD_VCP_CONFIGURATION_HS_STRING "VCP Config"
#define USBD_VCP_INTERFACE_HS_STRING "VCP Interface"
#define USBD_VCP_CONFIGURATION_FS_STRING "VCP Config"
#define USBD_VCP_INTERFACE_FS_STRING "VCP Interface"
12 defines
Private define
uint8_t *USBD_VCP_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t * length);
uint8_t *USBD_VCP_LangIDStrDescriptor(USBD_SpeedTypeDef speed,
uint16_t * length);
uint8_t *USBD_VCP_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed,
uint16_t * length);
uint8_t *USBD_VCP_ProductStrDescriptor(USBD_SpeedTypeDef speed,
uint16_t * length);
uint8_t *USBD_VCP_SerialStrDescriptor(USBD_SpeedTypeDef speed,
uint16_t * length);
uint8_t *USBD_VCP_ConfigStrDescriptor(USBD_SpeedTypeDef speed,
uint16_t * length);
uint8_t *USBD_VCP_InterfaceStrDescriptor(USBD_SpeedTypeDef speed,
uint16_t * length);
Private function prototypes
USBD_DescriptorsTypeDef VCP_Desc = {
USBD_VCP_DeviceDescriptor,
USBD_VCP_LangIDStrDescriptor,
USBD_VCP_ManufacturerStrDescriptor,
USBD_VCP_ProductStrDescriptor,
USBD_VCP_SerialStrDescriptor,
USBD_VCP_ConfigStrDescriptor,
USBD_VCP_InterfaceStrDescriptor,
...};
#if defined ( __ICCARM__ )
#pragma data_alignment=4
#endif
__ALIGN_BEGIN uint8_t USBD_VCP_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = {
0x12,
USB_DESC_TYPE_DEVICE,
0x00,
0x02,
0x02,
0x02,
0x00,
USB_MAX_EP0_SIZE,
LOBYTE(USBD_VCP_VID),
HIBYTE(USBD_VCP_VID),
LOBYTE(USBD_VCP_PID),
HIBYTE(USBD_VCP_PID),
0x00,
0x02,
USBD_IDX_MFC_STR,
USBD_IDX_PRODUCT_STR,
USBD_IDX_SERIAL_STR,
USBD_MAX_NUM_CONFIGURATION
...};
#if defined ( __ICCARM__ )
#pragma data_alignment=4
#endif
__ALIGN_BEGIN uint8_t USBD_VCP_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = {
USB_LEN_LANGID_STR_DESC,
USB_DESC_TYPE_STRING,
LOBYTE(USBD_VCP_LANGID_STRING),
HIBYTE(USBD_VCP_LANGID_STRING),
...};
#if defined ( __ICCARM__ )
#pragma data_alignment=4
#endif
__ALIGN_BEGIN uint8_t USBD_VCP_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END;
Private variables
/* ... */
uint8_t *USBD_VCP_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t * length)
{
*length = sizeof(USBD_VCP_DeviceDesc);
return USBD_VCP_DeviceDesc;
}{ ... }
/* ... */
uint8_t *USBD_VCP_LangIDStrDescriptor(USBD_SpeedTypeDef speed,
uint16_t * length)
{
*length = sizeof(USBD_VCP_LangIDDesc);
return USBD_VCP_LangIDDesc;
}{ ... }
/* ... */
uint8_t *USBD_VCP_ProductStrDescriptor(USBD_SpeedTypeDef speed,
uint16_t * length)
{
if (speed == 0)
{
USBD_GetString((uint8_t *) USBD_VCP_PRODUCT_HS_STRING, USBD_VCP_StrDesc,
length);
}if (speed == 0) { ... }
else
{
USBD_GetString((uint8_t *) USBD_VCP_PRODUCT_FS_STRING, USBD_VCP_StrDesc,
length);
}else { ... }
return USBD_VCP_StrDesc;
}{ ... }
/* ... */
uint8_t *USBD_VCP_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed,
uint16_t * length)
{
USBD_GetString((uint8_t *) USBD_VCP_MANUFACTURER_STRING, USBD_VCP_StrDesc,
length);
return USBD_VCP_StrDesc;
}{ ... }
/* ... */
uint8_t *USBD_VCP_SerialStrDescriptor(USBD_SpeedTypeDef speed,
uint16_t * length)
{
if (speed == USBD_SPEED_HIGH)
{
USBD_GetString((uint8_t *) USBD_VCP_SERIALNUMBER_HS_STRING,
USBD_VCP_StrDesc, length);
}if (speed == USBD_SPEED_HIGH) { ... }
else
{
USBD_GetString((uint8_t *) USBD_VCP_SERIALNUMBER_FS_STRING,
USBD_VCP_StrDesc, length);
}else { ... }
return USBD_VCP_StrDesc;
}{ ... }
/* ... */
uint8_t *USBD_VCP_ConfigStrDescriptor(USBD_SpeedTypeDef speed,
uint16_t * length)
{
if (speed == USBD_SPEED_HIGH)
{
USBD_GetString((uint8_t *) USBD_VCP_CONFIGURATION_HS_STRING,
USBD_VCP_StrDesc, length);
}if (speed == USBD_SPEED_HIGH) { ... }
else
{
USBD_GetString((uint8_t *) USBD_VCP_CONFIGURATION_FS_STRING,
USBD_VCP_StrDesc, length);
}else { ... }
return USBD_VCP_StrDesc;
}{ ... }
/* ... */
uint8_t *USBD_VCP_InterfaceStrDescriptor(USBD_SpeedTypeDef speed,
uint16_t * length)
{
if (speed == 0)
{
USBD_GetString((uint8_t *) USBD_VCP_INTERFACE_HS_STRING, USBD_VCP_StrDesc,
length);
}if (speed == 0) { ... }
else
{
USBD_GetString((uint8_t *) USBD_VCP_INTERFACE_FS_STRING, USBD_VCP_StrDesc,
length);
}else { ... }
return USBD_VCP_StrDesc;
}{ ... }