usbus: add find_endpoint function for interfaces
This commit is contained in:
parent
0bbb114ec6
commit
b32ec6b864
@ -427,6 +427,24 @@ 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);
|
uint16_t usbus_add_interface(usbus_t *usbus, usbus_interface_t *iface);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Find an endpoint from an interface based on the endpoint properties
|
||||||
|
*
|
||||||
|
* This iterates over the endpoints in an interface and will return the first
|
||||||
|
* endpoint from the interface matching the @p type and @p dir. It will return
|
||||||
|
* NULL when no matching endpoint is found.
|
||||||
|
*
|
||||||
|
* @param[in] interface interface to look in
|
||||||
|
* @param[in] type endpoint type to match
|
||||||
|
* @param[in] dir endpoint direction to match
|
||||||
|
*
|
||||||
|
* @return ptr to the first matching endpoint
|
||||||
|
* @return NULL when no endpoint is found
|
||||||
|
*/
|
||||||
|
usbus_endpoint_t *usbus_interface_find_endpoint(usbus_interface_t *interface,
|
||||||
|
usb_ep_type_t type,
|
||||||
|
usb_ep_dir_t dir);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Add an endpoint to the specified interface
|
* @brief Add an endpoint to the specified interface
|
||||||
*
|
*
|
||||||
|
|||||||
@ -127,6 +127,18 @@ void usbus_register_event_handler(usbus_t *usbus, usbus_handler_t *handler)
|
|||||||
*last = handler;
|
*last = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
usbus_endpoint_t *usbus_interface_find_endpoint(usbus_interface_t *interface,
|
||||||
|
usb_ep_type_t type,
|
||||||
|
usb_ep_dir_t dir)
|
||||||
|
{
|
||||||
|
for (usbus_endpoint_t *uep = interface->ep; uep; uep = uep->next) {
|
||||||
|
if (uep->ep->type == type && uep->ep->dir == dir) {
|
||||||
|
return uep;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
usbus_endpoint_t *usbus_add_endpoint(usbus_t *usbus, usbus_interface_t *iface,
|
usbus_endpoint_t *usbus_add_endpoint(usbus_t *usbus, usbus_interface_t *iface,
|
||||||
usb_ep_type_t type, usb_ep_dir_t dir,
|
usb_ep_type_t type, usb_ep_dir_t dir,
|
||||||
size_t len)
|
size_t len)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user