User API reference of the Audio Device Class. More...
Functions | |
void | USBD_ADCn_Initialize (void) |
Callback function called during USBD_Initialize to initialize the USB ADC class instance. | |
void | USBD_ADCn_Uninitialize (void) |
Callback function called during USBD_Uninitialize to de-initialize the USB ADC class instance. | |
void | USBD_ADCn_PlayStart (void) |
Callback function called when play started. | |
void | USBD_ADCn_PlayStop (void) |
Callback function called when play stopped. | |
void | USBD_ADCn_SetSpeakerMute (uint8_t ch, bool on) |
Callback function called when speaker mute setting changed. | |
void | USBD_ADCn_SetSpeakerVolume (uint8_t ch, uint16_t vol) |
Callback function called when speaker volume setting changed. | |
void | USBD_ADCn_RecordStart (void) |
Callback function called when recording started. | |
void | USBD_ADCn_RecordStop (void) |
Callback function called when recording stopped. | |
void | USBD_ADCn_SetMicrophoneMute (uint8_t ch, bool on) |
Callback function called when microphone mute setting changed. | |
void | USBD_ADCn_SetMicrophoneVolume (uint8_t ch, uint16_t vol) |
Callback function called when microphone volume setting changed. | |
void | USBD_ADCn_ReceivedSamples (void) |
Callback function called when data in USB buffer for speaker samples reaches half-full from empty. | |
usbStatus | USBD_ADC_SetSpeakerVolumeRange (uint8_t instance, uint8_t ch, uint16_t min, uint16_t max, uint16_t res, uint16_t cur) |
Set range for speaker volume control. | |
usbStatus | USBD_ADC_SetMicrophoneVolumeRange (uint8_t instance, uint8_t ch, uint16_t min, uint16_t max, uint16_t res, uint16_t cur) |
Set range for microphone volume (level) control. | |
uint32_t | USBD_ADC_ReceivedSamplesAvailable (uint8_t instance) |
Number of audio samples received from USB Host and available to be read. | |
uint32_t | USBD_ADC_WrittenSamplesPending (uint8_t instance) |
Number of audio samples written and pending to be sent to USB Host. | |
int32_t | USBD_ADC_ReadSamples (uint8_t instance, void *buf, int32_t num) |
Read audio samples received from USB Host. | |
int32_t | USBD_ADC_WriteSamples (uint8_t instance, const void *buf, int32_t num) |
Write audio samples to be transferred to USB Host. | |
User API reference of the Audio Device Class.
int32_t USBD_ADC_ReadSamples | ( | uint8_t | instance, |
void * | buf, | ||
int32_t | num | ||
) |
Read audio samples received from USB Host.
[in] | instance | instance of ADC class. |
[out] | buf | buffer that receives samples. |
[in] | num | maximum number of samples to read. |
The function USBD_ADC_ReadSamples reads audio samples that have been received from an USB Host.
The argument instance specifies the instance of the ADC class to be used.
The argument buf is a pointer to the buffer that stores the received samples. The data type is uint8_t, uint16_t or uint32_t and is specified by the USBD_ADCn_OUT_BBITRESOLUTION in USBD_Config_ADC_n.h file (USBD_ADCn_OUT_BBITRESOLUTION = 8 -> uint8_t, USBD_ADCn_OUT_BBITRESOLUTION = 16 -> uint16_t, USBD_ADCn_OUT_BBITRESOLUTION >= 24 -> uint32_t).
If stereo mode is used channels are encoded one sample per channel (sample 0 = L0, sample 1 = R0, sample 2 = L1, sample 3 = R1, ...)
The argument num specifies the maximum number of samples to be read.
Code Example
uint32_t USBD_ADC_ReceivedSamplesAvailable | ( | uint8_t | instance | ) |
Number of audio samples received from USB Host and available to be read.
[in] | instance | instance of ADC class. |
The function USBD_ADC_ReceivedSamplesAvailable signals the number of audio samples that have been received from the USB Host and are available to be read.
The argument instance specifies the instance of the ADC class to be used.
Code Example
usbStatus USBD_ADC_SetMicrophoneVolumeRange | ( | uint8_t | instance, |
uint8_t | ch, | ||
uint16_t | min, | ||
uint16_t | max, | ||
uint16_t | res, | ||
uint16_t | cur | ||
) |
Set range for microphone volume (level) control.
[in] | instance | instance of ADC class. |
[in] | ch | channel index :
|
[in] | min | minimum volume value. |
[in] | max | maximum volume value. |
[in] | res | volume resolution. |
[in] | cur | current volume value. |
The function USBD_ADC_SetMicrophoneVolumeRange sets the range for the microphone volume control.
The argument instance specifies the instance of the ADC class to be used.
The argument ch specifies the channel on the instance.
The argument min sets the minimum volume level.
The argument max sets the maximum volume level.
The argument res defines the volume resolution.
The argument cur sets the current volume level.
Code Example
usbStatus USBD_ADC_SetSpeakerVolumeRange | ( | uint8_t | instance, |
uint8_t | ch, | ||
uint16_t | min, | ||
uint16_t | max, | ||
uint16_t | res, | ||
uint16_t | cur | ||
) |
Set range for speaker volume control.
[in] | instance | instance of ADC class. |
[in] | ch | channel index :
|
[in] | min | minimum volume value. |
[in] | max | maximum volume value. |
[in] | res | volume resolution. |
[in] | cur | current volume value. |
The function USBD_ADC_SetSpeakerVolumeRange sets the range for the speaker volume control.
The argument instance specifies the instance of the ADC class to be used.
The argument ch specifies the channel on the instance.
The argument min sets the minimum volume level.
The argument max sets the maximum volume level.
The argument res defines the volume resolution.
The argument cur sets the current volume level.
Code Example
int32_t USBD_ADC_WriteSamples | ( | uint8_t | instance, |
const void * | buf, | ||
int32_t | num | ||
) |
Write audio samples to be transferred to USB Host.
[in] | instance | instance of ADC class. |
[in] | buf | buffer containing samples to write. |
[in] | num | number of samples to write. |
The function USBD_ADC_WriteSamples writes audio samples to be transferred to an USB Host.
The argument instance specifies the instance of the ADC class to be used.
The argument buf is a pointer to the buffer containing the samples to be written. The data type is uint8_t, uint16_t or uint32_t and is specified by the USBD_ADCn_IN_BBITRESOLUTION in USBD_Config_ADC_n.h file (USBD_ADCn_IN_BBITRESOLUTION = 8 -> uint8_t, USBD_ADCn_IN_BBITRESOLUTION = 16 -> uint16_t, USBD_ADCn_IN_BBITRESOLUTION >= 24 -> uint32_t).
If stereo mode is used, channels are encoded one sample per channel (sample 0 = L0, sample 1 = R0, sample 2 = L1, sample 3 = R1, ...)
The argument num specifies the maximum number of samples to be written.
Code Example
uint32_t USBD_ADC_WrittenSamplesPending | ( | uint8_t | instance | ) |
Number of audio samples written and pending to be sent to USB Host.
[in] | instance | instance of ADC class. |
The function USBD_ADC_WrittenSamplesPending signals the number of audio samples that were written and are pending. These signals must be still sent to the USB Host.
The argument instance specifies the instance of the ADC class.
Code Example
USBD_ADCn_Initialize | ( | void | ) |
Callback function called during USBD_Initialize to initialize the USB ADC class instance.
The function USBD_ADCn_Initialize initializes the hardware resources of the Audio Device Class USB Device. It is called during USBD_Initialize. The function may be used to allocate resources and initialize peripherals.
Modify this function to the application's needs.
Code Example
USBD_ADCn_PlayStart | ( | void | ) |
Callback function called when play started.
The callback function USBD_ADCn_PlayStart is called when a playback was started by the USB Host.
Code Example
USBD_ADCn_PlayStop | ( | void | ) |
Callback function called when play stopped.
The callback function USBD_ADCn_PlayStart is called when a playback was stopped by the USB Host.
Code Example
USBD_ADCn_ReceivedSamples | ( | void | ) |
Callback function called when data in USB buffer for speaker samples reaches half-full from empty.
The function USBD_ADCn_ReceivedSamples notifies that half of USB buffer for audio samples has been received starting from empty buffer.
Modify this function to the application needs.
USBD_ADCn_RecordStart | ( | void | ) |
Callback function called when recording started.
The callback function USBD_ADCn_RecordStart is called when a recording was started by the USB Host.
Code Example
USBD_ADCn_RecordStop | ( | void | ) |
Callback function called when recording stopped.
The callback function USBD_ADCn_RecordStop is called when a recording was stopped by the USB Host.
Code Example
USBD_ADCn_SetMicrophoneMute | ( | uint8_t | ch, |
bool | on | ||
) |
Callback function called when microphone mute setting changed.
[in] | ch | channel index :
|
[in] | on | current mute setting
|
The callback function USBD_ADCn_SetMicrophoneMute is called when the microphone mute setting was changed by the USB Host.
The argument ch specifies the channel that is used.
The argument on specifies the activated mute setting.
Code Example
USBD_ADCn_SetMicrophoneVolume | ( | uint8_t | ch, |
uint16_t | vol | ||
) |
Callback function called when microphone volume setting changed.
[in] | ch | channel index :
|
[in] | vol | current volume setting. |
The callback function USBD_ADCn_SetMicrophoneVolume is called when the microphone volume setting was changed by the USB Host.
The argument ch specifies the channel that is used.
The argument vol specifies the changed volume setting.
Code Example
USBD_ADCn_SetSpeakerMute | ( | uint8_t | ch, |
bool | on | ||
) |
Callback function called when speaker mute setting changed.
[in] | ch | channel index :
|
[in] | on | current mute setting :
|
The callback function USBD_ADCn_SetSpeakerMute is called when the speaker mute setting was changed by the USB Host.
The argument ch specifies the channel that is used.
The argument on specifies the activated mute setting.
Code Example
USBD_ADCn_SetSpeakerVolume | ( | uint8_t | ch, |
uint16_t | vol | ||
) |
Callback function called when speaker volume setting changed.
[in] | ch | channel index :
|
[in] | vol | current volume setting. |
The callback function USBD_ADCn_SetSpeakerVolume is called when the speaker volume setting was changed by the USB Host.
The argument ch specifies the channel that is used.
The argument vol specifies the changed volume setting.
Code Example
USBD_ADCn_Uninitialize | ( | void | ) |
Callback function called during USBD_Uninitialize to de-initialize the USB ADC class instance.
The function USBD_ADCn_Uninitialize de-initializes/releases the hardware resources of the Audio Device Class USB Device. It is called during USBD_Uninitialize. If USBD_ADCn_Initialize has been adapted to the application, USBD_ADCn_Uninitialize should release resources and de-initialize peripherals.