5#include <libusb-1.0/libusb.h>
38template <ep_direction Direction>
struct endpoint
79 throw std::invalid_argument{
"Cannot use IN endpoint for OUT"};
86 throw std::invalid_argument{
"Cannot use OUT endpoint for IN"};
112 template <ep_direction ToDirection>
135 template <ep_direction ToDirection>
Definition context.hpp:14
ep_direction
Definition endpoint.hpp:22
endpoint< ep_direction::out > ep_out(uint8_t ep, const interface &iface) noexcept
Wrapper around endpoint<co_usb::ep_direction::out>::make_safe.
Definition endpoint.cpp:9
endpoint< ep_direction::both > ep_any(uint8_t ep, const interface &iface) noexcept
Creates an endpoint with an unknown direction.
Definition endpoint.cpp:15
use_service
Definition context.hpp:17
endpoint< ep_direction::in > ep_in(uint8_t ep, const interface &iface) noexcept
Wrapper around endpoint<co_usb::ep_direction::in>::make_safe.
Definition endpoint.cpp:3
endpoint_type
Definition endpoint.hpp:13
USB endpoint templated on its direction.
Definition endpoint.hpp:39
uint8_t addr() const noexcept
Definition endpoint.hpp:92
static endpoint< Direction > make_unsafe(uint8_t ep, libusb_device_handle *devh) noexcept
Definition endpoint.hpp:62
friend endpoint< ToDirection > endpoint_cast(endpoint< ep_direction::both > ep) noexcept
static endpoint< Direction > make_safe(uint8_t ep, const interface &iface) noexcept
Makes an endpoint and completes address to proper value.
Definition endpoint.hpp:48
std::optional< endpoint< ToDirection > > as() const noexcept
Safe cast from an endpoint with an unknown direction to an endpoint with a concrete direction.
Definition endpoint.hpp:113
static endpoint< Direction > make_throwing(uint8_t ep, libusb_device_handle *devh)
Creates an endpoint or throws if the address doesn't match expected direction.
Definition endpoint.hpp:72
auto * dev() const noexcept
Definition endpoint.hpp:98
RAII wrapper than claims interface on ctor and releases on dtor.
Definition interface.hpp:18