CH32V203G6U6 issue with USB and Windows

Hello


I'm writing to get some help regarding USB device on my?CH32V203G6U6

I'm porting/implementing HID touchscreen and found that on Linux all works fine, I have multitouch but issue is on Windows


I have found that fix was done on Teensy but USB stack is much different for WCH and if some can help me understand and how to change this on WCH USB LIB

This is their fix:

Teensy 4.1 Windows fix

also one part is explained here

Microchip usb_config.h


And I know in WCH USB lfile: usb_core.c (or something else) we need to change it but I'm not so familiar with it so would be nice if someone can help me please


Also my base for doing this was sample from EVT: ch32v20x/EVT/EXAM/USB/USBD/CompositeKM


Thanks

I cant help you with the WCH implementation. You need to figure out that yourself. As far as I know WCH usually evaluates the Requests on bytelevel not on word level.


Anyway the case 0x01A1 means:

bmRequestType  A1:  classrequest on interface (CLASS_ | INTERFACE_)

bRequest             01:   means Get_Report          (GET_REPORT)


wValue                 0x300                                      (FEATURE_ << 8 | ReportId)

wIndex                 interface no                             (MULTITOUCH_INTERFACE)


wValue                 0x100                                      (INPUT_ << 8 | ReportId)

wIndex                 interface no                             (MULTITOUCH_INTERFACE)


see HID spec page50/51 hid1.2.pdf


in general all this magic numbers without comments in that patch is very bad programming




Hey usbman


You were 100% correct, after your post I have started to search for specific cases in WCH USB lib and found that specific handling is done in usb_prop.c


there is section in 

/*******************************************************************************

* @fn       USBD_Data_Setup

*

* @brief    handle the data class specific requests

*

* @param    Request Nb.

*

* @return   USB_UNSUPPORT or USB_SUCCESS.

*/

RESULT USBD_Data_Setup(uint8_t RequestNo


there is part in function


if (Request_No == HID_GET_REPORT)

    {

      /* HID Get Report */

    }


is where I added for POC


      /* HID Get Report */

if (USBbmRequestType == 0xa1 && Request_No == 0x01)

{

    uint8_t *point1 = (uint8_t *)&HID_Protocol_Value[0];

    uint8_t *point2 = (uint8_t *)&HID_Protocol_Value[1];

    

    *point1 = 0x02;

    *point2 = 0x02;

    

    pInformation->Ctrl_Info.Usb_wLength = 2;

    pInformation->Ctrl_Info.CopyData = &HID_Get_Protocol;

}


And it works, I get now normal enumeration of touchscreen and correct touchpoints


Wanna thank you a lot for hint :)


只有登录才能回复,可以选择微信账号登录