| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

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

## Detailed Description

# Module Source Dependencies

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

- LPCUSBlib/Drivers/USB/Class/Host/Audio.c (Makefile source module name: LPCUSBlib_SRC_USBCLASS)

# Module Description

Host Mode USB Class driver framework interface, for the Audio 1.0 USB 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 *DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3)
| 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.
uint8_t | Audio_Host_StartStopStreaming (USB_ClassInfo_Audio_Host_t *const AudioInterfaceInfo, const bool EnableStreaming) ATTR_NON_NULL_PTR_ARG(1)
| Starts or stops the audio streaming for the given configured Audio Host interface, allowing for audio samples to be send and/or received.
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)
| Gets or sets the specified property of a streaming audio class endpoint that is bound to a pipe in the given class instance.
static void | Audio_Host_USBTask (USB_ClassInfo_Audio_Host_t *const AudioInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE
| 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().
static bool | Audio_Host_IsSampleReceived (USB_ClassInfo_Audio_Host_t *const AudioInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE
| 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.
static bool | Audio_Host_IsReadyForNextSample (USB_ClassInfo_Audio_Host_t *const AudioInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE
| 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.
static int8_t | Audio_Host_ReadSample8 (USB_ClassInfo_Audio_Host_t *const AudioInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE
| Reads the next 8-bit audio sample from the current audio interface.
static int16_t | Audio_Host_ReadSample16 (USB_ClassInfo_Audio_Host_t *const AudioInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE
| Reads the next 16-bit audio sample from the current audio interface.
static int32_t | Audio_Host_ReadSample24 (USB_ClassInfo_Audio_Host_t *const AudioInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE
| Reads the next 24-bit audio sample from the current audio interface.
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
| Writes the next 8-bit audio sample to the current audio interface.
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
| Writes the next 16-bit audio sample to the current audio interface.
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
| Writes the next 24-bit audio sample to the current audio interface.

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

Definition at line 108 of file AudioClassHost.h.

## Function Documentation

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

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

  AudioInterfaceInfo | : Pointer to a structure containing an Audio Class host configuration and state.
  ConfigDescriptorSize | : Length of the attached device's Configuration Descriptor.
  DeviceConfigDescriptor | : Pointer to a buffer containing the attached device's Configuration Descriptor.

Returns
  A value from the AUDIO_Host_EnumerationFailure_ErrorCodes_t enum.

Definition at line 43 of file AudioClassHost.c.

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

  AudioInterfaceInfo | : Pointer to a structure containing an Audio Class host configuration and state.
  DataPipeIndex | : Index of the data pipe whose bound endpoint is to be altered.
  EndpointProperty | : Property of the endpoint to get or set, a value from Audio_ClassRequests_t.
  EndpointControl | : Parameter of the endpoint to get or set, a value from Audio_EndpointControls_t.
  DataLength | : For SET operations, the length of the parameter data to set. For GET operations, the maximum length of the retrieved data.
  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.

Definition at line 216 of file AudioClassHost.c.

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

  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.

Definition at line 222 of file AudioClassHost.h.

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

  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.

Definition at line 194 of file AudioClassHost.h.

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

  AudioInterfaceInfo | : Pointer to a structure containing an Audio Class configuration and state.

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

Definition at line 274 of file AudioClassHost.h.

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

  AudioInterfaceInfo | : Pointer to a structure containing an Audio Class configuration and state.

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

Definition at line 303 of file AudioClassHost.h.

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

  AudioInterfaceInfo | : Pointer to a structure containing an Audio Class configuration and state.

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

Definition at line 244 of file AudioClassHost.h.

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

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

Returns
  A value from the USB_Host_SendControlErrorCodes_t enum.

Definition at line 205 of file AudioClassHost.c.

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

  AudioInterfaceInfo | : Pointer to a structure containing an Audio Class host configuration and state.

Returns
  Nothing

Definition at line 177 of file AudioClassHost.h.

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

  AudioInterfaceInfo | : Pointer to a structure containing an Audio Class configuration and state.
  Sample | : Signed 16-bit audio sample.

Returns
  Nothing

Definition at line 362 of file AudioClassHost.h.

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

  AudioInterfaceInfo | : Pointer to a structure containing an Audio Class configuration and state.
  Sample | : Signed 24-bit audio sample.

Returns
  Nothing

Definition at line 391 of file AudioClassHost.h.

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

  AudioInterfaceInfo | : Pointer to a structure containing an Audio Class configuration and state.
  Sample | : Signed 8-bit audio sample.

Returns
  Nothing

Definition at line 333 of file AudioClassHost.h.