Jump to main content

##

# 2.6.2.3.3 Sending a Report

The USB HID Device sends data to the USB HID Host as reports. The USB HID Device application should use the USB_DEVICE_HID_ReportSend function to send the report. This function returns a transfer handler that allows the application to track the read request. The request is completed when the Host has requested the data. A report send request could fail if the driver instance transfer queue is full. The completion of the write transfer is indicated by a USB_DEVICE_HID_EVENT_REPORT_SENT event. The transfer handle and the amount of data sent is returned in the reportSent member of the eventData data structure along with the event.

The following code shows an example of how a USB HID Mouse application sends a report to the host.

    /* In this code example, the application uses the
     * USB_HID_MOUSE_ReportCreate to create the mouse report
     * and then uses the USB_DEVICE_HID_ReportSend() function
     * to send the report */

    USB_HID_MOUSE_ReportCreate(appData.xCoordinate, appData.yCoordinate,
        appData.mouseButton, &appData.mouseReport);

    /* Send the mouse report. */
    USB_DEVICE_HID_ReportSend(appData.hidInstance,
        &appData.reportTransferHandle, (uint8_t*)&appData.mouseReport,
        sizeof(USB_HID_MOUSE_REPORT));