Please check this AN, it will be helpful:
What specifically you are getting as problem with keyboard LED output report.
There seems to be many ways for checking if data is ready for endpoints. In the USB datasheet it says:
Data write into the IN endpoint:
/* Check that IN endpoint buffer is empty before write data. */
if (USBFS_IN_BUFFER_EMPTY == USBFS_GetEPState(IN_EP))
/* Write data into IN endpoint buffer.
* Data is written after function returns and endpoint is available to be
* read by host.
USBFS_LoadInEP(IN_EP, buffer, length);
Data read from OUT endpoint:
/* Check if OUT endpoint buffer contain data to be read. */
if (USBFS_OUT_BUFFER_FULL == USBFS_GetEPState(OUT_EP))
/* Read data from OUT endpoint buffer.
* Data is read after function returns and endpoint is available to be
* written by host.
In the CY8CKIT_046_USB_Mouse example it says:
/* Send Keyboard data to PC, if there is an USB keyboard endpoint event pending */
if(USBFS_GetEPState(KEYBOARD_END_POINT) == USBFS_EVENT_PENDING)
USBFS_LoadInEP(KEYBOARD_END_POINT, (uint8 *)keyboardReport, KEY_RPT_SIZE);
usbDataSentFlag |= KEYBOARD_DATA_SENT;
In the AN58726 example it says:
/*Checks for ACK from host*/
/*Function to Send Data to PC*/
/*Function to recieve data from PC*/
Which is the correct check to determine if I can read/write to endpoints for HID keyboard?
You can use either of the method as depicted in CY8CKIT_046_USB_Mouse Example Code or AN58726 .
Are you getting any issue in using the methods.
I'm trying to read data from OUT EP and I am having problems. I am doing this in main loop:
if (USBFS_OUT_BUFFER_FULL == USBFS_GetEPState(OUTPUT_END_POINT))
USBFS_ReadOutEP(OUTPUT_END_POINT, buf, HID_RPT_SIZE);
I can only read the first OUT packet successfully and the second packet reads out random incorrect data.