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.
This commit is contained in:
Daniel Thompson
2014-12-03 08:18:21 +00:00
committed by Karl Palsson
parent 0b63408260
commit d3aa579e0a
2 changed files with 14 additions and 1 deletions

View File

@@ -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;
}
}
}
}