arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
USBAudioBackendTinyUSB Class Reference

USBAudioBackend implementation wrapping the real TinyUSB device stack. Injected by the ESP32, TinyUSB (RP2040/Adafruit), and TinyUSBFreeRTOS platform subclasses of USBAudioDeviceBase. More...

#include <USBAudioBackendTinyUSB.h>

Inheritance diagram for USBAudioBackendTinyUSB:
USBAudioBackend

Public Member Functions

bool claimEndpoint (uint8_t rhport, uint8_t ep_addr) override
 
bool clearStall (uint8_t rhport, uint8_t ep_addr) override
 Clear a halted/stalled condition on an endpoint.
 
bool closeEndpoint (uint8_t rhport, uint8_t ep_addr) override
 
bool controlStatus (uint8_t rhport, const UsbSetupPacket &request) override
 Send a zero-length-packet status acknowledgement.
 
bool controlTransfer (uint8_t rhport, const UsbSetupPacket &request, uint8_t *buffer, uint16_t length) override
 Complete a GET/SET control transfer's data stage with buffer.
 
void enableSof (uint8_t rhport, bool enable) override
 
bool isFullSpeed () const
 Convenience: speed() == UsbSpeed::Full.
 
bool isHighSpeed () const
 Convenience: speed() == UsbSpeed::High.
 
bool isoActivateEndpoint (uint8_t rhport, const UsbEndpointDescriptorView &ep) override
 
bool isoAllocEndpoint (uint8_t rhport, uint8_t ep_addr, uint16_t max_packet_size) override
 
bool mounted () const override
 True once the device has completed USB enumeration.
 
bool openEndpoint (uint8_t rhport, const UsbEndpointDescriptorView &ep) override
 
bool releaseEndpoint (uint8_t rhport, uint8_t ep_addr) override
 
UsbSpeed speed () const override
 Current negotiated bus speed.
 
bool transfer (uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_t length) override
 
bool usesIsoAlloc () const override
 

Static Public Member Functions

static UsbInterfaceDescriptorView fromTusbInterface (tusb_desc_interface_t const *d)
 
static UsbSetupPacket fromTusbRequest (tusb_control_request_t const *r)
 
static tusb_desc_endpoint_t toTusbDescriptor (const UsbEndpointDescriptorView &ep)
 
static tusb_control_request_t toTusbRequest (const UsbSetupPacket &p)
 

Detailed Description

USBAudioBackend implementation wrapping the real TinyUSB device stack. Injected by the ESP32, TinyUSB (RP2040/Adafruit), and TinyUSBFreeRTOS platform subclasses of USBAudioDeviceBase.

Author
Phil Schatzmann

Member Function Documentation

◆ claimEndpoint()

bool claimEndpoint ( uint8_t  rhport,
uint8_t  ep_addr 
)
inlineoverridevirtual

True if the endpoint is currently free to accept a new transfer (used to gate feedback sends from the SOF ISR).

Implements USBAudioBackend.

◆ clearStall()

bool clearStall ( uint8_t  rhport,
uint8_t  ep_addr 
)
inlineoverridevirtual

Clear a halted/stalled condition on an endpoint.

Implements USBAudioBackend.

◆ closeEndpoint()

bool closeEndpoint ( uint8_t  rhport,
uint8_t  ep_addr 
)
inlineoverridevirtual

Close a previously opened endpoint. Only called when usesIsoAlloc() is false (backends using iso-alloc keep the endpoint reserved and just re-activate it on the next alt-setting).

Implements USBAudioBackend.

◆ controlStatus()

bool controlStatus ( uint8_t  rhport,
const UsbSetupPacket request 
)
inlineoverridevirtual

Send a zero-length-packet status acknowledgement.

Implements USBAudioBackend.

◆ controlTransfer()

bool controlTransfer ( uint8_t  rhport,
const UsbSetupPacket request,
uint8_t *  buffer,
uint16_t  length 
)
inlineoverridevirtual

Complete a GET/SET control transfer's data stage with buffer.

Implements USBAudioBackend.

◆ enableSof()

void enableSof ( uint8_t  rhport,
bool  enable 
)
inlineoverridevirtual

Enable/disable the start-of-frame interrupt for the audio feedback consumer. Backends without a SOF concept (e.g. one that polls instead) may implement this as a no-op, but must then drive the feedback-interval logic themselves — not a concern for the TinyUSB backend.

Implements USBAudioBackend.

◆ fromTusbInterface()

static UsbInterfaceDescriptorView fromTusbInterface ( tusb_desc_interface_t const *  d)
inlinestatic

◆ fromTusbRequest()

static UsbSetupPacket fromTusbRequest ( tusb_control_request_t const *  r)
inlinestatic

◆ isFullSpeed()

bool isFullSpeed ( ) const
inlineinherited

Convenience: speed() == UsbSpeed::Full.

◆ isHighSpeed()

bool isHighSpeed ( ) const
inlineinherited

Convenience: speed() == UsbSpeed::High.

◆ isoActivateEndpoint()

bool isoActivateEndpoint ( uint8_t  rhport,
const UsbEndpointDescriptorView ep 
)
inlineoverridevirtual

Activate a previously iso-allocated endpoint for the given descriptor (arms it to accept traffic at the given alt setting's packet size).

Implements USBAudioBackend.

◆ isoAllocEndpoint()

bool isoAllocEndpoint ( uint8_t  rhport,
uint8_t  ep_addr,
uint16_t  max_packet_size 
)
inlineoverridevirtual

Reserve buffer space for an isochronous endpoint. Only called when usesIsoAlloc() is true. Safe to call once per endpoint lifetime.

Implements USBAudioBackend.

◆ mounted()

bool mounted ( ) const
inlineoverridevirtual

True once the device has completed USB enumeration.

Implements USBAudioBackend.

◆ openEndpoint()

bool openEndpoint ( uint8_t  rhport,
const UsbEndpointDescriptorView ep 
)
inlineoverridevirtual

Open a non-isochronous endpoint (used for the AC interrupt EP, and for data endpoints on backends where usesIsoAlloc() is false).

Implements USBAudioBackend.

◆ releaseEndpoint()

bool releaseEndpoint ( uint8_t  rhport,
uint8_t  ep_addr 
)
inlineoverridevirtual

Release the busy/claim flag on an iso endpoint without closing it (used right after a pre-activation during enumeration so a later transfer can arm normally).

Implements USBAudioBackend.

◆ speed()

UsbSpeed speed ( ) const
inlineoverridevirtual

Current negotiated bus speed.

Implements USBAudioBackend.

◆ toTusbDescriptor()

static tusb_desc_endpoint_t toTusbDescriptor ( const UsbEndpointDescriptorView ep)
inlinestatic

◆ toTusbRequest()

static tusb_control_request_t toTusbRequest ( const UsbSetupPacket p)
inlinestatic

◆ transfer()

bool transfer ( uint8_t  rhport,
uint8_t  ep_addr,
uint8_t *  buffer,
uint16_t  length 
)
inlineoverridevirtual

Arm one linear-buffer IN or OUT transfer. buffer must stay valid until the transfer-complete callback fires. Returns false if the endpoint could not be armed (already busy, not open, etc).

Implements USBAudioBackend.

◆ usesIsoAlloc()

bool usesIsoAlloc ( ) const
inlineoverridevirtual

True if this backend must pre-allocate iso endpoint buffer space once (in audiod_open) and only (re)activate it on each SET_INTERFACE, rather than open/close per alt-setting (mirrors TinyUSB's TUP_DCD_EDPT_ISO_ALLOC platform capability). Lets the UAC2 driver pick one code path at runtime instead of branching on a preprocessor macro.

Implements USBAudioBackend.


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