|
8 | 8 |
|
9 | 9 | #include <zephyr/device.h>
|
10 | 10 | #include <zephyr/usb/usbd.h>
|
| 11 | +#include <zephyr/usb/bos.h> |
11 | 12 | #include <zephyr/sys/iterable_sections.h>
|
12 | 13 |
|
13 | 14 | #include <zephyr/logging/log.h>
|
@@ -37,6 +38,19 @@ USBD_CONFIGURATION_DEFINE(sample_hs_config,
|
37 | 38 | attributes,
|
38 | 39 | CONFIG_SAMPLE_USBD_MAX_POWER);
|
39 | 40 |
|
| 41 | +/* |
| 42 | + * This does not yet provide valuable information, but rather serves as an |
| 43 | + * example, and will be improved in the future. |
| 44 | + */ |
| 45 | +static const struct usb_bos_capability_lpm bos_cap_lpm = { |
| 46 | + .bLength = sizeof(struct usb_bos_capability_lpm), |
| 47 | + .bDescriptorType = USB_DESC_DEVICE_CAPABILITY, |
| 48 | + .bDevCapabilityType = USB_BOS_CAPABILITY_EXTENSION, |
| 49 | + .bmAttributes = 0UL, |
| 50 | +}; |
| 51 | + |
| 52 | +USBD_DESC_BOS_DEFINE(sample_usbext, sizeof(bos_cap_lpm), &bos_cap_lpm); |
| 53 | + |
40 | 54 | static int register_fs_classes(struct usbd_contex *uds_ctx)
|
41 | 55 | {
|
42 | 56 | int err = 0;
|
@@ -169,6 +183,17 @@ struct usbd_contex *sample_usbd_init_device(usbd_msg_cb_t msg_cb)
|
169 | 183 | }
|
170 | 184 | }
|
171 | 185 |
|
| 186 | + if (IS_ENABLED(CONFIG_SAMPLE_USBD_20_EXTENSION_DESC)) { |
| 187 | + (void)usbd_device_set_bcd(&sample_usbd, USBD_SPEED_FS, 0x0201); |
| 188 | + (void)usbd_device_set_bcd(&sample_usbd, USBD_SPEED_HS, 0x0201); |
| 189 | + |
| 190 | + err = usbd_add_descriptor(&sample_usbd, &sample_usbext); |
| 191 | + if (err) { |
| 192 | + LOG_ERR("Failed to add USB 2.0 Extension Descriptor"); |
| 193 | + return NULL; |
| 194 | + } |
| 195 | + } |
| 196 | + |
172 | 197 | err = usbd_init(&sample_usbd);
|
173 | 198 | if (err) {
|
174 | 199 | LOG_ERR("Failed to initialize device support");
|
|
0 commit comments