add hid host report api
This commit is contained in:
@@ -106,6 +106,32 @@ int usbh_hid_set_protocol(struct usbh_hid *hid_class, uint8_t protocol)
|
|||||||
return usbh_control_transfer(hid_class->hport, setup, NULL);
|
return usbh_control_transfer(hid_class->hport, setup, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int usbh_hid_set_report(struct usbh_hid *hid_class, uint8_t report_type, uint8_t report_id, uint8_t *buffer, uint32_t buflen)
|
||||||
|
{
|
||||||
|
struct usb_setup_packet *setup = hid_class->hport->setup;
|
||||||
|
|
||||||
|
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_INTERFACE;
|
||||||
|
setup->bRequest = HID_REQUEST_SET_REPORT;
|
||||||
|
setup->wValue = (uint16_t)(((uint32_t)report_type << 8U) | (uint32_t)report_id);
|
||||||
|
setup->wIndex = 0;
|
||||||
|
setup->wLength = buflen;
|
||||||
|
|
||||||
|
return usbh_control_transfer(hid_class->hport, setup, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
int usbh_hid_get_report(struct usbh_hid *hid_class, uint8_t report_type, uint8_t report_id, uint8_t *buffer, uint32_t buflen)
|
||||||
|
{
|
||||||
|
struct usb_setup_packet *setup = hid_class->hport->setup;
|
||||||
|
|
||||||
|
setup->bmRequestType = USB_REQUEST_DIR_IN | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_INTERFACE;
|
||||||
|
setup->bRequest = HID_REQUEST_GET_REPORT;
|
||||||
|
setup->wValue = (uint16_t)(((uint32_t)report_type << 8U) | (uint32_t)report_id);
|
||||||
|
setup->wIndex = 0;
|
||||||
|
setup->wLength = buflen;
|
||||||
|
|
||||||
|
return usbh_control_transfer(hid_class->hport, setup, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
int usbh_hid_connect(struct usbh_hubport *hport, uint8_t intf)
|
int usbh_hid_connect(struct usbh_hubport *hport, uint8_t intf)
|
||||||
{
|
{
|
||||||
struct usb_endpoint_descriptor *ep_desc;
|
struct usb_endpoint_descriptor *ep_desc;
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ extern "C" {
|
|||||||
|
|
||||||
int usbh_hid_set_idle(struct usbh_hid *hid_class, uint8_t report_id, uint8_t duration);
|
int usbh_hid_set_idle(struct usbh_hid *hid_class, uint8_t report_id, uint8_t duration);
|
||||||
int usbh_hid_get_idle(struct usbh_hid *hid_class, uint8_t *buffer);
|
int usbh_hid_get_idle(struct usbh_hid *hid_class, uint8_t *buffer);
|
||||||
|
int usbh_hid_set_report(struct usbh_hid *hid_class, uint8_t report_type, uint8_t report_id, uint8_t *buffer, uint32_t buflen);
|
||||||
|
int usbh_hid_get_report(struct usbh_hid *hid_class, uint8_t report_type, uint8_t report_id, uint8_t *buffer, uint32_t buflen);
|
||||||
|
|
||||||
void usbh_hid_run(struct usbh_hid *hid_class);
|
void usbh_hid_run(struct usbh_hid *hid_class);
|
||||||
void usbh_hid_stop(struct usbh_hid *hid_class);
|
void usbh_hid_stop(struct usbh_hid *hid_class);
|
||||||
|
|||||||
Reference in New Issue
Block a user