diff options
author | Daniel Thompson <daniel@redfelineninja.org.uk> | 2014-12-03 11:18:21 +0300 |
---|---|---|
committer | Karl Palsson <karlp@tweak.net.au> | 2014-12-19 01:50:27 +0300 |
commit | d3aa579e0ae09fbcb58224b1ef83285a0e475c3e (patch) | |
tree | 6b475165f95b679453095271f618d2b158523e0a /lib/usb | |
parent | 0b63408260ad59fbfead05b94ada309d1f08e7a4 (diff) |
usb: Support for class specific endpoint descriptors.
Extends struct usb_endpoint_descriptor to make it possible to provide
the USB host with class-specific extensions to endpoint descriptors.
The approach taken, based on extra and extralen and removing the sizeof()
from USB_DT_ENDPOINT_SIZE, is identical to the approach used to add
class-specific extensions to interface descriptors. All libopencm3-examples
use the USB_DT_ENDPOINT_SIZE (rather than directly using sizeof) so there
should be no compatibility problems resulting from this change.
Diffstat (limited to 'lib/usb')
-rw-r--r-- | lib/usb/usb_standard.c | 9 |
1 files changed, 9 insertions, 0 deletions
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; + } } } } |