FX3 USB3 (some USB3) and USB2 HID interface behaviour

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
FuBe_4381791
Level 4
Level 4
10 questions asked 50 sign-ins 25 replies posted

Hello Cypress!

I've run into some really strange behaviour with my HID keyboard interface, it is essentially the same as the mouse interface example, but for some reason it works perfectly when in a USB2 connection, and on some USB3, it sometimes works, and it works perfectly on other USB3 connections (such as through my USB3 hub).

The times when it does not work, is as if the key is held down for an extended period of time, sometimes as long as 9 seconds. I have no idea what could cause this difference in behavior on different hosts.

I have tried: removing the check for failure to commit or get buffer, changing the servicing interval on the SS descriptor from the HID mouse example to a larger value, and I even tried changing the thread priority to the same as the driver level (I know this is not recommended but I was curious if the FX3 was getting hung up on a driver call) and these had no effect.

Writing this I will double check if the driver handler callback is perhaps resetting the USB thread separately. If this is the issue I will make a comment here.

What confuses me the most is that this is not an issue on all USB3, but only on some....

    outBuf.buffer = 0;

    outBuf.status = 0;

    outBuf.size   = 8;

    outBuf.count  = 8;

    CyU3PDmaChannelReset (&KeyboardDMA);

    CyU3PDmaChannelSetXfer (&KeyboardDMA, 0);

CyU3PBusyWait (2000);

while (i < to_type_len && to_type != '\0'){

        status = CyU3PDmaChannelGetBuffer (&KeyboardDMA, &outBuf, 1000);

        key_out = keyboard_output(to_type);

outBuf.buffer[0] = (uint8_t)((key_out >> 😎 & 0xff);

outBuf.buffer[1]=0x00;

outBuf.buffer[2]= (uint8_t)(key_out & 0xff);

outBuf.buffer[3]=0x00;outBuf.buffer[4]=0x00;outBuf.buffer[5]=0x00;

outBuf.buffer[6]=0x00;outBuf.buffer[7]=0x00;

        status = CyU3PDmaChannelCommitBuffer (&KeyboardDMA, 8, 0);

        CyU3PBusyWait (2000);

status = CyU3PDmaChannelGetBuffer (&KeyboardDMA, &outBuf, 1000);

outBuf.buffer[0]=0x00;outBuf.buffer[1]=0x00;

outBuf.buffer[2]=0x00;outBuf.buffer[3]=0x00;

outBuf.buffer[4]=0x00;outBuf.buffer[5]=0x00;

outBuf.buffer[6]=0x00;outBuf.buffer[7]=0x00;

status = CyU3PDmaChannelCommitBuffer (&KeyboardDMA, 8, 0);

if (status != CY_U3P_SUCCESS){

CyU3PDmaChannelReset (&KeyboardDMA);

CyU3PDmaChannelSetXfer (&KeyboardDMA, 0);

}

CyU3PBusyWait (2000);

    i++;

    }

0 Likes
1 Solution

Hello Yashwant!

I managed to get it working, the 2 changes I made was adding to the LPM a check that keyboard output was not active (I do not know if this is been used):

if (glMscDriverBusy == CyFalse && keyboard_output_command ==0){

return CyTrue;

}

return CyFalse;

and modifying the interval in the descriptor:

//Endpoint Descriptor keyboard

0x07,  //Descriptor size

0x05,  //bDescriptorType: USB_ENDPOINT_DESCRIPTOR_TYPE

Keyboard_EP,  //bEndpointAddress in 0x83 Keyboard_EP

0x03,  //bmAttributes: USB_ENDPOINT_TYPE_INTERRUPT

0x08,0x00,  //wMaxPacketSize

0x04,  //bInterval

// Super Speed Endpoint Descriptor keyboard

0x06,                           // Descriptor size

0x30,    // SS Endpoint Companion Descriptor Type CY_FX_SS_EP_COMPN_DSCR_TYPE

0x00,                           // Max no. of packets in a Burst.

0x00,                           // No streaming for Interrupt Endpoints.

0x08,0x00                       // Number of bytes per interval = 2.

Thanks!

Fujimi

View solution in original post

0 Likes
3 Replies