使用了端点0、1、2枚举正常 *((u16 *)(PMAAddr)) = 0x0080;//(u16)ENDP0_TXADDR; *((u16 *)(PMAAddr+2*2)) = 0x0000; *((u16 *)(PMAAddr+4*2)) = 0x0040;//(u16)ENDP0_RXADDR; *((u16 *)(PMAAddr+6*2)) = 0x8400; *((u16 *)(PMAAddr+16)) = 0x00d0;//(u16)ENDP1_TXADDR; *((u16 *)(PMAAddr+16+2*2)) = 0x0000; *((u16 *)(PMAAddr+16+4*2)) = 0x00c0;//(u16)ENDP1_RXADDR; *((u16 *)(PMAAddr+16+6*2)) = 0x8000; *((u16 *)(PMAAddr+32)) = 0x00f0;//(u16)ENDP2_TXADDR; *((u16 *)(PMAAddr+32+2*2)) = 0x0000; *((u16 *)(PMAAddr+32+4*2)) = 0x00e0;//(u16)ENDP2_RXADDR; *((u16 *)(PMAAddr+32+6*2)) = 0x8000; 请用过的讲讲各个端点4个u16的数据都是什么意思 |
stm32 USB的CDC类传输掉数据
STM32F105 USB接收数据不断进入中断,出现“死机”现象
关于STM32CubeMX配置的USB例程电脑无法识别问题
STM32F407 USB-HS-OTG是否不外接PHY可以做虚拟串口?
如何做一个USB从机键盘用stm32f407
用STM32F4 Cube MX生成的USB Device C代码的BUG
USB Device + FatFS + SDIO 模拟U盘意外只读问题
USB Device + FatFS + SDIO 问题
STM32H7配置成USB DEVICE时,连接电脑时不进入中断
STM32F446 USB和串口1 冲突
不是给电脑发的描述符什么的是在STM32 USB缓冲区头几个字节的端点描述表。
谢谢,最后移植官方库了。
const uint8_t Speaker_DeviceDescriptor[] =
{
SPEAKER_SIZ_DEVICE_DESC, /* bLength */
USB_DEVICE_DESCRIPTOR_TYPE, /* bDescriptorType */
0x10,//0x00, /* 1.10 */ /* bcdUSB */
0x01,//0x02,
0x00, /* bDeviceClass */
0x00, /* bDeviceSubClass */
0x00, /* bDeviceProtocol */
MAX_EP0_SIZE, // 0x40, /* bMaxPacketSize 40 */
0x83,//0x8c,//0x0c,//0x51,//,//0x83, /* idVendor */
4,//0x0d,// 1,//0x20,//0x04,
0x21,//0x32,//0, /* idProduct = 0x5730*/
0x10,//0x03, // 0x57,
0x01,//0x00, /* 2.00 */ /* bcdDevice */
0x01,//0x02,
0,// 1, /* iManufacturer */
2, /* iProduct */
0,// 3, /* iSerialNumber */
0x01 /* bNumConfigurations */
};
/* USB Configuration Descriptor */
/* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
const uint8_t Speaker_ConfigDescriptor[] =
{
9,// 0 bLength 1 09h
2,// 1 bDescriptorType 1 02h Configuration
0x54,// 4,//0x54-7-9-9 -7-9-0x0e-9-9,// 2 wTotalLength 2 0154h SPEAKER_SIZ_CONFIG_DESC
0x01,
4,// 4 bNumInterfaces 1 04h
1,//5 bConfigurationValue 1 01h
0,//6 iConfiguration 1 00h
0xa0,//7 bmAttributes 1 A0h Bus Powered, Remote Wakeup
// 4..0: Reserved ...00000
//5: Remote Wakeup ..1..... Yes
//6: Self Powered .0...... No, Bus Powered
//7: Reserved (set to one)
//(bus-powered for 1.0) 1.......
0xfa,//8 bMaxPower 1 FAh 500 mA /* Configuration 1 */
//Interface Descriptor 0/0 Audio, 0 Endpoints
//Offset Field Size Value Description
9,//0 bLength 1 09h
4,// 1 bDescriptorType 1 04h Interface
0,// 2 bInterfaceNumber 1 00h
0,// 3 bAlternateSetting 1 00h
0,// 4 bNumEndpoints 1 00h
1,//5 bInterfaceClass 1 01h Audio
1,//6 bInterfaceSubClass 1 01h Audio Control
0,//7 bInterfaceProtocol 1 00h
0,//8 iInterface 1 00h
//Audio Control Interface Header Descriptor
//Offset Field Size Value Description
0x0a,//0 bLength 1 0Ah
0x24,// 1 bDescriptorType 1 24h Audio Control Interface Header
// 2 8 01 00 01 BB 00 02 01 02
01, 00, 01,0xBB, 00, 02, 01, 02,
//Audio Control Input Terminal Descriptor
//Offset Field Size Value Description
0x0c,//0 bLength 1 0Ch
0x24,// 1 bDescriptorType 1 24h Audio Control Input Terminal
// 2 10 02 01 01 01 00 08 3F 06
// 00 00
02, 01, 01, 01, 00, 0x08, 0x3F, 06,
00, 00,
//Audio Control Input Terminal Descriptor
//Offset Field Size Value Description
0x0c,//0 bLength 1 0Ch
0x24,// 1 bDescriptorType 1 24h Audio Control Input Terminal
// 2 10 02 04 01 02 00 02 03 00
// 00 00
02, 04, 01, 02, 00, 02, 03, 00,
00, 00,
//Audio Control Feature Unit Descriptor
//Offset Field Size Value Description
0x0a,//0 bLength 1 0Ah
0x24,// 1 bDescriptorType 1 24h Audio Control Feature Unit
// 2 8 06 08 04 01 40 02 02 00
06, 0x08, 04, 01, 0x40, 02, 02, 00,
//Audio Control Feature Unit Descriptor
//Offset Field Size Value Description
0x0a,//0 bLength 1 0Ah
0x24,// 1 bDescriptorType 1 24h Audio Control Feature Unit
// 2 8 06 09 04 01 01 02 02 00
06, 0x09, 04, 01, 01, 02, 02, 00,
//Audio Control Mixer Unit Descriptor
//Offset Field Size Value Description
0x19,//0 bLength 1 19h
0x24,// 1 bDescriptorType 1 24h Audio Control Mixer Unit
// 2 23 04 0C 03 01 09 0B 08 3F
//06 00 00 00 00 00 00 00
//00 00 00 00 00 00 00
04, 0x0C, 03, 01, 0x09, 0x0B, 0x08, 0x3F,
06, 00, 00, 00, 00, 00, 00, 00,
00, 00, 00, 00, 00, 00, 00,
//Audio Control Feature Unit Descriptor
//Offset Field Size Value Description
0x10,//0 bLength 1 10h
0x24,// 1 bDescriptorType 1 24h Audio Control Feature Unit
// 2 14 06 0D 0C 01 03 00 00 00
//00 00 00 00 00 00
06, 0x0D, 0x0C, 01, 03, 00, 00, 00,
00, 00, 00, 00, 00, 00,
//Audio Control Output Terminal Descriptor
//Offset Field Size Value Description
0x09,//0 bLength 1 09h
0x24,// 1 bDescriptorType 1 24h Audio Control Output Terminal
// 2 7 03 03 01 03 00 0D 00
03, 03, 01, 03, 00, 0x0D, 00,
//Audio Control Feature Unit Descriptor
//Offset Field Size Value Description
0x0a,//0 bLength 1 0Ah
0x24,// 1 bDescriptorType 1 24h Audio Control Feature Unit
// 2 8 06 02 0C 01 00 02 02 00
06, 02, 0x0C, 01, 00, 02, 02, 00,
//Audio Control Output Terminal Descriptor
//Offset Field Size Value Description
0x09,//0 bLength 1 09h
0x24,// 1 bDescriptorType 1 24h Audio Control Output Terminal
// 2 7 03 0A 01 01 00 07 00
03, 0x0A, 01, 01, 00, 07, 00,
//Audio Control Selector Unit Descriptor
//Offset Field Size Value Description
0x0a,//0 bLength 1 0Ah
0x24,// 1 bDescriptorType 1 24h Audio Control Selector Unit
// 2 8 05 07 04 08 0F 10 02 00
05, 07, 04, 0x08, 0x0F, 0x10, 02, 00,
//Audio Control Input Terminal Descriptor
//Offset Field Size Value Description
0x0c,//0 bLength 1 0Ch
0x24,// 1 bDescriptorType 1 24h Audio Control Input Terminal
02, 06, 03, 06, 00, 02, 03, 00,
00, 00,
//Audio Control Feature Unit Descriptor
//Offset Field Size Value Description
0x0a,//0 bLength 1 0Ah
0x24,// 1 bDescriptorType 1 24h Audio Control Feature Unit
// 2 8 06 0F 06 01 00 02 02 00
06, 0x0F, 06, 01, 00, 02, 02, 00,
//Audio Control Feature Unit Descriptor
//Offset Field Size Value Description
0x0a,//0 bLength 1 0Ah
0x24,// 1 bDescriptorType 1 24h Audio Control Feature Unit
// 2 8 06 0B 06 01 01 02 02 00
06, 0x0B, 06, 01, 01, 02, 02, 00,
//Audio Control Input Terminal Descriptor
//Offset Field Size Value Description
0x0c,//0 bLength 1 0Ch
0x24,// 1 bDescriptorType 1 24h Audio Control Input Terminal
// 2 10 02 05 05 06 00 02 03 00
// 00 00
02, 05, 05, 06, 00, 02, 03, 00,
00, 00,
//Audio Control Feature Unit Descriptor
//Offset Field Size Value Description
0x0a,//0 bLength 1 0Ah
0x24,// 1 bDescriptorType 1 24h Audio Control Feature Unit
// 2 8 06 10 05 01 01 00 00 00
06, 0x10, 05, 01, 01, 00, 00, 00,
//Interface Descriptor 1/0 Audio, 0 Endpoints
//Offset Field Size Value
* Function Name : Speaker_GetStringDescriptor.
* Description : Get the string descriptors according to the needed index.
* Input : Length : uint16_t.
* Output : None.
* Return : The address of the string descriptors.
*******************************************************************************/
uint8_t *Speaker_GetStringDescriptor(uint16_t Length)
{
uint8_t wValue0 = pInformation->USBwValue0;
if (wValue0 > 4)
{
return NULL;
}
else
{
return Standard_GetDescriptorData(Length, &String_Descriptor[wValue0]);
}
}
\DEVICE_PROP Device_Property =
DEVICE_PROP Device_Property =
{
CustomHID_init,
CustomHID_Reset,
CustomHID_Status_In,
CustomHID_Status_Out,
CustomHID_Data_Setup,
CustomHID_NoData_Setup,
CustomHID_Get_Interface_Setting,
CustomHID_GetDeviceDescriptor,
CustomHID_GetConfigDescriptor,
CustomHID_GetStringDescriptor,
0,
0x40 /*MAX PACKET SIZE*/
};
大体上相似这样的路径就都能够找到。