Merge pull request #15565 from dylad/pr/usbus/add_interface_alt_helper

usbus: add usbus_add_interface_alt() helper function
This commit is contained in:
Koen Zandberg 2020-12-09 14:52:21 +01:00 committed by GitHub
commit f9c40e31bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 1 deletions

View File

@ -449,6 +449,15 @@ uint16_t usbus_add_string_descriptor(usbus_t *usbus, usbus_string_t *desc,
*/
uint16_t usbus_add_interface(usbus_t *usbus, usbus_interface_t *iface);
/**
* @brief Add alternate settings to a given interface
*
* @param[in] iface USB interface
* @param[in] alt alternate settings interface to add
*/
void usbus_add_interface_alt(usbus_interface_t *iface,
usbus_interface_alt_t *alt);
/**
* @brief Find an endpoint from an interface based on the endpoint properties
*

View File

@ -229,7 +229,7 @@ static void _init(usbus_t *usbus, usbus_handler_t *handler)
usbus_add_interface(usbus, &cdcecm->iface_ctrl);
usbus_add_interface(usbus, &cdcecm->iface_data);
cdcecm->iface_data.alts = &cdcecm->iface_data_alt;
usbus_add_interface_alt(&cdcecm->iface_data, &cdcecm->iface_data_alt);
usbus_enable_endpoint(cdcecm->ep_out);
usbus_enable_endpoint(cdcecm->ep_in);

View File

@ -121,6 +121,16 @@ uint16_t usbus_add_interface(usbus_t *usbus, usbus_interface_t *iface)
return idx;
}
void usbus_add_interface_alt(usbus_interface_t *iface,
usbus_interface_alt_t *alt)
{
usbus_interface_alt_t **last = &iface->alts;
while (*last) {
last = &(*last)->next;
}
*last = alt;
}
void usbus_register_event_handler(usbus_t *usbus, usbus_handler_t *handler)
{
/* See note above for reasons against clist.h */