arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | List of all members
USBAudioBackend Class Referenceabstract

Abstract seam for every raw USB-stack call the UAC2 driver (USBAudioDeviceBase) needs. Concrete subclasses wrap TinyUSB (USBAudioBackendTinyUSB, today) or a native peripheral driver (STM32 HAL / Renesas USBFS — future work). More...

#include <USBAudioBackend.h>

Inheritance diagram for USBAudioBackend:
USBAudioBackendTinyUSB

Public Member Functions

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

Detailed Description

Abstract seam for every raw USB-stack call the UAC2 driver (USBAudioDeviceBase) needs. Concrete subclasses wrap TinyUSB (USBAudioBackendTinyUSB, today) or a native peripheral driver (STM32 HAL / Renesas USBFS — future work).

Only linear-buffer transfers are supported — there is no FIFO-mode transfer API.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ ~USBAudioBackend()

virtual ~USBAudioBackend ( )
virtualdefault

Member Function Documentation

◆ claimEndpoint()

virtual bool claimEndpoint ( uint8_t  rhport,
uint8_t  ep_addr 
)
pure virtual

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

Implemented in USBAudioBackendTinyUSB.

◆ clearStall()

virtual bool clearStall ( uint8_t  rhport,
uint8_t  ep_addr 
)
pure virtual

Clear a halted/stalled condition on an endpoint.

Implemented in USBAudioBackendTinyUSB.

◆ closeEndpoint()

virtual bool closeEndpoint ( uint8_t  rhport,
uint8_t  ep_addr 
)
pure virtual

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).

Implemented in USBAudioBackendTinyUSB.

◆ controlStatus()

virtual bool controlStatus ( uint8_t  rhport,
const UsbSetupPacket request 
)
pure virtual

Send a zero-length-packet status acknowledgement.

Implemented in USBAudioBackendTinyUSB.

◆ controlTransfer()

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

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

Implemented in USBAudioBackendTinyUSB.

◆ enableSof()

virtual void enableSof ( uint8_t  rhport,
bool  enable 
)
pure virtual

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.

Implemented in USBAudioBackendTinyUSB.

◆ isFullSpeed()

bool isFullSpeed ( ) const
inline

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

◆ isHighSpeed()

bool isHighSpeed ( ) const
inline

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

◆ isoActivateEndpoint()

virtual bool isoActivateEndpoint ( uint8_t  rhport,
const UsbEndpointDescriptorView ep 
)
pure virtual

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

Implemented in USBAudioBackendTinyUSB.

◆ isoAllocEndpoint()

virtual bool isoAllocEndpoint ( uint8_t  rhport,
uint8_t  ep_addr,
uint16_t  max_packet_size 
)
pure virtual

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

Implemented in USBAudioBackendTinyUSB.

◆ mounted()

virtual bool mounted ( ) const
pure virtual

True once the device has completed USB enumeration.

Implemented in USBAudioBackendTinyUSB.

◆ openEndpoint()

virtual bool openEndpoint ( uint8_t  rhport,
const UsbEndpointDescriptorView ep 
)
pure virtual

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

Implemented in USBAudioBackendTinyUSB.

◆ releaseEndpoint()

virtual bool releaseEndpoint ( uint8_t  rhport,
uint8_t  ep_addr 
)
pure virtual

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).

Implemented in USBAudioBackendTinyUSB.

◆ speed()

virtual UsbSpeed speed ( ) const
pure virtual

Current negotiated bus speed.

Implemented in USBAudioBackendTinyUSB.

◆ transfer()

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

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).

Implemented in USBAudioBackendTinyUSB.

◆ usesIsoAlloc()

virtual bool usesIsoAlloc ( ) const
pure virtual

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.

Implemented in USBAudioBackendTinyUSB.


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