nRF5 SDK v15.2.0
Modules | Data Structures | Macros | Typedefs | Enumerations | Functions

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

Enumerations

enum  app_usbd_audio_user_event_e {
  APP_USBD_AUDIO_USER_EVT_CLASS_REQ,
  APP_USBD_AUDIO_USER_EVT_RX_DONE,
  APP_USBD_AUDIO_USER_EVT_TX_DONE
}
 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_tapp_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...
 
ret_code_t app_usbd_audio_sof_interrupt_register (app_usbd_class_inst_t const *p_inst, app_usbd_sof_interrupt_handler_t handler)
 Register audio instance as the one that requires SOF events in interrupt. More...
 

Detailed Description

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

Reference specifications:

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
nameFeture 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
nameFormat 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_nameName of global instance.
interfaces_configsInterfaces configurations.
user_ev_handlerUser event handler.
format_descriptorAudio class Format descriptor.
input_descriptorAudio class Input Terminal descriptor.
output_descriptorAudio class Output Terminal descriptor.
feature_descriptorAudio class Feature Unit descriptor.
delayStreaming delay.
formatFormatTag (app_usbd_audio_as_iface_format_tag_t).
ep_sizeEndpoint size.
type_strStreaming 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
nameInput 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
nameOutput 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)
inlinestatic

Helper function to get audio from base class instance.

Parameters
[in]p_instBase 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)
inlinestatic

@brief Helper function to get class instance from Audio class.

Parameters
[in]p_audioAudio 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)
inlinestatic

Helper function to get audio specific request from audio class.

Parameters
[in]p_audioAudio 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_instBase 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_instBase class instance.
p_buffTarget buffer.
sizeSize 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_instBase class instance.
p_buffSource buffer.
sizeSize 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.
ret_code_t app_usbd_audio_sof_interrupt_register ( app_usbd_class_inst_t const *  p_inst,
app_usbd_sof_interrupt_handler_t  handler 
)

Register audio instance as the one that requires SOF events in interrupt.

This function should be called before appending the instance.

Parameters
p_instAudio instance that requires SOF event.
handlerHandler to SOF event
Return values
NRF_SUCCESSInstance linked into SOF processing list.
See Also
app_usbd_class_sof_interrupt_register

Documentation feedback | Developer Zone | Subscribe | Updated