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:
parent
0b63408260
commit
d3aa579e0a
|
@ -205,8 +205,12 @@ struct usb_endpoint_descriptor {
|
||||||
uint8_t bmAttributes;
|
uint8_t bmAttributes;
|
||||||
uint16_t wMaxPacketSize;
|
uint16_t wMaxPacketSize;
|
||||||
uint8_t bInterval;
|
uint8_t bInterval;
|
||||||
|
|
||||||
|
/* Descriptor ends here. The following are used internally: */
|
||||||
|
const void *extra;
|
||||||
|
int extralen;
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
#define USB_DT_ENDPOINT_SIZE sizeof(struct usb_endpoint_descriptor)
|
#define USB_DT_ENDPOINT_SIZE 7
|
||||||
|
|
||||||
/* USB Endpoint Descriptor bmAttributes bit definitions */
|
/* USB Endpoint Descriptor bmAttributes bit definitions */
|
||||||
#define USB_ENDPOINT_ATTR_CONTROL 0x00
|
#define USB_ENDPOINT_ATTR_CONTROL 0x00
|
||||||
|
|
|
@ -110,6 +110,15 @@ static uint16_t build_config_descriptor(usbd_device *usbd_dev,
|
||||||
len -= count;
|
len -= count;
|
||||||
total += count;
|
total += count;
|
||||||
totallen += ep->bLength;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue