1 /*
2  * Copyright (c) 2022, sakumisu
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 #ifndef USBH_HID_H
7 #define USBH_HID_H
8 
9 #include "usb_hid.h"
10 
11 struct usbh_hid {
12     struct usbh_hubport *hport;
13     struct usb_endpoint_descriptor *intin;  /* INTR IN endpoint */
14     struct usb_endpoint_descriptor *intout; /* INTR OUT endpoint */
15     struct usbh_urb intin_urb;              /* INTR IN urb */
16     struct usbh_urb intout_urb;             /* INTR OUT urb */
17 
18     uint16_t report_size;
19 
20     uint8_t protocol;
21     uint8_t intf; /* interface number */
22     uint8_t minor;
23 
24     void *user_data;
25 };
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 int usbh_hid_get_report_descriptor(struct usbh_hid *hid_class, uint8_t *buffer, uint32_t buflen);
32 int usbh_hid_set_idle(struct usbh_hid *hid_class, uint8_t report_id, uint8_t duration);
33 int usbh_hid_get_idle(struct usbh_hid *hid_class, uint8_t *buffer);
34 int usbh_hid_set_protocol(struct usbh_hid *hid_class, uint8_t protocol);
35 int usbh_hid_get_protocol(struct usbh_hid *hid_class, uint8_t *protocol);
36 int usbh_hid_set_report(struct usbh_hid *hid_class, uint8_t report_type, uint8_t report_id, uint8_t *buffer, uint32_t buflen);
37 int usbh_hid_get_report(struct usbh_hid *hid_class, uint8_t report_type, uint8_t report_id, uint8_t *buffer, uint32_t buflen);
38 
39 void usbh_hid_run(struct usbh_hid *hid_class);
40 void usbh_hid_stop(struct usbh_hid *hid_class);
41 
42 #ifdef __cplusplus
43 }
44 #endif
45 
46 #endif /* USBH_HID_H */
47