Skip to content

Commit b54b595

Browse files
[USB] Remove configuration and interface strings
These strings were defined and there was machinery to let the host request them, but they were not actually referenced in any descriptors. To clean up the code a bit, just remove the strings and the machinery. Specifying the callback functions as NULL signals to the USBD core that these strings are not available.
1 parent 0ff0a2a commit b54b595

File tree

2 files changed

+3
-45
lines changed

2 files changed

+3
-45
lines changed

cores/arduino/stm32/usb/usbd_desc.c

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,12 @@
4242
#define USBD_CLASS_PID 0x5711
4343
#define USBD_CLASS_PRODUCT_HS_STRING CONCATS(USB_PRODUCT, "HID in HS Mode")
4444
#define USBD_CLASS_PRODUCT_FS_STRING CONCATS(USB_PRODUCT, "HID in FS Mode")
45-
#define USBD_CLASS_CONFIGURATION_HS_STRING CONCATS(USB_PRODUCT, "HID Config")
46-
#define USBD_CLASS_INTERFACE_HS_STRING CONCATS(USB_PRODUCT, "HID Interface")
47-
#define USBD_CLASS_CONFIGURATION_FS_STRING CONCATS(USB_PRODUCT, "HID Config")
48-
#define USBD_CLASS_INTERFACE_FS_STRING CONCATS(USB_PRODUCT, "HID Interface")
4945
#endif /* USBD_USE_HID_COMPOSITE */
5046

5147
#ifdef USBD_USE_CDC
5248
#define USBD_CLASS_PID 0x5740
5349
#define USBD_CLASS_PRODUCT_HS_STRING CONCATS(USB_PRODUCT, "CDC in HS Mode")
5450
#define USBD_CLASS_PRODUCT_FS_STRING CONCATS(USB_PRODUCT, "CDC in FS Mode")
55-
#define USBD_CLASS_CONFIGURATION_HS_STRING CONCATS(USB_PRODUCT, "CDC Config")
56-
#define USBD_CLASS_INTERFACE_HS_STRING CONCATS(USB_PRODUCT, "CDC Interface")
57-
#define USBD_CLASS_CONFIGURATION_FS_STRING CONCATS(USB_PRODUCT, "CDC Config")
58-
#define USBD_CLASS_INTERFACE_FS_STRING CONCATS(USB_PRODUCT, "CDC Interface")
5951
#endif /* USBD_USE_CDC */
6052

6153
/* Private macro -------------------------------------------------------------*/
@@ -68,8 +60,6 @@ uint8_t *USBD_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
6860
/* Class specific */
6961
uint8_t *USBD_Class_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
7062
uint8_t *USBD_Class_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
71-
uint8_t *USBD_Class_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
72-
uint8_t *USBD_Class_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
7363

7464
#ifdef USB_SUPPORT_USER_STRING_DESC
7565
uint8_t *USBD_Class_USRStringDesc(USBD_SpeedTypeDef speed, uint8_t idx, uint16_t *length);
@@ -82,8 +72,8 @@ USBD_DescriptorsTypeDef USBD_Desc = {
8272
USBD_ManufacturerStrDescriptor,
8373
USBD_Class_ProductStrDescriptor,
8474
USBD_SerialStrDescriptor,
85-
USBD_Class_ConfigStrDescriptor,
86-
USBD_Class_InterfaceStrDescriptor,
75+
NULL,
76+
NULL,
8777
};
8878

8979
#ifdef USBD_USE_HID_COMPOSITE
@@ -225,38 +215,6 @@ uint8_t *USBD_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
225215
return (uint8_t *)USBD_StringSerial;
226216
}
227217

228-
/**
229-
* @brief Returns the configuration string descriptor.
230-
* @param speed: Current device speed
231-
* @param length: Pointer to data length variable
232-
* @retval Pointer to descriptor buffer
233-
*/
234-
uint8_t *USBD_Class_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
235-
{
236-
if (speed == USBD_SPEED_HIGH) {
237-
USBD_GetString((uint8_t *)USBD_CLASS_CONFIGURATION_HS_STRING, USBD_StrDesc, length);
238-
} else {
239-
USBD_GetString((uint8_t *)USBD_CLASS_CONFIGURATION_FS_STRING, USBD_StrDesc, length);
240-
}
241-
return USBD_StrDesc;
242-
}
243-
244-
/**
245-
* @brief Returns the interface string descriptor.
246-
* @param speed: Current device speed
247-
* @param length: Pointer to data length variable
248-
* @retval Pointer to descriptor buffer
249-
*/
250-
uint8_t *USBD_Class_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
251-
{
252-
if (speed == USBD_SPEED_HIGH) {
253-
USBD_GetString((uint8_t *)USBD_CLASS_INTERFACE_HS_STRING, USBD_StrDesc, length);
254-
} else {
255-
USBD_GetString((uint8_t *)USBD_CLASS_INTERFACE_FS_STRING, USBD_StrDesc, length);
256-
}
257-
return USBD_StrDesc;
258-
}
259-
260218
/**
261219
* @brief Create the serial number string descriptor
262220
* @param None

platform.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.5.1.path}/CMSIS/DSP/Lib/GCC
6969

7070
# USB Flags
7171
# ---------
72-
build.usb_flags=-DUSBCON {build.usb_speed} -DUSBD_VID={build.vid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT="{build.board}"' -DHAL_PCD_MODULE_ENABLED
72+
build.usb_flags=-DUSBCON {build.usb_speed} -DUSBD_VID={build.vid} -DUSBD_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT="{build.board}"' -DHAL_PCD_MODULE_ENABLED
7373

7474
# Default usb manufacturer will be replaced at compile time using
7575
# numeric vendor ID if available or by board's specific value.

0 commit comments

Comments
 (0)