| NUC472_NUC442_BSP V3.04.000 The Board Support Package for NUC472/NUC442

Functions | Variables
USB Host Audio Class Driver Exported Functions
NUC472/NUC442 Device Driver » USB Host Audio Class Driver » USB Host Audio Class Driver Exported Constants » USB Host Audio Class Driver Exported Type Define » USB Host Audio Class Driver Exported Structures
Collaboration diagram for USB Host Audio Class Driver Exported Functions:

## Functions
void | UAC_Init (void)
| Initialize this USB Audio Class driver. More...
UAC_DEV_T * | UAC_GetDeviceList (void)
| Get a list of currently connected USB Audio Class devices. More...
int32_t | UAC_GetChannelNumber (UAC_DEV_T *audev, uint8_t target)
| Obtain Audio Class device's channel number. More...
int32_t | UAC_GetBitResolution (UAC_DEV_T *audev, uint8_t target, uint8_t *byte_cnt)
| Obtain Audio Class device subframe bit resolution.. More...
int32_t | UAC_GetSamplingRate (UAC_DEV_T *audev, uint8_t target, uint32_t *srate_list, int max_cnt, uint8_t *type)
| Get a list of sampling rate frequences supported by the UAC device. More...
int32_t | UAC_MuteControl (UAC_DEV_T *audev, uint8_t target, uint8_t req, uint16_t chn, uint8_t *mute)
| Control Audio Class device mute on/off. More...
int32_t | UAC_VolumeControl (UAC_DEV_T *audev, uint8_t target, uint8_t req, uint16_t chn, uint16_t *volume)
| Audio Class device volume control. More...
int32_t | UAC_AutoGainControl (UAC_DEV_T *audev, uint8_t target, uint8_t req, uint16_t chn, uint8_t *mute)
| Audio Class device automatic gain control. More...
int32_t | UAC_SamplingRateControl (UAC_DEV_T *audev, uint8_t target, uint8_t req, uint32_t *srate)
| Set sampling rate frequency. More...
int32_t | UAC_InstallIsoInCbFun (UAC_DEV_T *audev, uint8_t *au_in_buff, int bufsiz, UAC_CB_FUNC *func)
| Install isochronous-in (microphone) callback function. Received audio data from UAC device will be delivered to user application by this callback function. More...
int32_t | UAC_StartIsoInPipe (UAC_DEV_T *audev)
| Start to receive audio data from UAC device via isochronous in pipe. More...
int32_t | UAC_StopIsoInPipe (UAC_DEV_T *audev)
| Stop UAC device audio in data stream. More...
int32_t | UAC_InstallIsoOutCbFun (UAC_DEV_T *audev, UAC_CB_FUNC *func)
| Install isochronous-out (speaker) callback function. The UAC driver will call the callback function to request one audio out packet from user application. UAC driver will then send this packet to UAC device via isochronous out pipe. More...
int32_t | UAC_StartIsoOutPipe (UAC_DEV_T *audev)
| Start to send audio data to UAC device via isochronous out pipe. More...
int32_t | UAC_StopIsoOutPipe (UAC_DEV_T *audev)
| Stop UAC device audio out data stream. More...

## Variables
USB_DEV_T * | uac_dev_t::udev
int | uac_dev_t::ctrl_ifnum
int | uac_dev_t::au_in_ifnum
int | uac_dev_t::au_out_ifnum
void * | uac_dev_t::priv
struct uac_dev_t * | uac_dev_t::next
EP_INFO_T * | uac_dev_t::ep_au_in
EP_INFO_T * | uac_dev_t::ep_au_out
URB_T * | uac_dev_t::urbin [ISO_IN_URB_CNT]
URB_T * | uac_dev_t::urbout [ISO_OUT_URB_CNT]
uint8_t | uac_dev_t::iso_inbuf [ISO_IN_URB_CNT][AU_IN_MAX_PKTSZ *ISO_FRAME_COUNT]
uint8_t | uac_dev_t::iso_outbuf [ISO_OUT_URB_CNT][AU_OUT_MAX_PKTSZ *ISO_FRAME_COUNT]
uint8_t | uac_dev_t::in_streaming
uint8_t | uac_dev_t::out_streaming
UAC_CB_FUNC * | uac_dev_t::au_in_func
UAC_CB_FUNC * | uac_dev_t::au_out_func
uint8_t * | uac_dev_t::au_in_buff
int | uac_dev_t::au_in_bufsz
int | uac_dev_t::au_in_bufidx

## Detailed Description

Audio Class device structure

## Function Documentation

## ◆ UAC_AutoGainControl()

int32_t UAC_AutoGainControl | ( | UAC_DEV_T * | audev,
|  | uint8_t | target,
|  | uint8_t | req,
|  | uint16_t | chn,
|  | uint8_t * | mute
| ) |  |

Audio Class device automatic gain control.

Parameters

  [in] | audev | UAC device
  [in] | target | Select the control target. UAC_SPEAKER UAC_MICROPHONE
  [in] | req | Control request. This UAC driver supports the following request: UAC_SET_CUR UAC_GET_CUR
  [in] | chn | The requested channel. It can be one of the followings: UAC_CH_LEFT_FRONT UAC_CH_RIGHT_FRONT UAC_CH_CENTER_FRONT UAC_CH_LOW_FREQ_EN UAC_CH_LEFT_SRN UAC_CH_RIGHT_SRN UAC_CH_LEFT_OF_CENTER UAC_CH_RIGHT_OF_CENTER UAC_CH_SURROUND UAC_CH_SIDE_LEFT UAC_CH_SIDE_RIGHT UAC_CH_TOP
  [in] | mute | One byte data. If the channel's automaic gain control is on, then the value is 1. Otherwise, it's 0.

Returns
  Success or failed.

Return values

  0 | Success
  UAC_RET_DEV_NOT_SUPPORTED | This UAC device does not support this function.
  Otheriwse | Error occurred

Definition at line 435 of file uac_core.c.

Here is the call graph for this function:

## ◆ UAC_GetBitResolution()

int32_t UAC_GetBitResolution | ( | UAC_DEV_T * | audev,
|  | uint8_t | target,
|  | uint8_t * | byte_cnt
| ) |  |

Obtain Audio Class device subframe bit resolution..

Parameters

  [in] | audev | UAC device
  [in] | target | Select the control target. UAC_SPEAKER UAC_MICROPHONE
  [out] | byte_cnt | The number of bytes occupied by one audio subframe. Can be 1, 2, 3 or 4.

Returns
  Bit resolution or error code.

Return values

  < | 0 Failed. UAC device may not present or function not supported.
  Otherwise | The number of effectively used bits from the available bits in an audio subframe.

Definition at line 79 of file uac_core.c.

## ◆ UAC_GetChannelNumber()

int32_t UAC_GetChannelNumber | ( | UAC_DEV_T * | audev,
|  | uint8_t | target
| ) |  |

Obtain Audio Class device's channel number.

Parameters

  [in] | audev | UAC device
  [in] | target | Select the control target. UAC_SPEAKER UAC_MICROPHONE

Returns
  Channel number or error code.

Return values

  < | 0 Failed. UAC device may not present or function not supported.
  Otheriwse | The channle number.

Definition at line 46 of file uac_core.c.

## ◆ UAC_GetDeviceList()

UAC_DEV_T * UAC_GetDeviceList | ( | void |  | ) |

Get a list of currently connected USB Audio Class devices.

Returns
  List of current connected UAC devices.

Return values

  NULL | There's no UAC devices found.
  Otherwise | A list of connected UAC devices.

The Audio Class devices are chained by the "next" member of UAC_DEV_T.

Definition at line 277 of file uac_driver.c.

## ◆ UAC_GetSamplingRate()

HIDDEN_SYMBOLS int32_t UAC_GetSamplingRate | ( | UAC_DEV_T * | audev,
|  | uint8_t | target,
|  | uint32_t * | srate_list,
|  | int | max_cnt,
|  | uint8_t * | type
| ) |  |

Get a list of sampling rate frequences supported by the UAC device.

Parameters

  [in] | audev | UAC device
  [in] | target | Select the control target. UAC_SPEAKER UAC_MICROPHONE
  [out] | srate_list | A word array provided by user application to hold the sampling rate list.
  [in] | max_cnt | Available number of entries of srate_list[]. Must be > 2.
  [out] | type | Indicates how the sampling frequency can be programmed. 0: Continuous sampling frequency. srate_list[0] is the lower bound in Hz of the sampling frequency and srate_list[1] is the upper bound. 1~255: The number of discrete sampling frequencies supported. They are listed in srate_list[].

Returns
  Success or not.

Return values

  0 | Success
  Otherwise | Failed

Definition at line 130 of file uac_core.c.

## ◆ UAC_Init()

HIDDEN_SYMBOLS void UAC_Init | ( | void |  | ) |

Initialize this USB Audio Class driver.

Returns
  None

Definition at line 261 of file uac_driver.c.

Here is the call graph for this function:

## ◆ UAC_InstallIsoInCbFun()

HIDDEN_SYMBOLS int32_t UAC_InstallIsoInCbFun | ( | UAC_DEV_T * | audev,
|  | uint8_t * | au_in_buff,
|  | int | bufsiz,
|  | UAC_CB_FUNC * | func
| ) |  |

Install isochronous-in (microphone) callback function. Received audio data from UAC device will be delivered to user application by this callback function.

Parameters

  [in] | audev | Audio Class device
  [in] | au_in_buff | Audio stream input buffer. User application prepares and announces this buffer. UAC driver will directly move received audio data into it. Once UAC driver moves audio data into au_in_buff, it will call the callback to notify user.
  [in] | bufsiz | Size of au_in_buff.
  [in] | func | The audio in callback function.

Returns
  Success or not.

Return values

  0 | Success
  Otherwise | Failed

Definition at line 559 of file uac_core.c.

## ◆ UAC_InstallIsoOutCbFun()

HIDDEN_SYMBOLS int32_t UAC_InstallIsoOutCbFun | ( | UAC_DEV_T * | audev,
|  | UAC_CB_FUNC * | func
| ) |  |

Install isochronous-out (speaker) callback function. The UAC driver will call the callback function to request one audio out packet from user application. UAC driver will then send this packet to UAC device via isochronous out pipe.

Parameters

  [in] | audev | Audio Class device
  [in] | func | The audio out callback function.

Returns
  Success or not.

Return values

  0 | Success
  Otherwise | Failed

Definition at line 749 of file uac_core.c.

## ◆ UAC_MuteControl()

int32_t UAC_MuteControl | ( | UAC_DEV_T * | audev,
|  | uint8_t | target,
|  | uint8_t | req,
|  | uint16_t | chn,
|  | uint8_t * | mute
| ) |  |

Control Audio Class device mute on/off.

Parameters

  [in] | audev | UAC device
  [in] | target | Select the control target. UAC_SPEAKER UAC_MICROPHONE
  [in] | req | Control request. This UAC driver supports the following request: UAC_SET_CUR UAC_GET_CUR
  [in] | chn | The requested channel. It can be one of the followings: UAC_CH_LEFT_FRONT UAC_CH_RIGHT_FRONT UAC_CH_CENTER_FRONT UAC_CH_LOW_FREQ_EN UAC_CH_LEFT_SRN UAC_CH_RIGHT_SRN UAC_CH_LEFT_OF_CENTER UAC_CH_RIGHT_OF_CENTER UAC_CH_SURROUND UAC_CH_SIDE_LEFT UAC_CH_SIDE_RIGHT UAC_CH_TOP
  [in] | mute | One byte data. If the channel is muted, then the value is 1. Otherwise, it's 0.

Returns
  Success or failed.

Return values

  0 | Success
  UAC_RET_DEV_NOT_SUPPORTED | This UAC device does not support this function.
  Otheriwse | Error occurred

Definition at line 269 of file uac_core.c.

Here is the call graph for this function:

## ◆ UAC_SamplingRateControl()

int32_t UAC_SamplingRateControl | ( | UAC_DEV_T * | audev,
|  | uint8_t | target,
|  | uint8_t | req,
|  | uint32_t * | srate
| ) |  |

Set sampling rate frequency.

Parameters

  [in] | audev | UAC device
  [in] | target | Select the control target. UAC_SPEAKER UAC_MICROPHONE
  [in] | req | Control request. This UAC driver supports the following request: UAC_SET_CUR UAC_GET_CUR UAC_SET_MIN UAC_GET_MIN UAC_SET_MAX UAC_GET_MAX UAC_SET_RES UAC_GET_RES
  [in] | srate | Sampling rate frequncy to be set or get.

Returns
  Success or failed.

Return values

  0 | Success
  Otheriwse | Error occurred

Definition at line 184 of file uac_core.c.

Here is the call graph for this function:

## ◆ UAC_StartIsoInPipe()

int32_t UAC_StartIsoInPipe | ( | UAC_DEV_T * | audev | ) |

Start to receive audio data from UAC device via isochronous in pipe.

Parameters

  [in] | audev | Audio Class device

Returns
  Success or not.

Return values

  0 | Success
  Otherwise | Failed

Definition at line 589 of file uac_core.c.

Here is the call graph for this function:

## ◆ UAC_StartIsoOutPipe()

int32_t UAC_StartIsoOutPipe | ( | UAC_DEV_T * | audev | ) |

Start to send audio data to UAC device via isochronous out pipe.

Parameters

  [in] | audev | Audio Class device

Returns
  Success or not.

Return values

  0 | Success
  Otherwise | Failed

Definition at line 776 of file uac_core.c.

Here is the call graph for this function:

## ◆ UAC_StopIsoInPipe()

int32_t UAC_StopIsoInPipe | ( | UAC_DEV_T * | audev | ) |

Stop UAC device audio in data stream.

Parameters

  [in] | audev | Audio Class device

Returns
  Success or not.

Return values

  0 | Success
  Otherwise | Failed

Definition at line 674 of file uac_core.c.

Here is the call graph for this function:

## ◆ UAC_StopIsoOutPipe()

int32_t UAC_StopIsoOutPipe | ( | UAC_DEV_T * | audev | ) |

Stop UAC device audio out data stream.

Parameters

  [in] | audev | Audio Class device

Returns
  Success or not.

Return values

  0 | Success
  Otherwise | Failed

Definition at line 865 of file uac_core.c.

Here is the call graph for this function:

## ◆ UAC_VolumeControl()

int32_t UAC_VolumeControl | ( | UAC_DEV_T * | audev,
|  | uint8_t | target,
|  | uint8_t | req,
|  | uint16_t | chn,
|  | uint16_t * | volume
| ) |  |

Audio Class device volume control.

Parameters

  [in] | audev | UAC device
  [in] | target | Select the control target. UAC_SPEAKER UAC_MICROPHONE
  [in] | req | Control request. This UAC driver supports the following request: UAC_SET_CUR UAC_GET_CUR UAC_SET_MIN UAC_GET_MIN UAC_SET_MAX UAC_GET_MAX UAC_SET_RES UAC_GET_RES UAC_GET_STAT
  [in] | chn | The requested channel. It can be one of the followings: UAC_CH_LEFT_FRONT UAC_CH_RIGHT_FRONT UAC_CH_CENTER_FRONT UAC_CH_LOW_FREQ_EN UAC_CH_LEFT_SRN UAC_CH_RIGHT_SRN UAC_CH_LEFT_OF_CENTER UAC_CH_RIGHT_OF_CENTER UAC_CH_SURROUND UAC_CH_SIDE_LEFT UAC_CH_SIDE_RIGHT UAC_CH_TOP
  [in] | volume | Audio Class device volume value, which is intepreted as the following: 0x7FFF: 127.9961 dB . . . 0x0100: 1.0000 dB . . . 0x0002: 0.0078 dB 0x0001: 0.0039 dB 0x0000: 0.0000 dB 0xFFFF: -0.0039 dB 0xFFFE: -0.0078 dB . . . 0xFE00: -1.0000 dB . . . 0x8002: -127.9922 dB 0x8001: -127.9961 dB

Returns
  Success or failed.

Return values

  0 | Success
  UAC_RET_DEV_NOT_SUPPORTED | This UAC device does not support this function.
  Otheriwse | Error occurred

Definition at line 362 of file uac_core.c.

Here is the call graph for this function:

## Variable Documentation

## ◆ au_in_buff

uint8_t* uac_dev_t::au_in_buff

Point to the user provided audio input buffer

Definition at line 125 of file usbh_uac.h.

## ◆ au_in_bufidx

int uac_dev_t::au_in_bufidx

Index for Audio Class driver writing au_in_buff

Definition at line 127 of file usbh_uac.h.

## ◆ au_in_bufsz

int uac_dev_t::au_in_bufsz

Size of au_in_buff

Definition at line 126 of file usbh_uac.h.

## ◆ au_in_func

UAC_CB_FUNC* uac_dev_t::au_in_func

Audio data input callback function

Definition at line 123 of file usbh_uac.h.

## ◆ au_in_ifnum

int uac_dev_t::au_in_ifnum

Audio data-in interface numder

Definition at line 103 of file usbh_uac.h.

## ◆ au_out_func

UAC_CB_FUNC* uac_dev_t::au_out_func

Audio data output callback function

Definition at line 124 of file usbh_uac.h.

## ◆ au_out_ifnum

int uac_dev_t::au_out_ifnum

Audio data-out interface numder

Definition at line 104 of file usbh_uac.h.

## ◆ ctrl_ifnum

int uac_dev_t::ctrl_ifnum

Audio control interface numder

Definition at line 102 of file usbh_uac.h.

## ◆ ep_au_in

EP_INFO_T* uac_dev_t::ep_au_in

Audio data input endoint

Definition at line 111 of file usbh_uac.h.

## ◆ ep_au_out

EP_INFO_T* uac_dev_t::ep_au_out

Audio data output endoint

Definition at line 112 of file usbh_uac.h.

## ◆ in_streaming

uint8_t uac_dev_t::in_streaming

Audio data in is streaming or not.

Definition at line 117 of file usbh_uac.h.

## ◆ iso_inbuf

uint8_t uac_dev_t::iso_inbuf[ISO_IN_URB_CNT][AU_IN_MAX_PKTSZ *ISO_FRAME_COUNT]

USB isochronous-in buffer

Definition at line 115 of file usbh_uac.h.

## ◆ iso_outbuf

uint8_t uac_dev_t::iso_outbuf[ISO_OUT_URB_CNT][AU_OUT_MAX_PKTSZ *ISO_FRAME_COUNT]

USB isochronous-out buffer

Definition at line 116 of file usbh_uac.h.

## ◆ next

struct uac_dev_t* uac_dev_t::next

Point to the next Audio Class device

Definition at line 106 of file usbh_uac.h.

## ◆ out_streaming

uint8_t uac_dev_t::out_streaming

Audio data out is streaming or not.

Definition at line 118 of file usbh_uac.h.

## ◆ priv

void* uac_dev_t::priv

Internal used by audio class driver

Definition at line 105 of file usbh_uac.h.

## ◆ udev

USB_DEV_T* uac_dev_t::udev

USB device pointer of UAC_DEV_T

Definition at line 101 of file usbh_uac.h.

## ◆ urbin

URB_T* uac_dev_t::urbin[ISO_IN_URB_CNT]

Audio data input URB

Definition at line 113 of file usbh_uac.h.

## ◆ urbout

URB_T* uac_dev_t::urbout[ISO_OUT_URB_CNT]

Audio data output URB

Definition at line 114 of file usbh_uac.h.