Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3af2d2a

Browse files
author
fpr
committed
Update USB descriptor to allow to use USBMicrophone library
Signed-off-by: fpr <fabien.perroquin@wi6labs.com>
1 parent635b829 commit3af2d2a

File tree

2 files changed

+43
-58
lines changed

2 files changed

+43
-58
lines changed

‎variants/DISCO_L475VG_IOT/usb/usbd_desc.c‎

Lines changed: 35 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,15 @@
6464
#elif !defined(USB_MANUFACTURER)
6565
// Fall through to unknown if no manufacturer name was provided in a macro
6666
#defineUSBD_MANUFACTURER_STRING "Unknown"
67-
#endif
67+
#endif/* USBD_VID */
6868
#ifdefUSBD_USE_HID_COMPOSITE
69-
#defineUSBD_HID_PRODUCT_HS_STRING "HID in HS Mode"
7069
#defineUSBD_HID_PRODUCT_FS_STRING "HID in FS Mode"
71-
#defineUSBD_HID_CONFIGURATION_HS_STRING "HID Config"
72-
#defineUSBD_HID_INTERFACE_HS_STRING "HID Interface"
7370
#defineUSBD_HID_CONFIGURATION_FS_STRING "HID Config"
7471
#defineUSBD_HID_INTERFACE_FS_STRING "HID Interface"
7572

7673
/* Private macro -------------------------------------------------------------*/
77-
/* Private function prototypes -----------------------------------------------*/
78-
staticuint8_t*USBD_HID_DeviceDescriptor(USBD_SpeedTypeDefspeed,uint16_t*length);
79-
staticuint8_t*USBD_HID_LangIDStrDescriptor(USBD_SpeedTypeDefspeed,uint16_t*length);
80-
staticuint8_t*USBD_HID_ManufacturerStrDescriptor (USBD_SpeedTypeDefspeed,uint16_t*length);
74+
/* Private function prototypes -----------------------------------------------*/;
8175
staticuint8_t*USBD_HID_ProductStrDescriptor (USBD_SpeedTypeDefspeed,uint16_t*length);
82-
staticuint8_t*USBD_HID_SerialStrDescriptor(USBD_SpeedTypeDefspeed,uint16_t*length);
8376
staticuint8_t*USBD_HID_ConfigStrDescriptor(USBD_SpeedTypeDefspeed,uint16_t*length);
8477
staticuint8_t*USBD_HID_InterfaceStrDescriptor(USBD_SpeedTypeDefspeed,uint16_t*length);
8578
#ifdefUSB_SUPPORT_USER_STRING_DESC
@@ -88,15 +81,15 @@ static uint8_t *USBD_HID_USRStringDesc (USBD_SpeedTypeDef speed, uint8_t idx, ui
8881

8982
/* Private variables ---------------------------------------------------------*/
9083
USBD_DescriptorsTypeDefHID_Desc= {
91-
USBD_HID_DeviceDescriptor,
92-
USBD_HID_LangIDStrDescriptor,
93-
USBD_HID_ManufacturerStrDescriptor,
84+
USBD_DeviceDescriptor,
85+
USBD_LangIDStrDescriptor,
86+
USBD_ManufacturerStrDescriptor,
9487
USBD_HID_ProductStrDescriptor,
95-
USBD_HID_SerialStrDescriptor,
88+
USBD_SerialStrDescriptor,
9689
USBD_HID_ConfigStrDescriptor,
9790
USBD_HID_InterfaceStrDescriptor,
9891
};
99-
#endif//USBD_USE_HID_COMPOSITE
92+
#endif/*USBD_USE_HID_COMPOSITE */
10093

10194
/* USB Standard Device Descriptor */
10295
#if defined (__ICCARM__ )/*!< IAR Compiler */
@@ -105,8 +98,8 @@ USBD_DescriptorsTypeDef HID_Desc = {
10598
__ALIGN_BEGINstaticuint8_tUSBD_DeviceDesc[USB_LEN_DEV_DESC]__ALIGN_END= {
10699
0x12,/* bLength */
107100
USB_DESC_TYPE_DEVICE,/* bDescriptorType */
108-
0x00,/* bcdUSB */
109-
0x02,
101+
0x01,/* bcdUSB */
102+
0x01,
110103
0x00,/* bDeviceClass */
111104
0x00,/* bDeviceSubClass */
112105
0x00,/* bDeviceProtocol */
@@ -115,8 +108,8 @@ __ALIGN_BEGIN static uint8_t USBD_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = {
115108
HIBYTE(USBD_VID),/* idVendor */
116109
LOBYTE(USBD_PID),/* idVendor */
117110
HIBYTE(USBD_PID),/* idVendor */
118-
0x00,/* bcdDevice rel.2.00 */
119-
0x02,
111+
0x01,/* bcdDevice rel.1.1 */
112+
0x01,
120113
USBD_IDX_MFC_STR,/* Index of manufacturer string */
121114
USBD_IDX_PRODUCT_STR,/* Index of product string */
122115
USBD_IDX_SERIAL_STR,/* Index of serial number string */
@@ -149,14 +142,13 @@ __ALIGN_BEGIN static uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END;
149142
staticvoidIntToUnicode (uint32_tvalue ,uint8_t*pbuf ,uint8_tlen);
150143
staticvoidGet_SerialNum(void);
151144

152-
#ifdefUSBD_USE_HID_COMPOSITE
153145
/**
154146
* @brief Returns the device descriptor.
155147
* @param speed: Current device speed
156148
* @param length: Pointer to data length variable
157149
* @retval Pointer to descriptor buffer
158150
*/
159-
uint8_t*USBD_HID_DeviceDescriptor(USBD_SpeedTypeDefspeed,uint16_t*length)
151+
uint8_t*USBD_DeviceDescriptor(USBD_SpeedTypeDefspeed,uint16_t*length)
160152
{
161153
UNUSED(speed);
162154
*length=sizeof(USBD_DeviceDesc);
@@ -169,39 +161,20 @@ uint8_t *USBD_HID_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
169161
* @param length: Pointer to data length variable
170162
* @retval Pointer to descriptor buffer
171163
*/
172-
uint8_t*USBD_HID_LangIDStrDescriptor(USBD_SpeedTypeDefspeed,uint16_t*length)
164+
uint8_t*USBD_LangIDStrDescriptor(USBD_SpeedTypeDefspeed,uint16_t*length)
173165
{
174166
UNUSED(speed);
175167
*length=sizeof(USBD_LangIDDesc);
176168
return (uint8_t*)USBD_LangIDDesc;
177169
}
178170

179-
/**
180-
* @brief Returns the product string descriptor.
181-
* @param speed: Current device speed
182-
* @param length: Pointer to data length variable
183-
* @retval Pointer to descriptor buffer
184-
*/
185-
uint8_t*USBD_HID_ProductStrDescriptor(USBD_SpeedTypeDefspeed,uint16_t*length)
186-
{
187-
if(speed==USBD_SPEED_HIGH)
188-
{
189-
USBD_GetString((uint8_t*)USBD_HID_PRODUCT_HS_STRING,USBD_StrDesc,length);
190-
}
191-
else
192-
{
193-
USBD_GetString((uint8_t*)USBD_HID_PRODUCT_FS_STRING,USBD_StrDesc,length);
194-
}
195-
returnUSBD_StrDesc;
196-
}
197-
198171
/**
199172
* @brief Returns the manufacturer string descriptor.
200173
* @param speed: Current device speed
201174
* @param length: Pointer to data length variable
202175
* @retval Pointer to descriptor buffer
203176
*/
204-
uint8_t*USBD_HID_ManufacturerStrDescriptor(USBD_SpeedTypeDefspeed,uint16_t*length)
177+
uint8_t*USBD_ManufacturerStrDescriptor(USBD_SpeedTypeDefspeed,uint16_t*length)
205178
{
206179
UNUSED(speed);
207180
USBD_GetString((uint8_t*)USBD_MANUFACTURER_STRING,USBD_StrDesc,length);
@@ -214,7 +187,7 @@ uint8_t *USBD_HID_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *l
214187
* @param length: Pointer to data length variable
215188
* @retval Pointer to descriptor buffer
216189
*/
217-
uint8_t*USBD_HID_SerialStrDescriptor(USBD_SpeedTypeDefspeed,uint16_t*length)
190+
uint8_t*USBD_SerialStrDescriptor(USBD_SpeedTypeDefspeed,uint16_t*length)
218191
{
219192
UNUSED(speed);
220193
*length=USB_SIZ_STRING_SERIAL;
@@ -225,6 +198,21 @@ uint8_t *USBD_HID_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
225198
return (uint8_t*)USBD_StringSerial;
226199
}
227200

201+
#ifdefUSBD_USE_HID_COMPOSITE
202+
203+
/**
204+
* @brief Returns the product string descriptor.
205+
* @param speed: Current device speed
206+
* @param length: Pointer to data length variable
207+
* @retval Pointer to descriptor buffer
208+
*/
209+
uint8_t*USBD_HID_ProductStrDescriptor(USBD_SpeedTypeDefspeed,uint16_t*length)
210+
{
211+
UNUSED(speed);
212+
USBD_GetString((uint8_t*)USBD_HID_PRODUCT_FS_STRING,USBD_StrDesc,length);
213+
returnUSBD_StrDesc;
214+
}
215+
228216
/**
229217
* @brief Returns the configuration string descriptor.
230218
* @param speed: Current device speed
@@ -233,14 +221,8 @@ uint8_t *USBD_HID_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
233221
*/
234222
uint8_t*USBD_HID_ConfigStrDescriptor(USBD_SpeedTypeDefspeed,uint16_t*length)
235223
{
236-
if(speed==USBD_SPEED_HIGH)
237-
{
238-
USBD_GetString((uint8_t*)USBD_HID_CONFIGURATION_HS_STRING,USBD_StrDesc,length);
239-
}
240-
else
241-
{
242-
USBD_GetString((uint8_t*)USBD_HID_CONFIGURATION_FS_STRING,USBD_StrDesc,length);
243-
}
224+
UNUSED(speed);
225+
USBD_GetString((uint8_t*)USBD_HID_CONFIGURATION_FS_STRING,USBD_StrDesc,length);
244226
returnUSBD_StrDesc;
245227
}
246228

@@ -252,17 +234,12 @@ uint8_t *USBD_HID_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
252234
*/
253235
uint8_t*USBD_HID_InterfaceStrDescriptor(USBD_SpeedTypeDefspeed,uint16_t*length)
254236
{
255-
if(speed==USBD_SPEED_HIGH)
256-
{
257-
USBD_GetString((uint8_t*)USBD_HID_INTERFACE_HS_STRING,USBD_StrDesc,length);
258-
}
259-
else
260-
{
261-
USBD_GetString((uint8_t*)USBD_HID_INTERFACE_FS_STRING,USBD_StrDesc,length);
262-
}
237+
UNUSED(speed);
238+
USBD_GetString((uint8_t*)USBD_HID_INTERFACE_FS_STRING,USBD_StrDesc,length);
263239
returnUSBD_StrDesc;
264240
}
265241
#endif//USBD_USE_HID_COMPOSITE
242+
266243
/**
267244
* @brief Create the serial number string descriptor
268245
* @param None

‎variants/DISCO_L475VG_IOT/usb/usbd_desc.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,15 @@
6161
#defineUSB_SIZ_STRING_SERIAL 0x1A
6262
/* Exported macro ------------------------------------------------------------*/
6363
/* Exported functions ------------------------------------------------------- */
64+
#ifdefUSBD_USE_HID_COMPOSITE
6465
externUSBD_DescriptorsTypeDefHID_Desc;
66+
#endif
67+
68+
uint8_t*USBD_DeviceDescriptor(USBD_SpeedTypeDefspeed,uint16_t*length);
69+
uint8_t*USBD_LangIDStrDescriptor(USBD_SpeedTypeDefspeed,uint16_t*length);
70+
uint8_t*USBD_ManufacturerStrDescriptor(USBD_SpeedTypeDefspeed,uint16_t*length);
71+
uint8_t*USBD_SerialStrDescriptor(USBD_SpeedTypeDefspeed,uint16_t*length);
72+
6573
#endif// USBCON
6674
#endif/* __USBD_DESC_H */
6775

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp