2.6.2.3.4 Receiving a Report

The application can receive a report from the Host by using the USB_DEVICE_HID_ReportReceive function. This function returns a transfer handler that allows the application to track the read request. The request is completed when the Host sends the report. The application must make sure that it allocates a buffer size that is at least the size of the report. The return value of the function indicates the success of the request. A read request could fail if the driver transfer queue is full. The completion of the read transfer is indicated by a USB_DEVICE_HID_EVENT_REPORT_RECEIVED event. The reportReceived member of the eventData data structure contains details about the received report. The following code shows an example of how a USB HID Keyboard can schedule a receive report operation to get the keyboard LED status.

/* The following code shows how the
 * USB HID Keyboard application schedules a
 * receive report operation to receive the
 * keyboard output report from the host. This
 * report contains the keyboard LED status. The
 * size of the report is 1 byte */

result = USB_DEVICE_HID_ReportReceive(appData.hidInstance,
             &appData.receiveTransferHandle,
             (uint8_t *)&appData.keyboardOutputReport,1);

if(USB_DEVICE_HID_RESULT_OK != result)
{
    /* Do error handling here */
}