搜索
查看: 1067|回复: 1

[原创] USB鼠标例程改成模拟触摸屏报点枚举中出现stall pid错误

[复制链接]

该用户从未签到

0

主题

3

帖子

0

蝴蝶豆

中级会员

最后登录
2020-11-13
发表于 2020-11-8 17:36:25 | 显示全部楼层 |阅读模式
请教各位大佬,我最近使用F405芯片,用stm32CubeMX默认创建了一个USBHID的例程,这个例程默认就是一个HID模拟鼠标移动的程序,我创建之后也是可以正常枚举并且鼠标正常移动的,说明生成的工程是没有问题的,然后我把报告描述符修改成了一个多点触摸的描述符,这个描述符是以前项目使用的,是没有问题的。变量也没有改变,只是把报告描述符的内容替换了,如下图:
1.png
这个报告描述符字节比较大,又474个字节,然后我又把相应的配置描述符修改了,如下图所示:

把配置描述符集合里HID描述符中描述报告描述符大小的字节改成我们修改后的大小,如下图
3.png

按道理,将这些修改之后,就相当于重新约定了HID上报数据的协议,随后,我又按照新规定的报告描述符的协议模拟上报触控点的数据。
通过Bus hound显示枚举是成功的,也一直在按照报告描述符规定的协议向主机发送数据,但是没有模拟触控的现象,我使用以前的工程是有明显
的触控屏幕的现象的。通过设备管理器查看设备是正常运行的,然后用Bus hound观察枚举过程,发现一直在上报数据,但是在枚举过程中在主机
发送GET_REPORT之后出现了USTS c0000004   stall pid 错误,出现之后枚举也没有停止,而是正常运行的,数据也是正常上报的,
但就是没有现象,我感觉是主机没有接收到报告描述符,或者接收错误了,导致虽然数据是正常上报的,但是系统不知道上报的数据的含义,
有没有大佬懂得这方面的错误,还请指导一下,工程其他地方都没有动,就是修改了配置、报告描述符等信息。
4.png

5.png

2.png
回复

使用道具 举报

该用户从未签到

0

主题

6

帖子

0

蝴蝶豆

初级会员

最后登录
2020-12-28
发表于 2020-12-28 17:10:00 | 显示全部楼层
__ALIGN_BEGIN static uint8_t Entity3Desc[] __ALIGN_END =
{
//Below is the report descriptor for an example multi-touch device, which can support
//up to 5 simultaneous contacts.  This report descriptor also supports multiple device modes.
//The OS may select the device mode (ex: mouse, single-touch digitizer, multi-touch digitizer)
//by sending a SET_REPORT (feature) control transfer.  In each mode, the device firmware
//should behave differently and send input packets on the HID IN endpoint, formatted
//based on the report descriptor collections associated with that mode.

//Each IN packet (HID report) sent to the host (in multi-touch digitizer mode) is ?? bytes long (Bytes 0-13).  
//The data is sent in little endian format.  To send the report to the host, verify
//that the HID IN endpoint buffer is not already busy, then place the data in the HID
//IN endpoint buffer SRAM, and then call the UsbSendEP5Report() function.  The data will
//then get sent to the host, at the next opportunity when the host polls that endpoint
//(by sending an IN token packet to the endpoint).

//NOTE (Contact identifier number): For a multi-touch device, the firmware needs to
//keep track of each contact point separately and independantly.  For example, suppose
//a human first presses one finger to the screen.  The firmware would detect this, and
//it should arbitrarily assign a contact identifier number for this contact. Typically
//it would be assigned something like contact ID = "1". As the human moves their finger
//around on the contact surface the firmware will report new X and Y coordinate
//information for this contact, but the contact ID byte should always be = "1" for
//this contact.
//
//Now suppose the human places a second finger onto the touch surface, so there are
//two simultanous contacts.  The firmware should assign this second contact a new
//contact ID, for instance, contact ID = "2".  So long as the first contact is still
//valid, the firmware needs to continue reporting ID = "1" for the first contact.  
//The firmware will continue to report information using these contact ID numbers
//until such time as a contact becomes invalid (human removes their finger from the
//screen).


    //Top level collection for use in Multi-Touch Digitizer device mode.
    //-------------------------------------------------------------------
    //Format for multi-touch digitizer input reports Using this report descriptor:
    //Byte[0] = Report ID == MULTI_TOUCH_DATA_REPORT_ID
    //1st contact point info in bytes 1-6.
    //Byte[1] = Bits7-3: pad bits (unused), Bit1:In Range, Bit0:Tip Switch
    //Byte[2] = Contact identifier number (see note above)
    //Byte[3] = X-coordinate LSB
    //Byte[4] = X-coordinate MSB
    //Byte[5] = Y-coordinate LSB
    //Byte[6] = Y-coordinate MSB
   
    //2nd contact point info in bytes 7-12
    //Byte[7] = Bits7-3: pad bits (unused), Bit1:In Range, Bit0:Tip Switch
    //Byte[8] = Contact identifier number (see note above)
    //Byte[9] = X-coordinate LSB
    //Byte[10]= X-coordinate MSB
    //Byte[11]= Y-coordinate LSB
    //Byte[12]= Y-coordinate MSB

    //3rd contact point info in bytes 13-18
    //Byte[13] = Bits7-3: pad bits (unused), Bit1:In Range, Bit0:Tip Switch
    //Byte[14] = Contact identifier number (see note above)
    //Byte[15] = X-coordinate LSB
    //Byte[16] = X-coordinate MSB
    //Byte[17] = Y-coordinate LSB
    //Byte[18] = Y-coordinate MSB
   
    //4th contact point info in bytes 19-24
    //Byte[19] = Bits7-3: pad bits (unused), Bit1:In Range, Bit0:Tip Switch
    //Byte[20] = Contact identifier number (see note above)
    //Byte[21] = X-coordinate LSB
    //Byte[22] = X-coordinate MSB
    //Byte[23] = Y-coordinate LSB
    //Byte[24] = Y-coordinate MSB

    //5th contact point info in bytes 25-30
    //Byte[25] = Bits7-3: pad bits (unused), Bit1:In Range, Bit0:Tip Switch
    //Byte[26] = Contact identifier number (see note above)
    //Byte[27] = X-coordinate LSB
    //Byte[28]= X-coordinate MSB
    //Byte[29]= Y-coordinate LSB
    //Byte[30]= Y-coordinate MSB

    //Byte[31]= 8-bit number indicating how many of the above contact points are valid.  
    //                        If only the first contact is valid, send "1" here.  If both are valid, send "2".......etc.

    //HID Report descriptor for an example Multi-Touch (5 simultaneous contacts), multi-modes device.
    //------------------------------------------------------------------------------------------------
    //Note: In a real application, at a minimum, certain terms in the report descriptor
    //(ex: UNIT, UNIT_EXPONENT, PHYSICAL_MAXIMUM and LOGICAL_MAXIMUM) will need to be modified to
    //match the characteristics (ex: size) of the actual application being developed.  See the HID1_11.pdf
    //specifications regarding these terms.


    //contact point
    0x05, 0x0D,                  // USAGE_PAGE (Digitizers)         
    0x09, 0x04,                  // USAGE (Touch Screen)            
    0xA1, 0x01,           // COLLECTION (Application)         
    0x85, MULTI_TOUCH_DATA_REPORT_ID,        //   REPORT_ID (Touch)   
    0x09, 0x22,           //   USAGE (Finger)
    //Finger 0     
    FINGER_USAGE,  
    //Finger 1     
    FINGER_USAGE,
    //Finger 2     
    FINGER_USAGE,
    //Finger 3     
    FINGER_USAGE,   
    //Finger 4     
    FINGER_USAGE,
    //Finger 5     
    FINGER_USAGE,
    //Finger 6     
    FINGER_USAGE,
    //Finger 7     
    FINGER_USAGE,
    //Finger 8     
    FINGER_USAGE,
    //Finger 9     
    FINGER_USAGE,

    //Timestamp in relative time - Scan Time

        0x05, 0x0D,                    //   Usage Page (Digitizer)
        0x55, 0x0C,                    //   Unit Exponent (-4)
        0x66, 0x01, 0x10,              //   Unit (Seconds)
        0x47, 0xFF, 0xFF, 0x00, 0x00,  //   Physical Maximum (65535)
        0x27, 0xFF, 0xFF, 0x00, 0x00,  //   Logical Maximum (65535)
        0x75, 0x10,                    //   Report Size (16)
        0x95, 0x01,                    //   Report Count (1)
        0x09, 0x56,                    //   Usage (0x56, Relative Scan Time)
        0x81, 0x02,                    //   Input (Data,Var,Abs)

    //indicating how many of the above contact points
   
    0x05, 0x0D,                  //   USAGE_PAGE (Digitizers)   
    0x09, 0x54,                  //   USAGE (Actual (contact) count)
    0x95, 0x01,           //   REPORT_COUNT (1)
    0x75, 0x08,           //   REPORT_SIZE (8)   
    0x25, 0x0A,           //   LOGICAL_MAXIMUM (10)                               
    0x81, 0x02,           //   INPUT (Data,Var,Abs)                               

    //In addition to standard HID reports (containing contact X/Y/tip-switch/in-range
    //information), the firmware can send feature report information to the host.  
    //Feature reports lets the host know information about the firmware/hardware
    //application design.  The host will typically request a feature report by sending
    //a GET_REPORT control transfer, with the bRequest = REPORT, but with wIndex (MSB) = 0x03
    //(get feature report request as indicated in the HID1_11.pdf specifications). If a
    //feature report is sent to the host, it should be sent as a 2-byte packet (for
    //this example project), formatted like follows:
    //Byte[0]= Report ID == VALID_CONTACTS_FEATURE_REPORT_ID == Feature report ID
    //Byte[1]= Maximum number of contacts simultaneously supported by this application.  Always == 2 in this demo, since this report descriptor only has input fields for 2 contact points
    //See the UserGetReportHandler() function that sends this type of packet in the MultiTouch.c file.

    //GET_REPORT CTL : A1 01 52 03 04 00 02 00
    //            IN : 52 05
   
    0x85, VALID_CONTACTS_FEATURE_REPORT_ID,   //   REPORT_ID (Feature)        
    0x09, 0x55,                               //   USAGE(Maximum Count)
    0xB1, 0x02,                               //   FEATURE (Data,Var,Abs)

    0x06, 0x00, 0xff,                         //     USAGE_PAGE (Vendor Defined)   
    0x09, 0xC5,                               //     USAGE (Vendor Usage 0xC5)
    0x85, VALID_CONTACTS_FEATURE_REPORT_ID,   //     REPORT_ID (VALID_CONTACTS_FEATURE_REPORT_ID)   
    0x15, 0x00,                               //     LOGICAL_MINIMUM (0)         
    0x26, 0xff, 0x00,                         //     LOGICAL_MAXIMUM (0xff)
    0x75, 0x08,                               //     REPORT_SIZE (8)            
    0x96, 0x00, 0x01,                         //     REPORT_COUNT (0x100) (256)
    0xB1, 0x02,                               //     FEATURE (Data,Var,Abs)
   
    0x05, 0x0d,                               //    USAGE_PAGE (Digitizer)
    0x85, Latency_Mode_Feature_Report_ID,     //    REPORT_ID (Latency)              
    0x09, 0x60,                               //    USAGE(Latency Mode)
    0x75, 0x01,                               //    REPORT_SIZE (1)
    0x95, 0x01,                               //    REPORT_COUNT (1)
    0x15, 0x00,                               //    LOGICAL_MINIMUM (0)
    0x25, 0x01,                               //    LOGICAL_MAXIMUM (1)
    0xb1, 0x02,                               //    FEATURE (Data,Var,Abs)
    0x95, 0x07,                               //    REPORT_COUNT (7)            
    0xb1, 0x03,                               //    FEATURE (Cnst,Var,Abs)
   
    0xC0,                                     // END_COLLECTION


    //Top level collection describing the feature report that the host will use (SET_REPORT (feature) control transfer) to set the device mode (ex: mouse, single-touch digitizer, multi-touch digitizer)
    //-------------------------------------------------------------------
    //Format of the feature report output data that the host will send to the device (when it wants to change the device mode):
    //byte[0] = Report ID = DEVICE_MODE_FEATURE_REPORT_ID
    //byte[1] = Device Mode (that the device should switch into)
    //byte[2] = Device Identifier

    //SET_REPORT CTL : 21 09 53 03 04 00 03 00
    //            IN : 53 02 00
   
    0x09, 0x0E,           // USAGE (Device Configuration)
    0xa1, 0x01,           // COLLECTION (Application)
    0x85, DEVICE_MODE_FEATURE_REPORT_ID,     //   REPORT_ID (Configuration)              
    0x09, 0x23,           //   USAGE (Device Settings)              
    0xa1, 0x02,           //   COLLECTION (logical)   
    0x09, 0x52,           //    USAGE (Device Mode)         
    0x09, 0x53,           //    USAGE (Device Identifier)
    0x15, 0x00,           //    LOGICAL_MINIMUM (0)      
    0x25, 0x0a,           //    LOGICAL_MAXIMUM (10)
    0x75, 0x08,           //    REPORT_SIZE (8)         
    0x95, 0x02,           //    REPORT_COUNT (2)         
    0xb1, 0x02,           //   FEATURE (Data,Var,Abs)   
    0xc0,                 //   END_COLLECTION (logical)
    0xc0,                 // END_COLLECTION (application)
   

    //Top level collection for use in Mouse device mode.
    //-------------------------------------------------------------------
    0x05, 0x01, // Usage Page (Generic Desktop)            
    0x09, 0x02, // Usage (Mouse)                           
    0xA1, 0x01, // Collection (Application)                 
    0x85, MOUSE_DATA_REPORT_ID, //  REPORT_ID (mouse)
    0x09, 0x01, //  Usage (Pointer)                        
    0xA1, 0x00, //  Collection (Physical)                  
    0x05, 0x09, //      Usage Page (Buttons)               
    0x19, 0x01, //      Usage Minimum (01)                  
    0x29, 0x03, //      Usage Maximum (03)                  
    0x15, 0x00, //      Logical Minimum (0)                 
    0x25, 0x01, //      Logical Maximum (1)                 
    0x45, 0x00, //      Physical Maximum (0)
    0x65, 0x00, //      Unit (none)                  
    0x95, 0x03, //      Report Count (3)                    
    0x75, 0x01, //      Report Size (1)                     
    0x81, 0x02, //      Input (Data, Variable, Absolute)   
    0x95, 0x01, //      Report Count (1)                    
    0x75, 0x05, //      Report Size (5)                     
    0x81, 0x01, //      Input (Constant)    ;5 bit padding  
    0x05, 0x01, //      Usage Page (Generic Desktop)        
    0x09, 0x30, //      Usage (X)                           
    0x09, 0x31, //      Usage (Y)                           
    0x15, 0x81, //      Logical Minimum (-127)              
    0x25, 0x7F, //      Logical Maximum (127)               
    0x75, 0x08, //      Report Size (8)                     
    0x95, 0x02, //      Report Count (2)                    
    0x81, 0x06, //      Input (Data, Variable, Relative)   
    0xC0,                 //  End Collection
    0xC0,              // End Collection            
};

#define  FINGER_USAGE  \
    0xA1, 0x02,           /*    COLLECTION (Logical)                   */  \
    0x05, 0x0D,                  /*       USAGE_PAGE (Digitizers)             */  \
    0x09, 0x42,           /*       USAGE (Tip Switch)                  */  \
    0x15, 0x00,           /*       LOGICAL_MINIMUM (0)                 */  \
    0x25, 0x01,           /*       LOGICAL_MAXIMUM (1)                 */  \
    0x75, 0x01,           /*       REPORT_SIZE (1)                     */  \
    0x95, 0x01,           /*       REPORT_COUNT (1)                    */  \
    0x81, 0x02,           /*       INPUT (Data,Var,Abs)                        */  \
    0x09, 0x32,                  /*       USAGE (In Range)                    */  \
    0x81, 0x02,           /*       INPUT (Data,Var,Abs)                */  \
    0x09, 0x51,           /*       Usage(Contact ID)                   */  \
    0x75, 0x06,           /*       REPORT_SIZE (6)                     */  \
    0x95, 0x01,           /*       REPORT_COUNT (1)                    */  \
    0x15, 0x00,           /*       LOGICAL_MINIMUM (0)                 */  \
    0x25, 0x3F,           /*       LOGICAL_MAXIMUM (63)                */  \
    0x81, 0x02,           /*       INPUT (Data,Var,Abs)                */  \
    0x05, 0x01,           /*       USAGE_PAGE (Generic Desk..          */  \
    0x26, 0x20, 0x35,     /*       LOGICAL_MAXIMUM (13600)                  */  \
    0x75, 0x10,           /*       REPORT_SIZE (16)                    */  \
    0x95, 0x01,           /*       REPORT_COUNT (1)                                  */  \
    0x55, 0x0E,           /*       UNIT_EXPONENT (-2)                  */  \
    0x65, 0x33,           /*       UNIT (Inches, English Linear)       */  \
    0x09, 0x30,           /*       USAGE (X)                           */  \
    0x35, 0x00,           /*       PHYSICAL_MINIMUM (0)                */  \
    0x46, 0x50, 0x05,     /*       PHYSICAL_MAXIMUM (0x550 = 1360)     */  \
    0x81, 0x02,           /*       INPUT (Data,Var,Abs)                */  \
    0x26, 0xE2, 0x1D,     /*       LOGICAL_MAXIMUM (7650)              */  \
    0x46, 0xFD, 0x02,     /*       PHYSICAL_MAXIMUM (0x2FD = 765)      */  \
    0x09, 0x31,           /*       USAGE (Y)                           */  \
    0x81, 0x02,           /*       INPUT (Data,Var,Abs)                               */  \
    0xC0                  /*    END_COLLECTION                         */  
#endif

你可以試試看這是我寫的觸控描述
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 注册/登录

本版积分规则

关闭

站长推荐上一条 /3 下一条

Archiver|手机版|小黑屋|论坛-意法半导体STM32/STM8技术社区

GMT+8, 2024-4-20 12:00 , Processed in 0.191153 second(s), 33 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表