File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -367,6 +367,24 @@ usbd_cdc_itf_t *usb_vcp_get(int idx) {
367
367
return & usb_device .usbd_cdc_itf [idx ];
368
368
}
369
369
370
+ #if MICROPY_HW_USB_HID
371
+
372
+ // return hid interface if hid is configured, NULL otherwise
373
+ usbd_hid_itf_t * usbd_hid_get (void ) {
374
+ #if defined(USE_HOST_MODE )
375
+ return NULL ;
376
+ #else
377
+ uint8_t usb_mode = USBD_GetMode (& usb_device .usbd_cdc_msc_hid_state ) & USBD_MODE_IFACE_MASK ;
378
+ if (usb_mode == USBD_MODE_HID || usb_mode == USBD_MODE_CDC_HID || usb_mode == USBD_MODE_MSC_HID ) {
379
+ return & usb_device .usbd_hid_itf ;
380
+ } else {
381
+ return NULL ;
382
+ }
383
+ #endif
384
+ }
385
+
386
+ #endif
387
+
370
388
/******************************************************************************/
371
389
// MicroPython bindings for USB
372
390
Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ typedef struct _usbd_hid_itf_t {
16
16
uint8_t report_in_buf [HID_DATA_FS_MAX_PACKET_SIZE ];
17
17
} usbd_hid_itf_t ;
18
18
19
+ usbd_hid_itf_t * usbd_hid_get (void );
20
+
19
21
static inline int usbd_hid_rx_num (usbd_hid_itf_t * hid ) {
20
22
return hid -> report_in_len != USBD_HID_REPORT_INVALID ;
21
23
}
You can’t perform that action at this time.
0 commit comments