laotui 发表于 2015-4-22 11:57:58

STM32 USB 端点描述表怎么写

使用了端点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的数据都是什么意思

党国特派员 发表于 2015-4-22 12:31:09

这个你要看USB的协议了。

laotui 发表于 2015-4-22 12:32:56

党国特派员 发表于 2015-4-22 12:31
这个你要看USB的协议了。

不是给电脑发的描述符什么的是在STM32 USB缓冲区头几个字节的端点描述表。

拼命三郎 发表于 2015-4-22 23:01:32

拼命三郎 发表于 2015-4-22 23:02:42

laotui 发表于 2015-4-25 16:37:03

拼命三郎 发表于 2015-4-22 23:02


谢谢,最后移植官方库了。

羿日光年 发表于 2015-4-25 21:04:27

我也是移植官方的库

powder-320203 发表于 2015-4-26 00:36:16

设备描述符在这里改:
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 */
};

powder-320203 发表于 2015-4-26 00:37:33

配置描述符在这里改:
/* 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

powder-320203 发表于 2015-4-26 00:39:03

字符描述符在这里改:
* 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);
}
}
页: [1] 2
查看完整版本: STM32 USB 端点描述表怎么写