SAMV71 Xplained Ultra Software Package 1.4

Usbd_audio_speakerphone

Collaboration diagram for Usbd_audio_speakerphone:

Data Structures

struct  AUDDStream
struct  AUDDSpeakerPhoneDriver
 Audio SpeakerPhone driver internal state. More...
struct  AUDDParseData
struct  AUDDXfrExt
struct  AUDDSpeakerPhone
struct  _AUDHeaderDescriptor2
struct  _AUDFeatureUnitDescriptor3
struct  _AUDDSpeakerPhoneDriverAudioControlDescriptors
struct  _AUDFormatTypeOneDescriptor1
struct  _AUDDSpeakerPhoneDriverConfigurationDescriptors

Modules

 Audio SpeakerPhone stream
 Audio SpeakerPhone Device Codes
 Audio Device IDs required by driver
 Audio Device Channels
 Audio SpeakerPhone Channel Numbers
 Audio SpeakerPhone Interface IDs
 Audio SpeakerPhone Entity IDs

Typedefs

typedef void(* AUDDStreamEventCallback )(uint32_t ec, uint8_t channel, void *pArg)

Functions

void AUDDSpeakerPhoneDriver_Initialize (const USBDDriverDescriptors *pDescriptors)
void AUDDSpeakerPhoneDriver_ConfigurationChangeHandler (uint8_t cfgnum)
void AUDDSpeakerPhoneDriver_InterfaceSettingChangedHandler (uint8_t interface, uint8_t setting)
void AUDDSpeakerPhoneDriver_RequestHandler (const USBGenericRequest *request)
uint8_t AUDDSpeakerPhoneDriver_Read (void *buffer, uint32_t length, TransferCallback callback, void *argument)
uint8_t AUDDSpeakerPhoneDriver_SetupWrite (void *pListInit, void *pDmaInit, uint16_t listSize, uint16_t delaySize, TransferCallback callback, void *argument)
uint8_t AUDDSpeakerPhoneDriver_Write (void *buffer, uint16_t length)
WEAK void AUDDSpeakerPhoneDriver_MuteChanged (uint8_t mic, uint8_t channel, uint8_t muted)
WEAK void AUDDSpeakerPhoneDriver_StreamSettingChanged (uint8_t mic, uint8_t newSetting)
void AUDDStream_Initialize (AUDDStream *pAuds, uint8_t numChannels, uint16_t wChannelVolumes[], AUDDStreamEventCallback fCallback, void *pArg)
uint32_t AUDDStream_IsRequestAccepted (AUDDStream *pAuds, const USBGenericRequest *pReq)
uint32_t AUDDStream_ChangeMute (AUDDStream *pAuds, uint8_t bChannel, uint8_t bMute)
uint32_t AUDDStream_SetVolume (AUDDStream *pAuds, uint8_t bChannel, uint16_t wVolume)
uint32_t AUDDStream_Read (AUDDStream *pAuds, void *pData, uint32_t dwSize, TransferCallback fCallback, void *pArg)
uint32_t AUDDStream_SetupWrite (AUDDStream *pAuds, void *pListInit, void *pDmaInit, uint16_t listSize, uint16_t delaySize, TransferCallback callback, void *argument)
uint32_t AUDDStream_Write (AUDDStream *pAuds, void *pBuffer, uint16_t wLength)
uint32_t AUDDStream_Close (AUDDStream *pStream)
void AUDDSpeakerPhone_InitializeStream (AUDDStream *pAuds, uint8_t numChannels, uint16_t wChannelVolumes[], AUDDStreamEventCallback fCallback, void *pArg)
void AUDDSpeakerPhone_Initialize (AUDDSpeakerPhone *pAudf, USBDDriver *pUsbd, AUDDStream *pSpeaker, AUDDStream *pMicrophone)
USBGenericDescriptor * AUDDSpeakerPhone_ParseInterfaces (AUDDSpeakerPhone *pAudf, USBGenericDescriptor *pDescriptors, uint32_t dwLength)
uint32_t AUDDSpeakerPhone_CloseStream (AUDDSpeakerPhone *pAudf, uint32_t bInterface)
uint32_t AUDDSpeakerPhone_RequestHandler (AUDDSpeakerPhone *pAudf, const USBGenericRequest *pRequest)
uint32_t AUDDSpeakerPhone_Read (AUDDSpeakerPhone *pAudf, void *pData, uint32_t dwSize, TransferCallback fCallback, void *pArg)
uint32_t AUDDSpeakerPhone_SetupWrite (AUDDSpeakerPhone *pAudf, void *pListInit, void *pDmaInit, uint16_t listSize, uint16_t delaySize, TransferCallback callback, void *argument)
uint32_t AUDDSpeakerPhone_Write (AUDDSpeakerPhone *pAudf, void *pBuffer, uint16_t wLength)
struct _AUDHeaderDescriptor2 __attribute__ ((__packed__)) AUDHeaderDescriptor2

Variables

const USBDeviceDescriptor deviceDescriptor
const
AUDDSpeakerPhoneDriverConfigurationDescriptors 
fsConfigurationDescriptors
const
AUDDSpeakerPhoneDriverConfigurationDescriptors 
hsConfigurationDescriptors
const unsigned char languageIdDescriptor []
const unsigned char manufacturerDescriptor []
const unsigned char productDescriptor []
const unsigned char serialNumberDescriptor []
const unsigned char * stringDescriptors []
const USBDDriverDescriptors auddSpeakerPhoneDriverDescriptors
uint8_t AUDDStream::bFeatureUnitOut
uint8_t AUDDStream::bFeatureUnitIn
uint8_t AUDDStream::bAsInterface
uint8_t AUDDStream::bEndpointOut
uint8_t AUDDStream::bEndpointIn
uint8_t AUDDStream::bNumChannels
uint8_t AUDDStream::bmMute
uint16_t * AUDDStream::pwVolumes
AUDDStreamEventCallback AUDDStream::fCallback
void * AUDDStream::pArg



#define AUDD_EC_MuteChanged   1
#define AUDD_EC_VolumeChanged   2

Detailed Description

Implement speaker phone function that combine 1 AC interface, 1 AS interface for speaker and 1 AS interface for microphone.

Implement speakerphone function that combine 1 AC interface, 1 AS interface for speaker and 1 AS interface for microphone.


Define Documentation

#define AUDD_EC_MuteChanged   1

usbd_audio_ec Audio Device Event codes Mute status changed

Definition at line 61 of file AUDDStream.h.

#define AUDD_EC_VolumeChanged   2

Volume status changed

Definition at line 63 of file AUDDStream.h.


Typedef Documentation

typedef void(* AUDDStreamEventCallback)(uint32_t ec, uint8_t channel, void *pArg)

Callback function for Audio Stream Event

Definition at line 71 of file AUDDStream.h.


Function Documentation

uint32_t AUDDSpeakerPhone_CloseStream ( AUDDSpeakerPhone pAudf,
uint32_t  bInterface 
)

Close the stream. All pending transfers are canceled.

Parameters:
pAudf Pointer to AUDDSpeakerPhone instance.
bInterface Stream interface number
void AUDDSpeakerPhone_Initialize ( AUDDSpeakerPhone pAudf,
USBDDriver pUsbd,
AUDDStream pSpeaker,
AUDDStream pMicrophone 
)

Initialize AUDDSpeakerPhone instance.

Parameters:
pAudf Pointer to AUDDSpeakerPhone instance.
pUsbd Pointer to USBDDriver instance.
pSpeaker Pointer to speaker streaming interface.
pMicrophone Pointer to microphone streaming interface.
void AUDDSpeakerPhone_InitializeStream ( AUDDStream pAuds,
uint8_t  numChannels,
uint16_t  wChannelVolumes[],
AUDDStreamEventCallback  fCallback,
void *  pArg 
)

Initialize AUDDStream instance. Note the number of channels excludes the master control, so actual volume array size should be (1 + numChannels).

Parameters:
pAuds Pointer to AUDDStream instance.
numChannels Number of channels in the stream (excluding master,<31).
wChannelVolumes Data array for channel volume values, must include master (1 + numChannels).
fCallback Callback function for stream control events.
pArg Pointer to event handler arguments.
USBGenericDescriptor * AUDDSpeakerPhone_ParseInterfaces ( AUDDSpeakerPhone pAudf,
USBGenericDescriptor *  pDescriptors,
uint32_t  dwLength 
)

Parse USB Audio streaming information for AUDDStream instance.

Parameters:
pAudf Pointer to AUDDSpeakerPhone instance.
pDescriptors Pointer to descriptor list.
dwLength Descriptor list size in bytes.
uint32_t AUDDSpeakerPhone_Read ( AUDDSpeakerPhone pAudf,
void *  pData,
uint32_t  dwSize,
TransferCallback  fCallback,
void *  pArg 
)

Receives data from the host through the audio function (as speaker). This function behaves like USBD_Read.

Parameters:
pAudf Pointer to AUDDSpeakerPhone instance.
pData Pointer to the data buffer to put received data.
dwSize Size of the data buffer in bytes.
fCallback Optional callback function to invoke when the transfer finishes.
pArg Optional argument to the callback function.
Returns:
USBD_STATUS_SUCCESS if the read operation has been started normally; otherwise, the corresponding error code.
uint32_t AUDDSpeakerPhone_RequestHandler ( AUDDSpeakerPhone pAudf,
const USBGenericRequest pRequest 
)

Handles audio-specific USB requests sent by the host

Parameters:
pAudf Pointer to AUDDSpeakerPhone instance.
pRequest Pointer to a USBGenericRequest instance.
Returns:
USBRC_PARAM_ERR if not handled.
uint32_t AUDDSpeakerPhone_SetupWrite ( AUDDSpeakerPhone pAudf,
void *  pListInit,
void *  pDmaInit,
uint16_t  listSize,
uint16_t  delaySize,
TransferCallback  callback,
void *  argument 
)

Initialize Frame List for sending audio data.

Parameters:
pAudf Pointer to AUDDSpeakerPhone instance.
pListInit Pointer to the allocated list for audio write.
pDmaInit Pointer to the allocated DMA descriptors for autio write (if DMA supported).
listSize Circular list size.
delaySize Start transfer after delaySize frames filled in.
callback Optional callback function for transfer.
argument Optional callback argument.
Returns:
USBD_STATUS_SUCCESS if setup successfully; otherwise an error code.
uint32_t AUDDSpeakerPhone_Write ( AUDDSpeakerPhone pAudf,
void *  pBuffer,
uint16_t  wLength 
)

Add frame buffer to audio sending list.

Parameters:
pAudf Pointer to AUDDSpeakerPhone instance.
pBuffer Pointer to data frame to send.
wLength Frame size in bytes.
Returns:
USBD_STATUS_SUCCESS if the transfer is started successfully; otherwise an error code.
void AUDDSpeakerPhoneDriver_ConfigurationChangeHandler ( uint8_t  cfgnum  ) 

Invoked whenever the active configuration of device is changed by the host.

Parameters:
cfgnum Configuration number.
void AUDDSpeakerPhoneDriver_Initialize ( const USBDDriverDescriptors pDescriptors  ) 

Initializes an USB audio SpeakerPhone device driver, as well as the underlying USB controller.

void AUDDSpeakerPhoneDriver_InterfaceSettingChangedHandler ( uint8_t  interface,
uint8_t  setting 
)

Invoked whenever the active setting of an interface is changed by the host. Changes the status of the third LED accordingly.

Parameters:
interface Interface number.
setting Newly active setting.
WEAK void AUDDSpeakerPhoneDriver_MuteChanged ( uint8_t  mic,
uint8_t  channel,
uint8_t  muted 
)

Invoked when an audio channel get muted or unmuted. Mutes/unmutes the channel at the DAC level.

Parameters:
mic Microphone/Speaker stream changed.
channel Channel number that changed.
muted Indicates the new mute status of the channel.
uint8_t AUDDSpeakerPhoneDriver_Read ( void *  buffer,
uint32_t  length,
TransferCallback  callback,
void *  argument 
)

Reads incoming audio data sent by the USB host into the provided buffer. When the transfer is complete, an optional callback function is invoked.

Parameters:
buffer Pointer to the data storage buffer.
length Size of the buffer in bytes.
callback Optional callback function.
argument Optional argument to the callback function.
Returns:
USBD_STATUS_SUCCESS if the transfer is started successfully; otherwise an error code.
void AUDDSpeakerPhoneDriver_RequestHandler ( const USBGenericRequest request  ) 

Handles audio-specific USB requests sent by the host, and forwards standard ones to the USB device driver.

Parameters:
request Pointer to a USBGenericRequest instance.
uint8_t AUDDSpeakerPhoneDriver_SetupWrite ( void *  pListInit,
void *  pDmaInit,
uint16_t  listSize,
uint16_t  delaySize,
TransferCallback  callback,
void *  argument 
)

Initialize Frame List for sending audio data.

Parameters:
pListInit Pointer to the allocated list for audio write.
pDmaInit Pointer to the allocated DMA descriptors for autio write (if DMA supported).
listSize Circular list size.
delaySize Start transfer after delaySize frames filled in.
callback Optional callback function for transfer.
argument Optional callback argument.
Returns:
USBD_STATUS_SUCCESS if setup successfully; otherwise an error code.
WEAK void AUDDSpeakerPhoneDriver_StreamSettingChanged ( uint8_t  mic,
uint8_t  newSetting 
)

Invoked when an audio streaming interface setting changed. Actually control streaming rate.

Parameters:
mic Microphone/Speaker stream changed.
newSetting New stream (interface) setting.
uint8_t AUDDSpeakerPhoneDriver_Write ( void *  buffer,
uint16_t  length 
)

Add frame buffer to audio sending list. Pointer to data frame to send. Frame size in bytes.

Returns:
USBD_STATUS_SUCCESS if the transfer is started successfully; otherwise an error code.
uint32_t AUDDStream_ChangeMute ( AUDDStream pAuds,
uint8_t  bChannel,
uint8_t  bMute 
)

Change Stream Mute status.

Parameters:
pAuds Pointer to AUDDStream instance.
bChannel Channel number.
bmMute 1 to mute, 0 to unmute.
uint32_t AUDDStream_Close ( AUDDStream pStream  ) 

Close the stream. All pending transfers are canceled.

Parameters:
pStream Pointer to AUDDStream instance.
void AUDDStream_Initialize ( AUDDStream pAuds,
uint8_t  numChannels,
uint16_t  wChannelVolumes[],
AUDDStreamEventCallback  fCallback,
void *  pArg 
)

Initialize AUDDStream instance. Note the number of channels excludes the master control, so actual volume array size should be (1 + numChannels).

Parameters:
pAuds Pointer to AUDDStream instance.
numChannels Number of channels in the stream (<31).
wChannelVolumes Data array for channel volume values.
fCallback Callback function for stream events.
pArg Pointer to event handler arguments.
uint32_t AUDDStream_IsRequestAccepted ( AUDDStream pAuds,
const USBGenericRequest pReq 
)

Check if the request is accepted.

Parameters:
pAuds Pointer to AUDDStream instance.
pReq Pointer to a USBGenericRequest instance.
Returns:
1 if accepted.
uint32_t AUDDStream_Read ( AUDDStream pAuds,
void *  pData,
uint32_t  dwSize,
TransferCallback  fCallback,
void *  pArg 
)

Receives data from the host through the audio function (as speaker). This function behaves like USBD_Read.

Parameters:
pAuds Pointer to AUDDStream instance.
pData Pointer to the data buffer to put received data.
dwSize Size of the data buffer in bytes.
fCallback Optional callback function to invoke when the transfer finishes.
pArg Optional argument to the callback function.
Returns:
USBD_STATUS_SUCCESS if the read operation has been started normally; otherwise, the corresponding error code.
uint32_t AUDDStream_SetupWrite ( AUDDStream pAuds,
void *  pListInit,
void *  pDmaInit,
uint16_t  listSize,
uint16_t  delaySize,
TransferCallback  callback,
void *  argument 
)

Initialize Frame List for sending audio data.

Parameters:
pAuds Pointer to AUDDStream instance.
pListInit Pointer to the allocated list for audio write.
pDmaInit Pointer to the allocated DMA descriptors for autio write (if DMA supported).
listSize Circular list size.
delaySize Start transfer after delaySize frames filled in.
callback Optional callback function for transfer.
argument Optional callback argument.
Returns:
USBD_STATUS_SUCCESS if setup successfully; otherwise an error code.
uint32_t AUDDStream_SetVolume ( AUDDStream pAuds,
uint8_t  bChannel,
uint16_t  wVolume 
)

Set Stream Volume status.

Parameters:
pAuds Pointer to AUDDStream instance.
bChannel Channel number.
wVolume New volume value.
uint32_t AUDDStream_Write ( AUDDStream pAuds,
void *  pBuffer,
uint16_t  wLength 
)

Add frame buffer to audio sending list.

Parameters:
pAuds Pointer to AUDDStream instance.
pBuffer Pointer to data frame to send.
wLength Frame size in bytes.
Returns:
USBD_STATUS_SUCCESS if the transfer is started successfully; otherwise an error code.

Variable Documentation

Initial value:
 {

    &deviceDescriptor,
    (const USBConfigurationDescriptor *) &fsConfigurationDescriptors,
    &qualifierDescriptor,
    0,
    0,
    (const USBConfigurationDescriptor *) &hsConfigurationDescriptors,
    &qualifierDescriptor,
    0,
    stringDescriptors, 4 
}

List of descriptors required by an USB Audio Speakerphoneer device driver.

Definition at line 753 of file USBDDriverDescriptors.c.

uint8_t AUDDStream::bAsInterface [inherited]

Audio Streaming Interface Number

AudioStreaming Interface number

Definition at line 58 of file AUDDSpeakerPhoneDriver.c.

uint8_t AUDDStream::bEndpointIn [inherited]

Streaming IN endpoint address

Definition at line 92 of file AUDDStream.h.

uint8_t AUDDStream::bEndpointOut [inherited]

Streaming OUT endpoint address

Definition at line 90 of file AUDDStream.h.

uint8_t AUDDStream::bFeatureUnitIn [inherited]

AudioControl Feature Unit ID for OUT

Definition at line 86 of file AUDDStream.h.

uint8_t AUDDStream::bFeatureUnitOut [inherited]

AudioControl Feature Unit ID for IN

Definition at line 84 of file AUDDStream.h.

uint8_t AUDDStream::bmMute [inherited]

Mute control bits (8b)

Definition at line 96 of file AUDDStream.h.

uint8_t AUDDStream::bNumChannels [inherited]

Number of channels (<=8)

Definition at line 94 of file AUDDStream.h.

const USBDeviceDescriptor deviceDescriptor
Initial value:
 {

    sizeof(USBDeviceDescriptor),
    USBGenericDescriptor_DEVICE,
    USBDeviceDescriptor_USB2_00,
    AUDDeviceDescriptor_CLASS,
    AUDDeviceDescriptor_SUBCLASS,
    AUDDeviceDescriptor_PROTOCOL,
    CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0),
    AUDDSpeakerPhoneDriverDescriptors_VENDORID,
    AUDDSpeakerPhoneDriverDescriptors_PRODUCTID,
    AUDDSpeakerPhoneDriverDescriptors_RELEASE,
    1, 
    2, 
    3, 
    1  
}

Device descriptor for a USB Audio Speakerphone driver.

Definition at line 102 of file USBDDriverDescriptors.c.

Audio Streaming Events Callback

Definition at line 101 of file AUDDStream.h.

const AUDDSpeakerPhoneDriverConfigurationDescriptors fsConfigurationDescriptors

FS Configuration descriptors for a USB Audio Speakerphone driver.

Definition at line 135 of file USBDDriverDescriptors.c.

const AUDDSpeakerPhoneDriverConfigurationDescriptors hsConfigurationDescriptors

HS Configuration descriptors for a USB Audio Speakerphone driver.

Definition at line 411 of file USBDDriverDescriptors.c.

const unsigned char languageIdDescriptor[]
Initial value:
 {

    USBStringDescriptor_LENGTH(1),
    USBGenericDescriptor_STRING,
    USBStringDescriptor_ENGLISH_US
}

String descriptor with the supported languages.

Definition at line 687 of file USBDDriverDescriptors.c.

const unsigned char manufacturerDescriptor[]
Initial value:

Manufacturer name.

Definition at line 695 of file USBDDriverDescriptors.c.

void* AUDDStream::pArg [inherited]

Callback arguments

Definition at line 103 of file AUDDStream.h.

uint16_t* AUDDStream::pwVolumes [inherited]

Volume control data

Definition at line 98 of file AUDDStream.h.

const unsigned char serialNumberDescriptor[]
Initial value:

Product serial number.

Definition at line 729 of file USBDDriverDescriptors.c.

const unsigned char* stringDescriptors[]
Initial value:

Array of pointers to the four string descriptors.

Definition at line 740 of file USBDDriverDescriptors.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines