|
10 | 10 |
|
11 | 11 | #include <zephyr/usb/usbh.h>
|
12 | 12 |
|
| 13 | +/** |
| 14 | + * @brief Information about a device, which is relevant for matching a particular class. |
| 15 | + */ |
| 16 | +struct usbh_class_filter { |
| 17 | + /** Vendor ID */ |
| 18 | + uint16_t vid; |
| 19 | + /** Product ID */ |
| 20 | + uint16_t pid; |
| 21 | + /** Device Class Code */ |
| 22 | + uint8_t dclass; |
| 23 | + /** Class Subclass Code */ |
| 24 | + uint8_t sub; |
| 25 | + /** Class Protocol Code */ |
| 26 | + uint8_t proto; |
| 27 | + /** Flags that tell which field to match */ |
| 28 | + uint8_t flags; |
| 29 | +}; |
| 30 | + |
13 | 31 | /**
|
14 | 32 | * @brief Auto-register all compile-time defined class drivers
|
15 | 33 | */
|
16 |
| -int usbh_register_all_classes(struct usbh_context *uhs_ctx); |
| 34 | +int usbh_register_all_classes(struct usbh_context *const uhs_ctx); |
17 | 35 |
|
18 | 36 | /**
|
19 | 37 | * @brief Initialize registered class drivers
|
20 | 38 | */
|
21 |
| -int usbh_init_registered_classes(struct usbh_context *uhs_ctx); |
| 39 | +int usbh_init_registered_classes(struct usbh_context *const uhs_ctx); |
| 40 | + |
| 41 | +/** Match a device's vendor ID */ |
| 42 | +#define USBH_CLASS_MATCH_VID BIT(1) |
| 43 | + |
| 44 | +/** Match a device's product ID */ |
| 45 | +#define USBH_CLASS_MATCH_PID BIT(2) |
| 46 | + |
| 47 | +/** Match a class code */ |
| 48 | +#define USBH_CLASS_MATCH_DCLASS BIT(3) |
| 49 | + |
| 50 | +/** Match a subclass code */ |
| 51 | +#define USBH_CLASS_MATCH_SUB BIT(4) |
| 52 | + |
| 53 | +/** Match a protocol code */ |
| 54 | +#define USBH_CLASS_MATCH_PROTO BIT(5) |
| 55 | + |
| 56 | +/** Match a code triple */ |
| 57 | +#define USBH_CLASS_MATCH_CODE_TRIPLE \ |
| 58 | + (USBH_CLASS_MATCH_DCLASS | USBH_CLASS_MATCH_SUB | USBH_CLASS_MATCH_PROTO) |
| 59 | + |
| 60 | +/** |
| 61 | + * @brief Check if information about a device matches the . |
| 62 | + * |
| 63 | + * @param filters Array of filters to match the class against. |
| 64 | + * @param n_filters Number of filters in the array. |
| 65 | + * @param desc Device descriptor with information to match against the filters. |
| 66 | + * |
| 67 | + * @return true if matched, false otherwise |
| 68 | + */ |
| 69 | +bool usbh_class_is_matching(struct usbh_class_filter *const filters, size_t n_filters, |
| 70 | + struct usb_device_descriptor *const desc); |
22 | 71 |
|
23 | 72 | #endif /* ZEPHYR_INCLUDE_USBD_CLASS_H */
|
0 commit comments