| LUFA Library 140302 |

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Enumerations | Functions
Audio 1.0 Class Host Mode Driver
Audio 1.0 Class Driver

## Data Structures
struct | USB_ClassInfo_Audio_Host_t
| Audio Class Host Mode Configuration and State Structure. More...

## Enumerations
enum | AUDIO_Host_EnumerationFailure_ErrorCodes_t { AUDIO_ENUMERROR_NoError = 0, AUDIO_ENUMERROR_InvalidConfigDescriptor = 1, AUDIO_ENUMERROR_NoCompatibleInterfaceFound = 2, AUDIO_ENUMERROR_PipeConfigurationFailed = 3 }

## Functions
uint8_t | Audio_Host_ConfigurePipes (USB_ClassInfo_Audio_Host_t *const AudioInterfaceInfo, uint16_t ConfigDescriptorSize, void *ConfigDescriptorData) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3)
uint8_t | Audio_Host_GetSetEndpointProperty (USB_ClassInfo_Audio_Host_t *const AudioInterfaceInfo, const uint8_t DataPipeIndex, const uint8_t EndpointProperty, const uint8_t EndpointControl, const uint16_t DataLength, void *const Data) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(6)
static bool | Audio_Host_IsReadyForNextSample (USB_ClassInfo_Audio_Host_t *const AudioInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE
static bool | Audio_Host_IsSampleReceived (USB_ClassInfo_Audio_Host_t *const AudioInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE
static int16_t | Audio_Host_ReadSample16 (USB_ClassInfo_Audio_Host_t *const AudioInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE
static int32_t | Audio_Host_ReadSample24 (USB_ClassInfo_Audio_Host_t *const AudioInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE
static int8_t | Audio_Host_ReadSample8 (USB_ClassInfo_Audio_Host_t *const AudioInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE
uint8_t | Audio_Host_StartStopStreaming (USB_ClassInfo_Audio_Host_t *const AudioInterfaceInfo, const bool EnableStreaming) ATTR_NON_NULL_PTR_ARG(1)
static void | Audio_Host_USBTask (USB_ClassInfo_Audio_Host_t *const AudioInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE
static void | Audio_Host_WriteSample16 (USB_ClassInfo_Audio_Host_t *const AudioInterfaceInfo, const int16_t Sample) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE
static void | Audio_Host_WriteSample24 (USB_ClassInfo_Audio_Host_t *const AudioInterfaceInfo, const int32_t Sample) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE
static void | Audio_Host_WriteSample8 (USB_ClassInfo_Audio_Host_t *const AudioInterfaceInfo, const int8_t Sample) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE

## Detailed Description

# Module Source Dependencies

The following files must be built with any user project that uses this module:

- LUFA/Drivers/USB/Class/Host/AudioClassHost.c (Makefile source module name: LUFA_SRC_USBCLASS)

# Module Description

Host Mode USB Class driver framework interface, for the Audio 1.0 USB Class driver.

## Enumeration Type Documentation

enum AUDIO_Host_EnumerationFailure_ErrorCodes_t

Enum for the possible error codes returned by the Audio_Host_ConfigurePipes() function.

Enumerator
AUDIO_ENUMERROR_NoError | Configuration Descriptor was processed successfully.
AUDIO_ENUMERROR_InvalidConfigDescriptor | The device returned an invalid Configuration Descriptor.
AUDIO_ENUMERROR_NoCompatibleInterfaceFound | A compatible AUDIO interface was not found in the device's Configuration Descriptor.
AUDIO_ENUMERROR_PipeConfigurationFailed | One or more pipes for the specified interface could not be configured correctly.

## Function Documentation

uint8_t Audio_Host_ConfigurePipes | ( | USB_ClassInfo_Audio_Host_t *const | AudioInterfaceInfo,
|  | uint16_t | ConfigDescriptorSize,
|  | void * | ConfigDescriptorData
| ) |  |

Host interface configuration routine, to configure a given Audio host interface instance using the Configuration Descriptor read from an attached USB device. This function automatically updates the given Audio Host instance's state values and configures the pipes required to communicate with the interface if it is found within the device. This should be called once after the stack has enumerated the attached device, while the host state machine is in the Addressed state.

Parameters

  [in,out] | AudioInterfaceInfo | Pointer to a structure containing an Audio Class host configuration and state.
  [in] | ConfigDescriptorSize | Length of the attached device's Configuration Descriptor.
  [in] | ConfigDescriptorData | Pointer to a buffer containing the attached device's Configuration Descriptor.

Returns
  A value from the AUDIO_Host_EnumerationFailure_ErrorCodes_t enum.

uint8_t Audio_Host_GetSetEndpointProperty | ( | USB_ClassInfo_Audio_Host_t *const | AudioInterfaceInfo,
|  | const uint8_t | DataPipeIndex,
|  | const uint8_t | EndpointProperty,
|  | const uint8_t | EndpointControl,
|  | const uint16_t | DataLength,
|  | void *const | Data
| ) |  |

Gets or sets the specified property of a streaming audio class endpoint that is bound to a pipe in the given class instance.

Parameters

  [in,out] | AudioInterfaceInfo | Pointer to a structure containing an Audio Class host configuration and state.
  [in] | DataPipeIndex | Index of the data pipe whose bound endpoint is to be altered.
  [in] | EndpointProperty | Property of the endpoint to get or set, a value from Audio_ClassRequests_t.
  [in] | EndpointControl | Parameter of the endpoint to get or set, a value from Audio_EndpointControls_t.
  [in,out] | DataLength | For SET operations, the length of the parameter data to set. For GET operations, the maximum length of the retrieved data.
  [in,out] | Data | Pointer to a location where the parameter data is stored for SET operations, or where the retrieved data is to be stored for GET operations.

Returns
  A value from the USB_Host_SendControlErrorCodes_t enum.

static bool Audio_Host_IsReadyForNextSample | ( | USB_ClassInfo_Audio_Host_t *const | AudioInterfaceInfo | ) |
| inline static

Determines if the given audio interface is ready to accept the next sample to be written to it, and selects the streaming OUT pipe ready for writing.

Precondition
  This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the call will fail.

Parameters

  [in,out] | AudioInterfaceInfo | Pointer to a structure containing an Audio Class configuration and state.

Returns
  Boolean `true` if the given Audio interface is ready to accept the next sample, `false` otherwise.

static bool Audio_Host_IsSampleReceived | ( | USB_ClassInfo_Audio_Host_t *const | AudioInterfaceInfo | ) |
| inline static

Determines if the given audio interface is ready for a sample to be read from it, and selects the streaming IN pipe ready for reading.

Precondition
  This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the call will fail.

Parameters

  [in,out] | AudioInterfaceInfo | Pointer to a structure containing an Audio Class configuration and state.

Returns
  Boolean `true` if the given Audio interface has a sample to be read, `false` otherwise.

static int16_t Audio_Host_ReadSample16 | ( | USB_ClassInfo_Audio_Host_t *const | AudioInterfaceInfo | ) |
| inline static

Reads the next 16-bit audio sample from the current audio interface.

Precondition
  This should be preceded immediately by a call to the Audio_Host_IsSampleReceived() function to ensure that the correct pipe is selected and ready for data.

Parameters

  [in,out] | AudioInterfaceInfo | Pointer to a structure containing an Audio Class configuration and state.

Returns
  Signed 16-bit audio sample from the audio interface.

static int32_t Audio_Host_ReadSample24 | ( | USB_ClassInfo_Audio_Host_t *const | AudioInterfaceInfo | ) |
| inline static

Reads the next 24-bit audio sample from the current audio interface.

Precondition
  This should be preceded immediately by a call to the Audio_Host_IsSampleReceived() function to ensure that the correct pipe is selected and ready for data.

Parameters

  [in,out] | AudioInterfaceInfo | Pointer to a structure containing an Audio Class configuration and state.

Returns
  Signed 24-bit audio sample from the audio interface.

static int8_t Audio_Host_ReadSample8 | ( | USB_ClassInfo_Audio_Host_t *const | AudioInterfaceInfo | ) |
| inline static

Reads the next 8-bit audio sample from the current audio interface.

Precondition
  This should be preceded immediately by a call to the Audio_Host_IsSampleReceived() function to ensure that the correct pipe is selected and ready for data.

Parameters

  [in,out] | AudioInterfaceInfo | Pointer to a structure containing an Audio Class configuration and state.

Returns
  Signed 8-bit audio sample from the audio interface.

uint8_t Audio_Host_StartStopStreaming | ( | USB_ClassInfo_Audio_Host_t *const | AudioInterfaceInfo,
|  | const bool | EnableStreaming
| ) |  |

Starts or stops the audio streaming for the given configured Audio Host interface, allowing for audio samples to be send and/or received.

Parameters

  [in,out] | AudioInterfaceInfo | Pointer to a structure containing an Audio Class host configuration and state.
  [in] | EnableStreaming | Boolean true to enable streaming of the specified interface, `false` to disable

Returns
  A value from the USB_Host_SendControlErrorCodes_t enum.

static void Audio_Host_USBTask | ( | USB_ClassInfo_Audio_Host_t *const | AudioInterfaceInfo | ) |
| inline static

General management task for a given Audio host class interface, required for the correct operation of the interface. This should be called frequently in the main program loop, before the master USB management task USB_USBTask().

Parameters

  [in,out] | AudioInterfaceInfo | Pointer to a structure containing an Audio Class host configuration and state.

static void Audio_Host_WriteSample16 | ( | USB_ClassInfo_Audio_Host_t *const | AudioInterfaceInfo,
|  | const int16_t | Sample
| ) |  |
| inline static

Writes the next 16-bit audio sample to the current audio interface.

Precondition
  This should be preceded immediately by a call to the Audio_Host_IsReadyForNextSample() function to ensure that the correct pipe is selected and ready for data.

Parameters

  [in,out] | AudioInterfaceInfo | Pointer to a structure containing an Audio Class configuration and state.
  [in] | Sample | Signed 16-bit audio sample.

static void Audio_Host_WriteSample24 | ( | USB_ClassInfo_Audio_Host_t *const | AudioInterfaceInfo,
|  | const int32_t | Sample
| ) |  |
| inline static

Writes the next 24-bit audio sample to the current audio interface.

Precondition
  This should be preceded immediately by a call to the Audio_Host_IsReadyForNextSample() function to ensure that the correct pipe is selected and ready for data.

Parameters

  [in,out] | AudioInterfaceInfo | Pointer to a structure containing an Audio Class configuration and state.
  [in] | Sample | Signed 24-bit audio sample.

static void Audio_Host_WriteSample8 | ( | USB_ClassInfo_Audio_Host_t *const | AudioInterfaceInfo,
|  | const int8_t | Sample
| ) |  |
| inline static

Writes the next 8-bit audio sample to the current audio interface.

Precondition
  This should be preceded immediately by a call to the Audio_Host_IsReadyForNextSample() function to ensure that the correct pipe is selected and ready for data.

Parameters

  [in,out] | AudioInterfaceInfo | Pointer to a structure containing an Audio Class configuration and state.
  [in] | Sample | Signed 8-bit audio sample.