Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/thirdpin/libopencm3.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libopencm3/usb/usbstd.h6
-rw-r--r--lib/usb/usb_standard.c9
2 files changed, 14 insertions, 1 deletions
diff --git a/include/libopencm3/usb/usbstd.h b/include/libopencm3/usb/usbstd.h
index f85ec82d..0b5cb213 100644
--- a/include/libopencm3/usb/usbstd.h
+++ b/include/libopencm3/usb/usbstd.h
@@ -205,8 +205,12 @@ struct usb_endpoint_descriptor {
uint8_t bmAttributes;
uint16_t wMaxPacketSize;
uint8_t bInterval;
+
+ /* Descriptor ends here. The following are used internally: */
+ const void *extra;
+ int extralen;
} __attribute__((packed));
-#define USB_DT_ENDPOINT_SIZE sizeof(struct usb_endpoint_descriptor)
+#define USB_DT_ENDPOINT_SIZE 7
/* USB Endpoint Descriptor bmAttributes bit definitions */
#define USB_ENDPOINT_ATTR_CONTROL 0x00
diff --git a/lib/usb/usb_standard.c b/lib/usb/usb_standard.c
index 42458722..bc4710ff 100644
--- a/lib/usb/usb_standard.c
+++ b/lib/usb/usb_standard.c
@@ -110,6 +110,15 @@ static uint16_t build_config_descriptor(usbd_device *usbd_dev,
len -= count;
total += count;
totallen += ep->bLength;
+ /* Copy extra bytes (class specific). */
+ if (ep->extra) {
+ memcpy(buf, ep->extra,
+ count = MIN(len, ep->extralen));
+ buf += count;
+ len -= count;
+ total += count;
+ totallen += ep->extralen;
+ }
}
}
}