I am using HID communication (IN and OUT interrupt endpoints) in a main loop of my custom code. It's supposed to check for OUT messages every loop iteration.
The code looks like this:
Code: Select all
while (1)
{
  /* Receive a buffer (512-bytes) of data from the host */
  host_transfer_length = XUD_GetBuffer(ep_from_host, (ubuf, char[HID_BUFFER_SIZE*4]));
  if(host_transfer_length < 0) 
  {
      XUD_ResetEndpoint(ep_from_host, ep_to_host);
  }
  else if (host_transfer_length > 0)
  {
    Develop_hid();
    /* Send the modified buffer back to the host */
    host_transfer_length = XUD_SetBuffer(ep_to_host, (ubuf, char[HID_BUFFER_SIZE*4]), host_transfer_length);
    if(host_transfer_length < 0)
      XUD_ResetEndpoint(ep_from_host, ep_to_host);
  }
    
  /*** Custom code **/
  /*.........................*/
  /*****************/
  
}
The XUD_GetBuffer() blocks execution waiting for a message.
Is there any way around it (I don't have any extra cores available)?
Like using a streaming channel or something like that.
But I have no idea how to do it in this case.
Please advise.
Thank you,
Gennady

