Merge pull request #12504 from bergzand/pr/usbus/descr_terminology

usbus: Unify terminology to use 'descriptor' everywhere
This commit is contained in:
benpicco 2019-11-12 11:41:10 +01:00 committed by GitHub
commit 341d23dded
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 109 additions and 125 deletions

View File

@ -75,7 +75,7 @@ extern "C" {
/**
* @name USB CDC descriptor subtypes
*/
#define USB_CDC_DESCR_SUBTYPE_FUNCTIONAL 0x00 /**< Header functional
#define USB_CDC_DESCR_SUBTYPE_FUNCTIONAL 0x00 /**< functional
* descriptor */
#define USB_CDC_DESCR_SUBTYPE_CALL_MGMT 0x01 /**< Call management
descriptor */

View File

@ -120,7 +120,7 @@ typedef enum {
* @brief USB endpoint transfer status events
*/
typedef enum {
USBUS_EVENT_TRANSFER_COMPLETE, /**< Transfer succesfully completed */
USBUS_EVENT_TRANSFER_COMPLETE, /**< Transfer successfully completed */
USBUS_EVENT_TRANSFER_FAIL, /**< Transfer nack replied by peripheral */
USBUS_EVENT_TRANSFER_STALL, /**< Transfer stall replied by peripheral */
} usbus_event_transfer_t;
@ -170,15 +170,15 @@ typedef struct usbus usbus_t;
typedef struct usbus_handler usbus_handler_t;
/**
* @brief Header length types for USB descriptor generators
* @brief descriptor length types for USB descriptor generators
*/
typedef enum {
USBUS_HDR_LEN_FIXED, /**< Header always generates a fixed length */
USBUS_HDR_LEN_FUNC, /**< Header length is calculated by a function */
} usbus_hdr_len_type_t;
USBUS_DESCR_LEN_FIXED, /**< Descriptor always generates a fixed length */
USBUS_DESCR_LEN_FUNC, /**< Descriptor length is calculated by a function */
} usbus_descr_len_type_t;
/**
* @brief USBUS header generator function pointers
* @brief USBUS descriptor generator function pointers
*/
typedef struct {
/**
@ -187,7 +187,7 @@ typedef struct {
* the descriptor of the object it is part of.
*
* @param usbus The usbus context
* @param arg Additional argument for the header generator
* @param arg Additional argument for the descriptor generator
*
* @return Length of the generated descriptor
*/
@ -199,53 +199,54 @@ typedef struct {
* the descriptor of the object it is part of.
*
* @param usbus The usbus context
* @param arg Additional argument for the header generator
* @param arg Additional argument for the descriptor generator
*
* @return Length of the generated header
* @return Length of the generated descriptor
*/
size_t (*get_header)(usbus_t *usbus, void *arg);
size_t (*fmt_post_descriptor)(usbus_t *usbus, void *arg);
union {
/**
* @brief USBUS generic header generator generated length
* @brief USBUS generic descriptor generator generated length
*
* Must return the total length of the descriptors that will be
* generated by @ref fmt_pre_descriptor and @ref get_header
* generated by @ref fmt_pre_descriptor and @ref fmt_post_descriptor
* This function is used when @ref len_type is set to
* @ref USBUS_HDR_LEN_FUNC.
* @ref USBUS_DESCR_LEN_FUNC.
*
* @param usbus The usbus context
* @param arg Additional argument for the header generator
* @param arg Additional argument for the descriptor generators
*
* @return Length of the generated header
* @return Length of the generated descriptors
*/
size_t (*get_header_len)(usbus_t *usbus, void *arg);
size_t (*get_descriptor_len)(usbus_t *usbus, void *arg);
/**
* @brief Fixed total length of the generated descriptors
*
* Must return the total length of the descriptors that will be
* generated by the @ref fmt_pre_descriptor and @ref get_header.
* This value is used when @ref len_type is set to @ref USBUS_HDR_LEN_FIXED.
* generated by the @ref fmt_pre_descriptor and @ref fmt_post_descriptor.
* This value is used when @ref len_type is set to
* @ref USBUS_DESCR_LEN_FIXED.
*/
size_t fixed_len;
} len; /**< Fixed or generated length of the header */
usbus_hdr_len_type_t len_type; /**< Either USBUS_HDR_LEN_FIXED or USBUS_HDR_LEN_FUNC */
} usbus_hdr_gen_funcs_t;
} len; /**< Fixed or generated length of the descriptor */
usbus_descr_len_type_t len_type; /**< Either USBUS_DESCR_LEN_FIXED or USBUS_DESCR_LEN_FUNC */
} usbus_descr_gen_funcs_t;
/**
* @brief USBUS header generator
* @brief USBUS descriptor generator
*
* The functions are called to allow custom modules to define their own
* headers in addition to the USB descriptor. The top level (@ref usbus_t), the
* descriptors in addition to the USB descriptor. The top level (@ref usbus_t), the
* interface (@ref usbus_interface_t), interface alternative settings
* (@ref usbus_interface_alt_t) and endpoints (@ref usbus_endpoint_t) allow for
* generating additional headers
* generating additional descriptors
*/
typedef struct usbus_hdr_gen {
struct usbus_hdr_gen *next; /**< ptr to the next header generator */
const usbus_hdr_gen_funcs_t *funcs; /**< Function pointers */
void *arg; /**< Extra context argument for the
headers functions */
} usbus_hdr_gen_t;
typedef struct usbus_descr_gen {
struct usbus_descr_gen *next; /**< ptr to the next descriptor generator */
const usbus_descr_gen_funcs_t *funcs; /**< Function pointers */
void *arg; /**< Extra context argument for the
descriptor functions */
} usbus_descr_gen_t;
/**
* @brief USBUS endpoint context
@ -254,7 +255,8 @@ typedef struct usbus_endpoint {
struct usbus_endpoint *next; /**< Next endpoint in the
@ref usbus_interface_t list of
endpoints */
usbus_hdr_gen_t *hdr_gen; /**< Optional additional header generator */
usbus_descr_gen_t *descr_gen; /**< Linked list of optional additional
descriptor generators */
usbdev_ep_t *ep; /**< ptr to the matching usbdev endpoint */
uint16_t maxpacketsize; /**< Max packet size of this endpoint */
uint8_t interval; /**< Poll interval for interrupt endpoints */
@ -269,8 +271,8 @@ typedef struct usbus_endpoint {
*/
typedef struct usbus_interface_alt {
struct usbus_interface_alt *next; /**< Next alternative setting */
usbus_hdr_gen_t *hdr_gen; /**< Optional additional header
generator */
usbus_descr_gen_t *descr_gen; /**< Linked list of optional additional
descriptor generators */
usbus_endpoint_t *ep; /**< List of associated endpoints for
this alternative setting */
} usbus_interface_alt_t;
@ -281,8 +283,8 @@ typedef struct usbus_interface_alt {
typedef struct usbus_interface {
struct usbus_interface *next; /**< Next interface (set by USBUS during
registration) */
usbus_hdr_gen_t *hdr_gen; /**< Optional additional header
generators */
usbus_descr_gen_t *descr_gen; /**< Linked list of optional additional
descriptor generators */
usbus_endpoint_t *ep; /**< Linked list of endpoints belonging
to this interface */
struct usbus_interface_alt *alts; /**< List of alt settings */
@ -382,7 +384,8 @@ struct usbus {
event_queue_t queue; /**< Event queue */
usbdev_t *dev; /**< usb phy device of the usb manager */
usbus_handler_t *control; /**< Ptr to the control endpoint handler */
usbus_hdr_gen_t *hdr_gen; /**< Top level header generators */
usbus_descr_gen_t *descr_gen; /**< Linked list of top level descriptor
generators */
usbus_string_t *strings; /**< List of descriptor strings */
usbus_interface_t *iface; /**< List of USB interfaces */
usbus_handler_t *handlers; /**< List of event callback handlers */
@ -468,10 +471,10 @@ usbus_endpoint_t *usbus_add_endpoint(usbus_t *usbus, usbus_interface_t *iface,
* @brief Add a generator for generating additional top level USB descriptor
* content
*
* @param[in] usbus USBUS context
* @param[in] hdr_gen Header generator to add
* @param[in] usbus USBUS context
* @param[in] descr_gen descriptor generator to add
*/
void usbus_add_conf_descriptor(usbus_t *usbus, usbus_hdr_gen_t *hdr_gen);
void usbus_add_conf_descriptor(usbus_t *usbus, usbus_descr_gen_t *descr_gen);
/**
* @brief Add an event handler to the USBUS context

View File

@ -114,7 +114,7 @@ struct usbus_cdcacm_device {
usbus_handler_t handler_ctrl; /**< control handler */
usbus_interface_t iface_ctrl; /**< CDC control interface */
usbus_interface_t iface_data; /**< CDC data interface */
usbus_hdr_gen_t cdcacm_hdr; /**< CDC header generator */
usbus_descr_gen_t cdcacm_descr; /**< CDC descriptor generator */
usbus_cdcacm_cb_t cb; /**< Callback for data handlers */
usbus_cdcacm_coding_cb_t coding_cb; /**< Callback for ACM coding changes */
tsrb_t tsrb; /**< TSRB for data to the host */

View File

@ -98,7 +98,7 @@ typedef struct usbus_cdcecm_device {
usbus_endpoint_t *ep_in; /**< Data endpoint in */
usbus_endpoint_t *ep_out; /**< Data endpoint out */
usbus_endpoint_t *ep_ctrl; /**< Control endpoint */
usbus_hdr_gen_t ecm_hdr; /**< ECM header generator */
usbus_descr_gen_t ecm_descr; /**< ECM descriptor generator */
event_t rx_flush; /**< Receive flush event */
event_t tx_xmit; /**< Transmit ready event */
netdev_t netdev; /**< Netdev context struct */

View File

@ -36,7 +36,7 @@ extern "C" {
*
* @return the generated descriptor size in bytes
*/
size_t usbus_fmt_hdr_conf(usbus_t *usbus);
size_t usbus_fmt_descriptor_conf(usbus_t *usbus);
/**
* @brief generator for the USB device descriptor
@ -45,7 +45,7 @@ size_t usbus_fmt_hdr_conf(usbus_t *usbus);
*
* @return the generated descriptor size in bytes
*/
size_t usbus_fmt_hdr_dev(usbus_t *usbus);
size_t usbus_fmt_descriptor_dev(usbus_t *usbus);
#ifdef __cplusplus
}

View File

@ -50,9 +50,9 @@ static size_t _gen_full_acm_descriptor(usbus_t *usbus, void *arg);
static size_t _gen_assoc_descriptor(usbus_t *usbus, void *arg);
/* Descriptors */
static const usbus_hdr_gen_funcs_t _cdcacm_descriptor = {
static const usbus_descr_gen_funcs_t _cdcacm_descriptor = {
.fmt_post_descriptor = _gen_full_acm_descriptor,
.fmt_pre_descriptor = _gen_assoc_descriptor,
.get_header = _gen_full_acm_descriptor,
.len = {
.fixed_len = sizeof(usb_descriptor_interface_association_t) +
sizeof(usb_desc_cdc_t) +
@ -60,7 +60,7 @@ static const usbus_hdr_gen_funcs_t _cdcacm_descriptor = {
sizeof(usb_desc_union_t) +
sizeof(usb_desc_call_mngt_t),
},
.len_type = USBUS_HDR_LEN_FIXED,
.len_type = USBUS_DESCR_LEN_FIXED,
};
static size_t _gen_assoc_descriptor(usbus_t *usbus, void *arg)
@ -185,21 +185,21 @@ static void _init(usbus_t *usbus, usbus_handler_t *handler)
cdcacm->flush.handler = _handle_flush;
cdcacm->cdcacm_hdr.next = NULL;
cdcacm->cdcacm_hdr.funcs = &_cdcacm_descriptor;
cdcacm->cdcacm_hdr.arg = cdcacm;
cdcacm->cdcacm_descr.next = NULL;
cdcacm->cdcacm_descr.funcs = &_cdcacm_descriptor;
cdcacm->cdcacm_descr.arg = cdcacm;
/* Configure Interface 0 as control interface */
cdcacm->iface_ctrl.class = USB_CLASS_CDC_CONTROL ;
cdcacm->iface_ctrl.subclass = USB_CDC_SUBCLASS_ACM;
cdcacm->iface_ctrl.protocol = USB_CDC_PROTOCOL_NONE;
cdcacm->iface_ctrl.hdr_gen = &cdcacm->cdcacm_hdr;
cdcacm->iface_ctrl.descr_gen = &cdcacm->cdcacm_descr;
cdcacm->iface_ctrl.handler = handler;
/* Configure second interface to handle data endpoint */
cdcacm->iface_data.class = USB_CLASS_CDC_DATA ;
cdcacm->iface_data.subclass = USB_CDC_SUBCLASS_NONE;
cdcacm->iface_data.protocol = USB_CDC_PROTOCOL_NONE;
cdcacm->iface_data.hdr_gen = NULL;
cdcacm->iface_data.descr_gen = NULL;
cdcacm->iface_data.handler = handler;
/* Create required endpoints */

View File

@ -45,14 +45,14 @@ static void _handle_tx_xmit(event_t *ev);
static size_t _gen_full_ecm_descriptor(usbus_t *usbus, void *arg);
static const usbus_hdr_gen_funcs_t _ecm_descriptor = {
.get_header = _gen_full_ecm_descriptor,
static const usbus_descr_gen_funcs_t _ecm_descriptor = {
.fmt_post_descriptor = _gen_full_ecm_descriptor,
.len = {
.fixed_len = sizeof(usb_desc_cdc_t) +
sizeof(usb_desc_union_t) +
sizeof(usb_desc_ecm_t),
},
.len_type = USBUS_HDR_LEN_FIXED,
.len_type = USBUS_DESCR_LEN_FIXED,
};
static size_t _gen_union_descriptor(usbus_t *usbus, usbus_cdcecm_device_t *cdcecm)
@ -183,23 +183,23 @@ static void _init(usbus_t *usbus, usbus_handler_t *handler)
cdcecm->tx_xmit.handler = _handle_tx_xmit;
cdcecm->rx_flush.handler = _handle_rx_flush_ev;
/* Set up header generators */
cdcecm->ecm_hdr.next = NULL;
cdcecm->ecm_hdr.funcs = &_ecm_descriptor;
cdcecm->ecm_hdr.arg = cdcecm;
/* Set up descriptor generators */
cdcecm->ecm_descr.next = NULL;
cdcecm->ecm_descr.funcs = &_ecm_descriptor;
cdcecm->ecm_descr.arg = cdcecm;
/* Configure Interface 0 as control interface */
cdcecm->iface_ctrl.class = USB_CLASS_CDC_CONTROL;
cdcecm->iface_ctrl.subclass = USB_CDC_SUBCLASS_ENCM;
cdcecm->iface_ctrl.protocol = USB_CDC_PROTOCOL_NONE;
cdcecm->iface_ctrl.hdr_gen = &cdcecm->ecm_hdr;
cdcecm->iface_ctrl.descr_gen = &cdcecm->ecm_descr;
cdcecm->iface_ctrl.handler = handler;
/* Configure second interface to handle data endpoint */
cdcecm->iface_data.class = USB_CLASS_CDC_DATA;
cdcecm->iface_data.subclass = USB_CDC_SUBCLASS_NONE;
cdcecm->iface_data.protocol = USB_CDC_PROTOCOL_NONE;
cdcecm->iface_data.hdr_gen = NULL;
cdcecm->iface_data.descr_gen = NULL;
cdcecm->iface_data.handler = handler;
/* Add string descriptor for the host mac */

View File

@ -73,10 +73,10 @@ uint16_t usbus_add_string_descriptor(usbus_t *usbus, usbus_string_t *desc,
return desc->idx;
}
void usbus_add_conf_descriptor(usbus_t *usbus, usbus_hdr_gen_t *hdr_gen)
void usbus_add_conf_descriptor(usbus_t *usbus, usbus_descr_gen_t *descr_gen)
{
hdr_gen->next = usbus->hdr_gen;
usbus->hdr_gen = hdr_gen;
descr_gen->next = usbus->descr_gen;
usbus->descr_gen = descr_gen;
}
static usbus_handler_t *_ep_to_handler(usbus_t *usbus, usbdev_ep_t *ep)

View File

@ -146,12 +146,12 @@ static int _req_str(usbus_t *usbus, uint16_t idx)
static int _req_dev(usbus_t *usbus)
{
return usbus_fmt_hdr_dev(usbus);
return usbus_fmt_descriptor_dev(usbus);
}
static int _req_config(usbus_t *usbus)
{
return usbus_fmt_hdr_conf(usbus);
return usbus_fmt_descriptor_conf(usbus);
}
static int _req_dev_qualifier(usbus_t *usbus)

View File

@ -74,19 +74,14 @@ static size_t _num_endpoints_alt(usbus_interface_alt_t *alt)
return num;
}
static inline size_t call_get_header_len(usbus_t *usbus, usbus_hdr_gen_t *hdr)
{
return hdr->funcs->len_type == USBUS_HDR_LEN_FIXED ?
hdr->funcs->len.fixed_len :
hdr->funcs->len.get_header_len(usbus, hdr->arg);
}
static size_t _hdr_gen_size(usbus_t *usbus, usbus_hdr_gen_t *hdr)
static size_t _gen_descriptor_size(usbus_t *usbus, usbus_descr_gen_t *descr)
{
size_t len = 0;
for (; hdr; hdr = hdr->next) {
len += call_get_header_len(usbus, hdr);
for (; descr; descr = descr->next) {
len += (descr->funcs->len_type == USBUS_DESCR_LEN_FIXED)
? descr->funcs->len.fixed_len
: descr->funcs->len.get_descriptor_len(usbus, descr->arg);
}
return len;
}
@ -97,7 +92,7 @@ static size_t _ep_size(usbus_t *usbus, usbus_endpoint_t *ep)
for (; ep; ep = ep->next) {
len += sizeof(usb_descriptor_endpoint_t);
len += _hdr_gen_size(usbus, ep->hdr_gen);
len += _gen_descriptor_size(usbus, ep->descr_gen);
}
return len;
}
@ -108,73 +103,58 @@ static size_t _alt_size(usbus_t *usbus, usbus_interface_alt_t *alt)
for (; alt; alt = alt->next) {
len += sizeof(usb_descriptor_interface_t);
len += _hdr_gen_size(usbus, alt->hdr_gen);
len += _gen_descriptor_size(usbus, alt->descr_gen);
len += _ep_size(usbus, alt->ep);
}
return len;
}
static size_t _hdrs_config_size(usbus_t *usbus)
static size_t _gen_config_descriptor_size(usbus_t *usbus)
{
size_t len = sizeof(usb_descriptor_configuration_t);
len += _hdr_gen_size(usbus, usbus->hdr_gen);
len += _gen_descriptor_size(usbus, usbus->descr_gen);
for (usbus_interface_t *iface = usbus->iface;
iface;
iface = iface->next) {
len += sizeof(usb_descriptor_interface_t);
len += _hdr_gen_size(usbus, iface->hdr_gen);
len += _gen_descriptor_size(usbus, iface->descr_gen);
len += _ep_size(usbus, iface->ep);
len += _alt_size(usbus, iface->alts);
}
return len;
}
static inline size_t _get_pre_header(usbus_t *usbus, usbus_hdr_gen_t *hdr)
{
return (hdr->funcs->fmt_pre_descriptor != NULL)
? hdr->funcs->fmt_pre_descriptor(usbus, hdr->arg)
: 0;
}
static inline size_t _get_additional_header(usbus_t *usbus, usbus_hdr_gen_t *hdr)
{
return (hdr->funcs->get_header != NULL)
? hdr->funcs->get_header(usbus, hdr->arg)
: 0;
}
static size_t _hdrs_fmt_pre(usbus_t *usbus, usbus_hdr_gen_t *hdr)
static size_t _fmt_descriptors_pre(usbus_t *usbus, usbus_descr_gen_t *descr)
{
size_t len = 0;
for (; hdr; hdr = hdr->next) {
len += _get_pre_header(usbus, hdr);
for (; descr; descr = descr->next) {
len += (descr->funcs->fmt_pre_descriptor != NULL)
? descr->funcs->fmt_pre_descriptor(usbus, descr->arg)
: 0;
}
return len;
}
static size_t _hdrs_fmt_additional(usbus_t *usbus, usbus_hdr_gen_t *hdr)
static size_t _fmt_descriptors_post(usbus_t *usbus, usbus_descr_gen_t *descr)
{
size_t len = 0;
for (; hdr; hdr = hdr->next) {
len += _get_additional_header(usbus, hdr);
for (; descr; descr = descr->next) {
len += (descr->funcs->fmt_post_descriptor!= NULL)
? descr->funcs->fmt_post_descriptor(usbus, descr->arg)
: 0;
}
return len;
}
static size_t _hdrs_fmt_hdrs(usbus_t *usbus)
{
return _hdrs_fmt_additional(usbus, usbus->hdr_gen);
}
static size_t _hdrs_fmt_endpoints(usbus_t *usbus, usbus_endpoint_t *ep)
static size_t _fmt_descriptors_endpoints(usbus_t *usbus, usbus_endpoint_t *ep)
{
size_t len = 0;
while (ep) {
_hdrs_fmt_pre(usbus, ep->hdr_gen);
_fmt_descriptors_pre(usbus, ep->descr_gen);
usb_descriptor_endpoint_t usb_ep;
memset(&usb_ep, 0, sizeof(usb_descriptor_endpoint_t));
usb_ep.length = sizeof(usb_descriptor_endpoint_t);
@ -188,7 +168,7 @@ static size_t _hdrs_fmt_endpoints(usbus_t *usbus, usbus_endpoint_t *ep)
usb_ep.interval = ep->interval;
usbus_control_slicer_put_bytes(usbus, (uint8_t *)&usb_ep,
sizeof(usb_descriptor_endpoint_t));
_hdrs_fmt_additional(usbus, ep->hdr_gen);
_fmt_descriptors_post(usbus, ep->descr_gen);
len += usb_ep.length;
/* iterate to next endpoint */
ep = ep->next;
@ -196,7 +176,7 @@ static size_t _hdrs_fmt_endpoints(usbus_t *usbus, usbus_endpoint_t *ep)
return len;
}
static void _hdrs_fmt_iface(usbus_interface_t *iface,
static void _fmt_descriptor_iface(usbus_interface_t *iface,
usb_descriptor_interface_t *usb_iface)
{
memset(usb_iface, 0, sizeof(usb_descriptor_interface_t));
@ -208,7 +188,8 @@ static void _hdrs_fmt_iface(usbus_interface_t *iface,
usb_iface->protocol = iface->protocol;
}
static size_t _hdrs_fmt_iface_alts(usbus_t *usbus, usbus_interface_t *iface)
static size_t _fmt_descriptors_iface_alts(usbus_t *usbus,
usbus_interface_t *iface)
{
size_t len = 0;
uint8_t alts = 1;
@ -217,27 +198,27 @@ static size_t _hdrs_fmt_iface_alts(usbus_t *usbus, usbus_interface_t *iface)
alt;
alt = alt->next) {
usb_descriptor_interface_t usb_iface;
_hdrs_fmt_iface(iface, &usb_iface);
_fmt_descriptor_iface(iface, &usb_iface);
usb_iface.alternate_setting = alts++;
usb_iface.num_endpoints = _num_endpoints_alt(alt);
usbus_control_slicer_put_bytes(usbus, (uint8_t *)&usb_iface,
sizeof(usb_descriptor_interface_t));
len += _hdrs_fmt_additional(usbus, alt->hdr_gen);
len += _hdrs_fmt_endpoints(usbus, alt->ep);
len += _fmt_descriptors_post(usbus, alt->descr_gen);
len += _fmt_descriptors_endpoints(usbus, alt->ep);
}
return len;
}
static size_t _hdrs_fmt_ifaces(usbus_t *usbus)
static size_t _fmt_descriptors_ifaces(usbus_t *usbus)
{
size_t len = 0;
for (usbus_interface_t *iface = usbus->iface;
iface;
iface = iface->next) {
len += _hdrs_fmt_pre(usbus, iface->hdr_gen);
len += _fmt_descriptors_pre(usbus, iface->descr_gen);
usb_descriptor_interface_t usb_iface;
_hdrs_fmt_iface(iface, &usb_iface);
_fmt_descriptor_iface(iface, &usb_iface);
usb_iface.num_endpoints = _num_endpoints(iface);
if (iface->descr) {
usb_iface.idx = iface->descr->idx;
@ -248,14 +229,14 @@ static size_t _hdrs_fmt_ifaces(usbus_t *usbus)
usbus_control_slicer_put_bytes(usbus, (uint8_t *)&usb_iface,
sizeof(usb_descriptor_interface_t));
len += sizeof(usb_descriptor_interface_t);
len += _hdrs_fmt_additional(usbus, iface->hdr_gen);
len += _hdrs_fmt_endpoints(usbus, iface->ep);
len += _hdrs_fmt_iface_alts(usbus, iface);
len += _fmt_descriptors_post(usbus, iface->descr_gen);
len += _fmt_descriptors_endpoints(usbus, iface->ep);
len += _fmt_descriptors_iface_alts(usbus, iface);
}
return len;
}
size_t usbus_fmt_hdr_conf(usbus_t *usbus)
size_t usbus_fmt_descriptor_conf(usbus_t *usbus)
{
size_t len = 0;
usb_descriptor_configuration_t conf;
@ -274,15 +255,15 @@ size_t usbus_fmt_hdr_conf(usbus_t *usbus)
conf.max_power = USB_CONFIG_MAX_POWER / 2;
conf.num_interfaces = _num_ifaces(usbus);
len += sizeof(usb_descriptor_configuration_t);
conf.total_length = _hdrs_config_size(usbus);
conf.total_length = _gen_config_descriptor_size(usbus);
conf.idx = usbus->config.idx;
usbus_control_slicer_put_bytes(usbus, (uint8_t *)&conf, sizeof(conf));
len += _hdrs_fmt_hdrs(usbus);
len += _hdrs_fmt_ifaces(usbus);
len += _fmt_descriptors_post(usbus, usbus->descr_gen);
len += _fmt_descriptors_ifaces(usbus);
return len;
}
size_t usbus_fmt_hdr_dev(usbus_t *usbus)
size_t usbus_fmt_descriptor_dev(usbus_t *usbus)
{
usb_descriptor_device_t desc;