Files: usbd_midi_desc.c Directory: DAD_FORGE/Drivers/_MIDI Description: USB descriptor management for Full Speed MIDI device
š Class Description
USB MIDI descriptors implementation module (USB MIDI Device Class). This module provides all necessary functions to generate and return USB descriptors required by the USB Host Controller system, including device descriptor, string descriptors (manufacturer, product, serial, configuration, interface), and language ID. It is specifically designed for Full Speed (FS) operation with a MIDI device named āOSCAR MIDIā.
šÆ Enumerations and Associated Structures
The class uses the external USBD_DescriptorsTypeDef structure defined in the standard USB framework.
Returns the string descriptor containing a unique serial number generated from the microcontrollerās hardware identifiers (DEVICE_ID1, DEVICE_ID2, DEVICE_ID3).
Parameter(s)
Ā
speed
USB speed type. Parameter ignored for this Full Speed device.
length
Pointer to a variable that will receive the length of the returned descriptor in bytes.
Return
Pointer to the buffer containing the serial number (USBD_Midi_StringSerial).
Returns the string descriptor containing the interface description (āMIDI Interfaceā). The string is converted to USB Unicode format.
Parameter(s)
Ā
speed
USB speed type. Parameter ignored for this Full Speed device.
length
Pointer to a variable that will receive the length of the returned descriptor in bytes.
Return
Pointer to the buffer containing the interface string descriptor (USBD_Midi_StrDesc).
š Utility Functions
Get_SerialNum
Element
Details
Method
static void Get_SerialNum(void)
Description
Generates a unique serial number by combining the microcontrollerās hardware identifiers (DEVICE_ID1, DEVICE_ID2, DEVICE_ID3) and converts the result to Unicode format for storage in the serial string buffer.
Parameter(s)
No parameters. Static method with no arguments.
Return
No return value (void). Directly modifies the USBD_Midi_StringSerial buffer.
Converts a 32-bit integer value to a hexadecimal Unicode character string (high-speed USB ASCII format). Each nibble is converted to a ā0ā-ā9ā or āAā-āFā character.
Parameter(s)
Ā
value
32-bit integer value to convert.
pbuf
Pointer to the destination buffer for the Unicode string (must be aligned).
len
Maximum conversion length in bytes (number of nibbles Ć 2).
Return
No return value (void).
š¦ Data
Member
Type
Description
USBD_Midi_FS_DeviceDesc
uint8_t[USB_LEN_DEV_DESC]
Buffer containing the USB device descriptor (type, version, vendor/product ID, maximum packet size, etc.). Memory aligned.
USBD_Midi_LangIDDesc
uint8_t[USB_LEN_LANGID_STR_DESC]
Buffer containing the Language ID descriptor (code 1036 = French). Memory aligned.
USBD_Midi_StrDesc
uint8_t[USBD_MAX_STR_DESC_SIZ]
Generic buffer for Unicode string descriptors (manufacturer, product, configuration, interface). Reused by multiple functions.
USBD_Midi_StringSerial
uint8_t[USB_SIZ_STRING_SERIAL]
Buffer containing the deviceās unique serial number, generated from hardware identifiers. Memory aligned.
FS_Midi_Desc
USBD_DescriptorsTypeDef
Structure aggregating callbacks for all USB MIDI descriptors (pointer to each descriptor function).
DAD_FORGE/DSP - Dad Design DSP Library Copyright (c) 2024-2026 Dad Design.