📄 audio-speaker.dir
字号:
|1|bDescriptorType|1|0x24|CS_INTERFACE descriptor\
(AUDGenericDescriptor_INTERFACE).
|2|bDescriptorSubType|1|0x02|FORMAT_TYPE subtype\n
(AUDStreamingInterfaceDescriptor_FORMATTYPE).
|3|bFormatType|1|0x01|FORMAT_TYPE_I (AUDFormatTypeOneDescriptor_FORMATTYPEONE).
|4|bNrChannels|1|0x02|2 channels (AUDDSpeakerDriver_NUMCHANNELS).
|5|bSubFrameSize|1|0x02|Two bytes per audio subframe\n
(AUDDSpeakerDriver_BYTESPERSAMPLE).
|6|bBitResolution|1|0x10|16 bits per sample\n
(AUDDSpeakerDriver_BYTESPERSAMPLE * 2).
|7|bSamFreqType|1|0x01|One frequency supported.
|8|tSamFreq|3|4800|4800Hz (AUDDSpeakerDriver_SAMPLERATE).
Standard %Endpoint Descriptor (AUDEndpointDescriptor)
||Offset||Field||Size||Value||Description
|0|bLength|1|0x09|Size of AUDFormatTypeOneDescriptor1 in bytes.
|1|bDescriptorType|1|0x24|ENDPOINT descriptor (USBGenericDescriptor_ENDPOINT).
|2|bEndpointAddress|1|0x04\nTest|OUT endpoint 4\n
See USBEndpointDescriptor_ADDRESS\n
See AUDDSpeakerDriverDescriptors_DATAOUT.
|3|bmAttributes|1|0x01|Isochronous, not shared\n
(USBEndpointDescriptor_ISOCHRONOUS).
|4|wMaxPacketSize|2|0x????|BOARD_USB_ENDPOINTS_MAXPACKETSIZE().
|6|bInterval|1|0x01|One packet per frame.
|7|bRefresh|1|0x00|Unused.
|8|bSynchAddress|1|0x00|Unused.
Class-specific Isochronous Audio Data Endpoint Descriptor
(AUDDataEndpointDescriptor)
||Offset||Field||Size||Value||Description
|0|bLength|1|0x07|Size of AUDDataEndpointDescriptor in bytes.
|1|bDescriptorType|1|0x25|CS_ENDPOINT descriptor\n
(AUDGenericDescriptor_ENDPOINT).
|2|bDescriptorSubType|1|0x01|GENERAL subtype\n
(AUDDataEndpointDescriptor_SUBTYPE).
|3|bmAttributes|1|0x00|No sampling frequency control\n
no pitch control\n
no packet padding.
|4|bLockDelayUnits|1|0x00|Unused.
|5|wLockDelay|2|0x0000|Unused.
!!String Descriptors
There are three string descriptors available. The Manufacturer, Product and
Serial Number descriptor.
See manufacturerDescriptor, productDescriptor, serialNumberDescriptor.
!!!Requests
The Audio Speaker Driver supports all necessary standard requests, and some
class-specific requests.
USBDCallbacks_RequestReceived is used to filter all requests,
AUDDSpeakerDriver_RequestHandler is invoked to handle Audio Class requests
and forward standard request to AUDDSpeakerDriver_RequestHandler.
!!Standard requests
Set Interface request should be processed to control bandwidth allocation.
!Set Interface
USBDDriverCallbacks_InterfaceSettingChanged is re-implemented to handle the
event.
||Offset||Field||Size||Value||Description
|0|bmRequestType|1|0x01|D7:0=Host to Device.\n
D6..5:00=Standard Request.\n
D4..0:00001=Recipient is interface.
|1|bRequest|1|0x0B|SET_INTERFACE.
|2|wValue|2|0x0000\n
or\n
0x0001|Zero bandwidth or normal isochronous operation.
|4|wIndex|2|0x0001|Interface number of the AudioStreaming interface.
|6|wLength|2|0x0000|No Parameter Block.
!!Class-specific requests
The only class-specific Request supported is the Set/Get Feature Unit Control
Request. For mute control of the Feature Unit.
!Set Feature Unit Control Request
||Offset||Field||Size||Value||Description
|0|bmRequestType|1|0x01|D7:0=Host to Device.\n
D6..5:01=Class Request.\n
D4..0:00001=Recipient is interface.
|1|bRequest|1|0x01|SET_CUR.
|2|wValue|2|0x0100|Mute control (AUDFeatureUnitRequest_MUTE) of\n
Master channel (AUDDSpeakerDriver_MASTERCHANNEL).
|4|wIndex|2|0x0200|Feature Unit (AUDDSpeakerDriverDescriptors_FEATUREUNIT)\n
and\n
AudioControl Interface (AUDDSpeakerDriverDescriptors_CONTROL).
|6|wLength|2|0x0001|Paramter Block Length
The one-byte Parameter Block contains the new bMuted value for Feature
Control.
!Get Feature Unit Control Request
||Offset||Field||Size||Value||Description
|0|bmRequestType|1|0x01|D7:0=Host to Device.\n
D6..5:01=Class Request.\n
D4..0:00001=Recipient is interface.
|1|bRequest|1|0x81|GET_CUR.
|2|wValue|2|0x0100|Mute control (AUDFeatureUnitRequest_MUTE) of\n
Master channel (AUDDSpeakerDriver_MASTERCHANNEL).
|4|wIndex|2|0x0200|Feature Unit (AUDDSpeakerDriverDescriptors_FEATUREUNIT)\n
and\n
AudioControl Interface (AUDDSpeakerDriverDescriptors_CONTROL).
|6|wLength|2|0x0001|Paramter Block Length
The one-byte Parameter Block contains the new bMuted value for Feature
Control.
!!!Modify the Device Driver
You can modify your project from the USB Audio Demoes:
- usb-device-audio-speaker-ac97-project
- usb-device-audio-speaker-project
!!Change Device ID and Display
All Device ID and Display Strings are in AUDDSpeakerDriverDescriptors.c.
!Device IDs
You can find "Audio Speaker Device Codes"
- AUDDSpeakerDriverDescriptors_VENDORID
- AUDDSpeakerDriverDescriptors_PRODUCTID
- AUDDSpeakerDriverDescriptors_RELEASE
!Display Strings
You can modify the string descriptors
- manufacturerDescriptor
- productDescriptor
- serialNumberDescriptor
!!!Add Recorder Function
See "USB Audio Recorder".
*/
/**
\page "USB Audio Recorder"
This page describes how to add recorder function into the
"USB Audio Speaker Device", So that you can learn how to extend your audio
device driver from current Audio Speaker demo.
!!!Description
To add %audio record function, new Input Terminal, Output Termnial and Feature
Unit is added.
\image UsbAudioSpeakerRecorder.png "USB Desktop Speaker Hierarchy"
!!!Modify the configuration descriptor:
New descriptor for the terminals and unit should be added, and according
interface, too.
\image UsbAudioSpeakerRecorderDescriptors.png "USB Desktop Speaker Descriptors"
!!Terminal Descriptors and Unit Descriptor
...
!Input Terminal Descriptor for recording
...
||Offset||Field||Size||Value||Description
|0|bLength|1|0x0C|Size of this descriptor, in bytes.
|1|bDescriptorType|1|0x24|CS_INTERFACE descriptor\n
(AUDGenericDescriptor_INTERFACE).
|2|bDescriptorSubType|1|0x03|INPUT_TERMINAL subtype\n
(AUDGenericDescriptor_INPUTTERMINAL).
|3|bTerminalID|1|0x03|ID of this Input Terminal\n
(AUDDSpeakerDriverDescriptors_INPUTTERMINAL_REC).
|4|wTerminalType|2|0x0403|Terminal is Speaker Phone\n
(AUDInputTerminalDescriptor_SPEAKERPHONE).
|6|bAssocTerminal|1|0x04|Associated to Output Terminal\n
(AUDDSpeakerDriverDescriptors_OUTPUTTERMINAL_REC).
|7|bNrChannels|1|0x02|Two channel.
|8|wChannelConfig|2|0x0003|Left plus right front channel.
|10|iChannelNames|1|0x00|Unused.
|11|iTerminal|1|0x00|Unused.
!Output Terminal Descriptor for recording
...
||Offset||Field||Size||Value||Description
|0|bLength|1|0x09|Size of this descriptor, in bytes.
|1|bDescriptorType|1|0x24|CS_INTERFACE descriptor\n
(AUDGenericDescriptor_INTERFACE).
|2|bDescriptorSubType|1|0x04|OUTPUT_TERMINAL subtype\n
(AUDGenericDescriptor_OUTPUTTERMINAL).
|3|bTerminalID|1|0x04|ID of this Output Terminal\n
(AUDDSpeakerDriverDescriptors_OUTPUTTERMINAL_REC).
|4|wTerminalType|2|0x0301|Terminal is USB stream\n
(AUDOutputTerminalDescriptor_USBTREAMING).
|6|bAssocTerminal|1|0x03|Associated to Input Terminal\n
(AUDDSpeakerDriverDescriptors_INPUTTERMINAL_REC).
|7|bSourceID|1|0x05|From Feature Unit\n
(AUDDSpeakerDriverDescriptors_FEATUREUNIT_REC).
|8|iTerminal|1|0x00|Unused.
!Feature Unit Descriptor for recording
...
||Offset||Field||Size||Value||Description
|0|bLength|1|0x0A|Size of this descriptor, in bytes.
|1|bDescriptorType|1|0x24|CS_INTERFACE descriptor\n
(AUDGenericDescriptor_INTERFACE).
|2|bDescriptorSubType|1|0x02|FEATURE_UNIT subtype\n
(AUDGenericDescriptor_FEATUREUNIT).
|3|bUnitID|1|0x05|ID of this Feature Unit\n
(AUDDSpeakerDriverDescriptors_FEATUREUNIT_REC).
|4|bSourceID|1|0x03|From Input Terminal\n
(AUDDSpeakerDriverDescriptors_INPUTTERMINAL_REC).
|5|bControlSize|1|0x01|1 byte per channel for controls
|6|bmaControls|3|0x000001|Master channel mute control, no other controls.
|9|iFeature|1|0x00|Unused.
!!Interface Descriptor and Endpoint Descriptor for recording
...
!Zero-bandwidth Alternate Setting 0
Standard AS Interface Descriptor (USBInterfaceDescriptor)
||Offset||Field||Size||Value||Description
|0|bLength|1|0x09|Size of this descriptor, in bytes.
|1|bDescriptorType|1|0x04|INTERFACE descriptor\n
(USBGenericDescriptor_INTERFACE).
|2|bInterfaceNumber|1|0x02|Index of this interface.
|3|bAlternateSetting|1|0x00|Index of this setting.
|4|bNumEndpoints|1|0x00|0 endpoint.
|5|bInterfaceClass|1|0x01|AUDIO (AUDStreamingInterfaceDescriptor_CLASS).
|6|bInterfaceSubClass|1|0x02|AUDIO_STREAMING\n
(AUDStreamingInterfaceDescriptor_SUBCLASS).
|7|bInterfaceProtocol|1|0x00|Unused (AUDStreamingInterfaceDescriptor_PROTOCOL).
|8|iInterface|1|0x00|Unused.
!Operational Alternate Setting 1
Standard AS Interface Descriptor (USBInterfaceDescriptor)
||Offset||Field||Size||Value||Description
|0|bLength|1|0x09|Size of USBInterfaceDescriptor in bytes.
|1|bDescriptorType|1|0x04|INTERFACE descriptor\n
(USBGenericDescriptor_INTERFACE).
|2|bInterfaceNumber|1|0x02|Index of this interface.
|3|bAlternateSetting|1|0x01|Index of this setting.
|4|bNumEndpoints|1|0x01|1 endpoint.
|5|bInterfaceClass|1|0x01|AUDIO (AUDStreamingInterfaceDescriptor_CLASS).
|6|bInterfaceSubClass|1|0x02|AUDIO_STREAMING\n
(AUDStreamingInterfaceDescriptor_SUBCLASS).
|7|bInterfaceProtocol|1|0x00|Unused (AUDStreamingInterfaceDescriptor_PROTOCOL).
|8|iInterface|1|0x00|Unused.
Class-specific AS General Interface Descriptor (AUDStreamingInterfaceDescriptor)
||Offset||Field||Size||Value||Description
|0|bLength|1|0x06|Size of AUDStreamingInterfaceDescriptor in bytes.
|1|bDescriptorType|1|0x24|CS_INTERFACE descriptor\n
(AUDGenericDescriptor_INTERFACE).
|2|bDescriptorSubType|1|0x01|GENERAL subtype\n
(AUDStreamingInterfaceDescriptor_GENERAL).
|3|bTerminalLink|1|0x02|Unit ID of the Input Terminal\n
(AUDDSpeakerDriverDescriptors_INPUTTERMINAL).
|4|bDelay|1|0x00|No interface delay.
|5|wFormatTag|2|0x0001|PCM Format (AUDFormatTypeOneDescriptor_PCM).
Type I Format Type Descriptor (AUDFormatTypeOneDescriptor1)
||Offset||Field||Size||Value||Description
|0|bLength|1|0x0B|Size of AUDFormatTypeOneDescriptor1 in bytes.
|1|bDescriptorType|1|0x24|CS_INTERFACE descriptor\n
(AUDGenericDescriptor_INTERFACE).
|2|bDescriptorSubType|1|0x02|FORMAT_TYPE subtype\n
(AUDStreamingInterfaceDescriptor_FORMATTYPE).
|3|bFormatType|1|0x01|FORMAT_TYPE_I (AUDFormatTypeOneDescriptor_FORMATTYPEONE).
|4|bNrChannels|1|0x02|2 channels (AUDDSpeakerDriver_NUMCHANNELS).
|5|bSubFrameSize|1|0x02|Two bytes per audio subframe\n
(AUDDSpeakerDriver_BYTESPERSAMPLE).
|6|bBitResolution|1|0x10|16 bits per sample\n
(AUDDSpeakerDriver_BYTESPERSAMPLE * 2).
|7|bSamFreqType|1|0x01|One frequency supported.
|8|tSamFreq|3|4800|4800Hz (AUDDSpeakerDriver_SAMPLERATE).
Standard %Endpoint Descriptor (AUDEndpointDescriptor)
||Offset||Field||Size||Value||Description
|0|bLength|1|0x09|Size of AUDFormatTypeOneDescriptor1 in bytes.
|1|bDescriptorType|1|0x24|ENDPOINT descriptor (USBGenericDescriptor_ENDPOINT).
|2|bEndpointAddress|1|0x85|IN endpoint 5\n
USBEndpointDescriptor_ADDRESS()\n
AUDDSpeakerDriverDescriptors_DATAIN
|3|bmAttributes|1|0x01|Isochronous, not shared\n
(USBEndpointDescriptor_ISOCHRONOUS).
|4|wMaxPacketSize|2|0x????|BOARD_USB_ENDPOINTS_MAXPACKETSIZE(5).
|6|bInterval|1|0x01|One packet per frame.
|7|bRefresh|1|0x00|Unused.
|8|bSynchAddress|1|0x00|Unused.
Class-specific Isochronous Audio Data Endpoint Descriptor
(AUDDataEndpointDescriptor)
||Offset||Field||Size||Value||Description
|0|bLength|1|0x07|Size of AUDDataEndpointDescriptor in bytes.
|1|bDescriptorType|1|0x25|CS_ENDPOINT descriptor\n
(AUDGenericDescriptor_ENDPOINT).
|2|bDescriptorSubType|1|0x01|GENERAL subtype\n
(AUDDataEndpointDescriptor_SUBTYPE).
|3|bmAttributes|1|0x00|No sampling frequency control\n
no pitch control\n
no packet padding
|4|bLockDelayUnits|1|0x00|Unused.
|5|wLockDelay|2|0x0000|Unused.
!!!Modified methods for new function
Several methods modified for new recorder function.
!!Request handlers callbacks
Add handler for new Interface, Terminal and Unit IDs.
See AUDDSpeakerDriver_RequestHandler.
!!Add function for recording USB stream
See AUDDSpeakerDriver_Write.
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -