解析 /* Class-spec AS ISO Audio Data endpoint Descriptor */ 0x07, /* bLength */ 0x25, /* bDescriptorType:CS_ENDPOINT */ 0x01, /* bDescriptorSubType:EP_GENERAL */ 0x80, /* bmAttributes */ 0x00, /* bLockDelayUnits */ 0x00, 0x00, /* wLockDelay */
时间: 2023-10-26 13:04:50 浏览: 46
该描述符是一个Class-spec AS ISO Audio Data endpoint描述符,表示一个用于音频数据传输的端点。各字段含义如下:
- bLength:描述符长度,为0x07;
- bDescriptorType:描述符类型,为0x25,表示该描述符为Class-spec AS描述符;
- bDescriptorSubType:描述符子类型,为0x01,表示该描述符为Endpoint General描述符;
- bmAttributes:端点属性,为0x80,表示该端点为异步端点;
- bLockDelayUnits:锁定延迟的单位,为0x00,表示不使用锁定延迟;
- wLockDelay:锁定延迟的值,为0x0000,表示不使用锁定延迟。
总之,这个描述符主要是为了描述一个音频数据传输的异步端点,并且不使用锁定延迟。
相关问题
ubuntu下,usb设备信息显示为 Bus 002 Device 004: ID 0403:6001 Future Technology Devices International, Ltd FT232 Serial (UART) IC Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 0 bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 8 idVendor 0x0403 Future Technology Devices International, Ltd idProduct 0x6001 FT232 Serial (UART) IC bcdDevice 6.00 iManufacturer 1 (error) iProduct 2 (error) iSerial 3 (error) bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 0x0020 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xa0 (Bus Powered) Remote Wakeup MaxPower 90mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 255 Vendor Specific Class bInterfaceSubClass 255 Vendor Specific Subclass bInterfaceProtocol 255 Vendor Specific Protocol iInterface 2 (error) Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x02 EP 2 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 can't get device qualifier: Resource temporarily unavailable can't get debug descriptor: Resource temporarily unavailable Device Status: 0x0000 是什么原因
根据设备信息显示,USB设备是FT232芯片的串行通讯接口设备,但是在字段iManufacturer、iProduct和iSerial中显示为(error),原因可能是设备驱动没有正确加载或者设备没有正确识别。另外,can't get device qualifier和can't get debug descriptor的错误提示可能是由于权限不足或者其他系统问题导致的。可以尝试以root权限运行lsusb命令或者重启系统来解决这些问题。
stm32F103 usbcfg中的usb audio 发送函数,请举一个详细的例子
好的,以下是一个使用USBCFG实现的USB音频发送的详细例子:
首先,在USBCFG的配置文件中,需要添加音频流输入(Audio Streaming IN)的描述符,如下所示:
```c
/* USB AUDIO device Configuration Descriptor */
const uint8_t USBD_CfgDesc[USB_AUDIO_CONFIG_DESC_SIZ] =
{
0x09, /* bLength: Configuation Descriptor size */
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
USB_AUDIO_CONFIG_DESC_SIZ, /* wTotalLength: configuration descriptor set total length */
0x00,
0x01, /* bNumInterfaces: 1 interface */
0x01, /* bConfigurationValue: configuration value */
0x00, /* iConfiguration: index of string descriptor describing the configuration */
0xC0, /* bmAttributes: self powered */
0x32, /* MaxPower 100 mA */
/************** Descriptor of Audio interface ********************/
/* Audio interface descriptor (9 bytes) */
0x09, /* bLength: Interface Descriptor size */
USB_DESC_TYPE_INTERFACE, /* bDescriptorType: Interface descriptor type */
0x00, /* bInterfaceNumber: Number of Interface */
0x00, /* bAlternateSetting: Alternate setting */
0x00, /* bNumEndpoints: One endpoints used */
0x01, /* bInterfaceClass: Audio */
0x01, /* bInterfaceSubClass: Audio Streaming */
0x00, /* bInterfaceProtocol: Unused */
0x00, /* iInterface: Index of string descriptor */
/****************** Descriptor of Audio Streaming ******************/
/* Audio Streaming Interface Descriptor (7bytes) */
0x07, /* bLength: Endpoint Descriptor size */
USB_AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType: Interface descriptor type */
USB_AUDIO_STREAMING_GENERAL, /* bDescriptorSubtype: General */
0x01, /* bTerminalLink: Terminal ID of the Output Terminal */
0x00, /* bDelay: Delay introduced by the data path */
0x01, /* wFormatTag: PCM Format */
/******************** Audio Format Descriptor **************************/
/* Audio Format Descriptor (11 bytes) */
0x0B, /* bLength: Endpoint Descriptor size */
USB_AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType: Interface descriptor type */
USB_AUDIO_STREAMING_FORMAT_TYPE, /* bDescriptorSubtype: Format */
0x01, /* bFormatType: Type of the format */
0x02, /* bNrChannels: Number of channels */
0x02, /* bSubFrameSize: Size of a sample */
0x10, /* bBitResolution: Number of bits per sample */
0x01, /* bSampleFrequencyType: Type of the sampling frequency */
0x40, /* tSampleFrequency: Sampling frequency */
/******************** Endpoint Descriptor **************************/
/* Endpoint 1 Descriptor (9 bytes) */
0x09, /* bLength: Endpoint Descriptor size */
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
AUDIO_IN_EP, /* bEndpointAddress: Endpoint Address (IN) */
0x05, /* bmAttributes: Bulk */
AUDIO_PACKET_SZE, /* wMaxPacketSize: 64 Bytes max */
0x00,
0x00, /* bInterval: Polling Interval (ignored) */
};
```
其中,`AUDIO_IN_EP`是音频流输入的端点地址,`AUDIO_PACKET_SZE`是音频数据包的大小。
接着,在USBCFG的源文件中,需要编写音频流输入发送函数,如下所示:
```c
/**
* @brief USBD_AUDIO_Sync
* Copy buffer from user into data buffer used for sync transfer
* @param pdev: device instance
* @param offset: offset in the audio buffer where the copy should be done
* @retval status
*/
uint8_t USBD_AUDIO_Sync(void *pdev, uint32_t offset)
{
// 等待直到USB准备好发送数据
while (USBD_AUDIO_StreamIn_IsReady(pdev) != USBD_OK);
// 获取音频数据缓冲区指针
uint8_t* buf = USBD_AUDIO_GetInBuffer(pdev, offset);
// 将音频数据复制到缓冲区
memcpy(buf, audio_buffer, AUDIO_BUFFER_SIZE);
// 发送音频数据包
USBD_AUDIO_StreamIn(pdev, buf, AUDIO_PACKET_SZE);
return USBD_OK;
}
```
在该示例中,`USBD_AUDIO_StreamIn_IsReady()`函数用于检查USB准备好发送数据的状态,`USBD_AUDIO_GetInBuffer()`函数用于获取音频数据缓冲区指针,`memcpy()`函数用于将音频数据复制到缓冲区,`USBD_AUDIO_StreamIn()`函数用于将音频数据包发送到主机。
需要注意的是,该示例中的`audio_buffer`是音频数据缓冲区,`AUDIO_BUFFER_SIZE`是缓冲区的大小,`AUDIO_PACKET_SZE`是音频数据包的大小。需要根据您的应用场景和需求进行更加详细的配置和设置,以保证USB音频发送的功能和稳定性。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![gz](https://img-home.csdnimg.cn/images/20210720083447.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)