co_usb
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Friends | List of all members
co_usb::endpoint< Direction > Struct Template Reference

USB endpoint templated on its direction. More...

#include <endpoint.hpp>

Public Member Functions

uint8_t addr () const noexcept
 
autodev () const noexcept
 
template<ep_direction ToDirection>
requires (Direction == ep_direction::both)
std::optional< endpoint< ToDirection > > as () const noexcept
 Safe cast from an endpoint with an unknown direction to an endpoint with a concrete direction.
 

Static Public Member Functions

static endpoint< Directionmake_safe (uint8_t ep, const interface &iface) noexcept
 Makes an endpoint and completes address to proper value.
 
static endpoint< Directionmake_unsafe (uint8_t ep, libusb_device_handle *devh) noexcept
 
static endpoint< Directionmake_throwing (uint8_t ep, libusb_device_handle *devh)
 Creates an endpoint or throws if the address doesn't match expected direction.
 

Friends

template<ep_direction ToDirection>
endpoint< ToDirectionendpoint_cast (endpoint< ep_direction::both > ep) noexcept
 

Detailed Description

template<ep_direction Direction>
struct co_usb::endpoint< Direction >

USB endpoint templated on its direction.

Must be used with transfer types to provide directional information. Prefer make_safe function to construct a valid endpoint

Template Parameters
Directiondirection of an endpoint. Value co_usb::ep_direction::both is semantically equal to an unknown endpoint direction and as such only allows casts to either in or out endpoint.

Member Function Documentation

◆ addr()

template<ep_direction Direction>
uint8_t co_usb::endpoint< Direction >::addr ( ) const
inlinenoexcept

◆ as()

template<ep_direction Direction>
template<ep_direction ToDirection>
requires (Direction == ep_direction::both)
std::optional< endpoint< ToDirection > > co_usb::endpoint< Direction >::as ( ) const
inlinenoexcept

Safe cast from an endpoint with an unknown direction to an endpoint with a concrete direction.

Returns
std::nullopt when the endpoint value does not match expected direction or is equal to control endpoint (0x80)
Properly typed endpoint if conversion is possible

◆ dev()

template<ep_direction Direction>
auto * co_usb::endpoint< Direction >::dev ( ) const
inlinenoexcept

◆ make_safe()

template<ep_direction Direction>
static endpoint< Direction > co_usb::endpoint< Direction >::make_safe ( uint8_t  ep,
const interface iface 
)
inlinestaticnoexcept

Makes an endpoint and completes address to proper value.

Example:

◆ make_throwing()

template<ep_direction Direction>
static endpoint< Direction > co_usb::endpoint< Direction >::make_throwing ( uint8_t  ep,
libusb_device_handle devh 
)
inlinestatic

Creates an endpoint or throws if the address doesn't match expected direction.

Exceptions

ref std::invalid_argument when endpoint address does not match @tp Direction

◆ make_unsafe()

template<ep_direction Direction>
static endpoint< Direction > co_usb::endpoint< Direction >::make_unsafe ( uint8_t  ep,
libusb_device_handle devh 
)
inlinestaticnoexcept

Friends And Related Symbol Documentation

◆ endpoint_cast

template<ep_direction Direction>
template<ep_direction ToDirection>
endpoint< ToDirection > endpoint_cast ( endpoint< ep_direction::both ep)
friend

The documentation for this struct was generated from the following file: