The USB_HostHidSetReport() function is working correctly. However, the implementation requires that USB_HostHidGetReport() be called after every SetReport operation to ensure proper behavior. Is there a specific reason why a GetReport call is required after each SetReport?
Below is the current implementation:
USB_HostHidSetReport(
g_HostHidKeyboard.classHandle, /* HID class instance */
HID_NO_REPORT_ID, /* Report ID = 0 */
HID_REPORT_TYPE_OUTPUT, /* Output report */
&buffer, /* 1-byte LED report */
sizeof(buffer),
NULL, /* Completion callback */
NULL
);
USB_HostHidGetReport(
g_HostHidKeyboard.classHandle,
HID_NO_REPORT_ID,
HID_REPORT_TYPE_OUTPUT, /* Report type */
&ReportGet,
1,
NULL,
NULL
);Report ID: 0x00
Report Type: 0x02
The following function demonstrates the full sequence:
static void Keyboard_SetReport(uint8_t buffer)
{
usb_status_t status;
uint8_t ReportGet;
vTaskDelay(50 / portTICK_PERIOD_MS);
usb_echo("Keyboard_SetReport - %d\r\n", buffer);
status = USB_HostHidSetReport(
g_HostHidKeyboard.classHandle, /* HID class instance */
HID_NO_REPORT_ID, /* Report ID = 0 */
HID_REPORT_TYPE_OUTPUT, /* Output report */
&buffer, /* 1-byte LED report */
sizeof(buffer),
NULL, /* Completion callback */
NULL
);
vTaskDelay(10 / portTICK_PERIOD_MS);
status = USB_HostHidGetReport(
g_HostHidKeyboard.classHandle,
HID_NO_REPORT_ID,
HID_REPORT_TYPE_OUTPUT,
&ReportGet,
1,
NULL,
NULL
);
if (status != kStatus_USB_Success)
{
usb_echo("Error in USB_HostHidSetReport call - %d\r\n", status);
/* Handle error */
}
}