USB Namespace Reference

Namespaces

 CDC
 
 DFU
 
 ECM_RNDIS
 
 HID
 
 MIDI
 
 MSC
 
 NCM
 
 VENDOR
 

Classes

struct  Descriptor
 Structure of a USB descriptor. More...
 
struct  DescriptorList
 Buffer containing list of descriptors. More...
 
struct  StringDescriptor
 Template for making a USB string descriptor. More...
 
class  DeviceInterface
 Base class to support a USB device interface implementation. More...
 
class  HostInterface
 Common base class to support Host USB access. More...
 

Typedefs

using GetDeviceDescriptor = Delegate< const tusb_desc_device_t *(const tusb_desc_device_t &desc)>
 Callback to support provision of dynamic device descriptors. More...
 
using GetDescriptorString = Delegate< const Descriptor *(uint8_t index)>
 Application-provided callback to customise string responses. More...
 

Functions

void onGetDeviceDescriptor (GetDeviceDescriptor callback)
 
void onGetDescriptorSting (GetDescriptorString callback)
 
bool begin (bool host)
 Initialise the USB stack. More...
 
void end ()
 Stop USB operation. More...
 

Typedef Documentation

◆ GetDescriptorString

using USB::GetDescriptorString = typedef Delegate<const Descriptor*(uint8_t index)>

Application-provided callback to customise string responses.

Parameters
indexString index to fetch (STRING_INDEX_xxxx)
Return values
constStringDescriptor* Pointer to persistent buffer containing descriptor. Return nullptr to use default value from string table.
Note
Returned descriptor MUST NOT be on the stack! Typically this is statically allocated.

◆ GetDeviceDescriptor

using USB::GetDeviceDescriptor = typedef Delegate<const tusb_desc_device_t*(const tusb_desc_device_t& desc)>

Callback to support provision of dynamic device descriptors.

Parameters
descThe statically configured device descriptor
consttusb_desc_device_t* Application returns a pointer to a statically allocated descriptor to use

Application typically copies the source descriptor to a statically allocated buffer, then amends values as required.

Function Documentation

◆ begin()

bool USB::begin ( bool  host)

Initialise the USB stack.

Parameters
hostPass true to initialise for host mode, false for device mode

OTG devices support operating as A (host) or B (device). This function can be called to switch between the two.

◆ end()

void USB::end ( )

Stop USB operation.

◆ onGetDescriptorSting()

void USB::onGetDescriptorSting ( GetDescriptorString  callback)

◆ onGetDeviceDescriptor()

void USB::onGetDeviceDescriptor ( GetDeviceDescriptor  callback)