USB AUDIO class

nRF5 SDK v15.0.0

nRF52840 only: Module with types, definitions, and API used by USB Audio class. More...

Modules

USB Audio descriptors
nRF52840 only: Descriptors used in the USB Audio class.
USB Audio internals
nRF52840 only: USB Audio class internals.
USB Audio types
nRF52840 only: Type definitions for the USB Audio class.
USB AUDIO class configuration

Data Structures

struct app_usbd_audio_t
Audio class instance type. More...

Macros

#define APP_USBD_AUDIO_GLOBAL_DEF (instance_name,interfaces_configs,user_ev_handler,format_descriptor,input_descriptor,output_descriptor,feature_descriptor,delay,format,ep_size,type_str)
Global definition of app_usbd_audio_t class instance. More...
#define APP_USBD_AUDIO_FORMAT_DESCRIPTOR (name,...)
Initializer of Audio Format descriptor. More...
#define APP_USBD_AUDIO_INPUT_DESCRIPTOR (name,...)
Initializer of Audio Input descriptor. More...
#define APP_USBD_AUDIO_OUTPUT_DESCRIPTOR (name,...)
Initializer of Audio Output descriptor. More...
#define APP_USBD_AUDIO_FEATURE_DESCRIPTOR (name,...)
Initializer of Feture Output descriptor. More...

Typedefs

typedef enum
app_usbd_audio_user_event_e
app_usbd_audio_user_event_t
Events passed to user event handler. More...

Functions

static app_usbd_class_inst_t
const *
app_usbd_audio_class_inst_get ( app_usbd_audio_t const *p_audio)
static app_usbd_audio_req_t * app_usbd_audio_class_request_get ( app_usbd_audio_t const *p_audio)
Helper function to get audio specific request from audio class. More...
static app_usbd_audio_t const * app_usbd_audio_class_get ( app_usbd_class_inst_t const *p_inst)
Helper function to get audio from base class instance. More...
size_t app_usbd_audio_class_rx_size_get ( app_usbd_class_inst_t const *p_inst)
Get the size of last received transfer. More...
ret_code_t app_usbd_audio_class_rx_start ( app_usbd_class_inst_t const *p_inst, void *p_buff, size_t size)
Start audio data copying from the endpoint buffer. More...
ret_code_t app_usbd_audio_class_tx_start ( app_usbd_class_inst_t const *p_inst, const void *p_buff, size_t size)
Start copying audio data to the endpoint buffer. More...

Detailed Description

nRF52840 only: Module with types, definitions, and API used by USB Audio class.

Reference specifications:

  • "Universal Serial Bus Device Class Definition for Audio Devices" Release 1.0, March 18, 1998.
  • "Universal Serial Bus Device Class Definition for Audio Data Formats" Release 1.0, March 18, 1998.
  • "Universal Serial Bus Device Class Definition for Terminal Types" Release 1.0, March 18, 1998.

Macro Definition Documentation

#define APP_USBD_AUDIO_FEATURE_DESCRIPTOR ( name,
...
)
Value:
static uint8_t const CONCAT_2 (name, _data)[] = \
{ \
__VA_ARGS__ \
}; \
static const app_usbd_audio_subclass_desc_t name = \
{ \
sizeof( CONCAT_2 (name, _data)), \
APP_USBD_AUDIO_AC_IFACE_SUBTYPE_FEATURE_UNIT, \
CONCAT_2 (name,_data) \
}

Initializer of Feture Output descriptor.

Parameters
name Feture descriptor name
... Feture descriptor data
#define APP_USBD_AUDIO_FORMAT_DESCRIPTOR ( name,
...
)
Value:
static uint8_t const CONCAT_2 (name, _data)[] = \
{ \
__VA_ARGS__ \
}; \
static const app_usbd_audio_subclass_desc_t name = \
{ \
sizeof( CONCAT_2 (name, _data)), \
APP_USBD_AUDIO_AS_IFACE_SUBTYPE_FORMAT_TYPE, \
CONCAT_2 (name,_data) \
}

Initializer of Audio Format descriptor.

Parameters
name Format descriptor name
... Format descriptor data
#define APP_USBD_AUDIO_GLOBAL_DEF ( instance_name,
interfaces_configs,
user_ev_handler,
format_descriptor,
input_descriptor,
output_descriptor,
feature_descriptor,
delay,
format,
ep_size,
type_str
)
Value:
interfaces_configs, \
user_ev_handler, \
format_descriptor, \
input_descriptor, \
output_descriptor, \
feature_descriptor, \
delay, \
format, \
ep_size, \
type_str)

Global definition of app_usbd_audio_t class instance.

Parameters
instance_name Name of global instance
interfaces_configs Interfaces configurations
user_ev_handler User event handler
format_descriptor Audio class Format descriptor
input_descriptor Audio class Input Terminal descriptor
output_descriptor Audio class Output Terminal descriptor
feature_descriptor Audio class Feature Unit descriptor
delay Streaming delay
format FormatTag ( app_usbd_audio_as_iface_format_tag_t )
ep_size Endpoint size
type_str Streaming type MIDISTREAMING/AUDIOSTREAMING
Note
This macro is just simplified version of APP_USBD_AUDIO_GLOBAL_DEF_INTERNAL
#define APP_USBD_AUDIO_INPUT_DESCRIPTOR ( name,
...
)
Value:
static uint8_t const CONCAT_2 (name, _data)[] = \
{ \
__VA_ARGS__ \
}; \
static const app_usbd_audio_subclass_desc_t name = \
{ \
sizeof( CONCAT_2 (name, _data)), \
APP_USBD_AUDIO_AC_IFACE_SUBTYPE_INPUT_TERMINAL, \
CONCAT_2 (name,_data) \
}

Initializer of Audio Input descriptor.

Parameters
name Input descriptor name
... Input descriptor data
#define APP_USBD_AUDIO_OUTPUT_DESCRIPTOR ( name,
...
)
Value:
static uint8_t const CONCAT_2 (name, _data)[] = \
{ \
__VA_ARGS__ \
}; \
static const app_usbd_audio_subclass_desc_t name = \
{ \
sizeof( CONCAT_2 (name, _data)), \
APP_USBD_AUDIO_AC_IFACE_SUBTYPE_OUTPUT_TERNINAL, \
CONCAT_2 (name,_data) \
}

Initializer of Audio Output descriptor.

Parameters
name Output descriptor name
... Output descriptor data

Typedef Documentation

Events passed to user event handler.

Note
Example prototype of user event handler:
void audio_user_ev_handler( app_usbd_class_inst_t const * p_inst,

Enumeration Type Documentation

Events passed to user event handler.

Note
Example prototype of user event handler:
void audio_user_ev_handler( app_usbd_class_inst_t const * p_inst,
Enumerator
APP_USBD_AUDIO_USER_EVT_CLASS_REQ

User event CLASS_REQ

APP_USBD_AUDIO_USER_EVT_RX_DONE

User event RX_DONE

APP_USBD_AUDIO_USER_EVT_TX_DONE

User event TX_DONE

Function Documentation

static app_usbd_audio_t const* app_usbd_audio_class_get ( app_usbd_class_inst_t const * p_inst )
inline static

Helper function to get audio from base class instance.

Parameters
[in] p_inst Base class instance
Returns
Audio class handle
static app_usbd_class_inst_t const* app_usbd_audio_class_inst_get ( app_usbd_audio_t const * p_audio )
inline static

@brief Helper function to get class instance from Audio class

Parameters
[in] p_audio Audio class instance (declared by APP_USBD_AUDIO_GLOBAL_DEF )
Returns
Base class instance
static app_usbd_audio_req_t * app_usbd_audio_class_request_get ( app_usbd_audio_t const * p_audio )
inline static

Helper function to get audio specific request from audio class.

Parameters
[in] p_audio Audio class instance (declared by APP_USBD_AUDIO_GLOBAL_DEF )
Returns
Audio class specific request
size_t app_usbd_audio_class_rx_size_get ( app_usbd_class_inst_t const * p_inst )

Get the size of last received transfer.

Note
Call this function in reaction to a SOF event to check if there is any data to process.
Parameters
p_inst Base class instance.
Returns
Number of bytes received in the last transmission.
ret_code_t app_usbd_audio_class_rx_start ( app_usbd_class_inst_t const * p_inst ,
void * p_buff ,
size_t size
)

Start audio data copying from the endpoint buffer.

Function to be used to copy data from an audio OUT endpoint to a given buffer. When it finishes, an APP_USBD_AUDIO_USER_EVT_RX_DONE event is generated.

Parameters
p_inst Base class instance.
p_buff Target buffer.
size Size of the requested data.
Returns
Result of the endpoint transmission start.
See Also
app_usbd_audio_class_rx_size_get
Note
This function should be called in reaction to a SOF event. Isochronous endpoints are double buffered and they are automatically switched at every SOF.
ret_code_t app_usbd_audio_class_tx_start ( app_usbd_class_inst_t const * p_inst ,
const void * p_buff ,
size_t size
)

Start copying audio data to the endpoint buffer.

Function to be used to copy data to an audio IN endpoint from a given buffer. When it finishes, an APP_USBD_AUDIO_USER_EVT_TX_DONE event is generated.

Parameters
p_inst Base class instance.
p_buff Source buffer.
size Size of the data to be sent.
Returns
Result of the endpoint transsmision start.
Note
This function should be called in reaction to a SOF event. Isochronous endpoints are double buffered and they are automatically switched at every SOF.