STM32746G-Discovery board drivers V1.0.0

Dependents:   F746_SD_GraphicEqualizer_ren0620

Fork of BSP_DISCO_F746NG by ST

Embed: (wiki syntax)

« Back to documentation index

STM32746G_DISCOVERY AUDIO Out Exported Functions

STM32746G_DISCOVERY AUDIO Out Exported Functions
[STM32746G_DISCOVERY AUDIO]

Functions

uint8_t BSP_AUDIO_OUT_Init (uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq)
 Configures the audio peripherals.
uint8_t BSP_AUDIO_OUT_Play (uint16_t *pBuffer, uint32_t Size)
 Starts playing audio stream from a data buffer for a determined size.
void BSP_AUDIO_OUT_ChangeBuffer (uint16_t *pData, uint16_t Size)
 Sends n-Bytes on the SAI interface.
uint8_t BSP_AUDIO_OUT_Pause (void)
 This function Pauses the audio file stream.
uint8_t BSP_AUDIO_OUT_Resume (void)
 This function Resumes the audio file stream.
uint8_t BSP_AUDIO_OUT_Stop (uint32_t Option)
 Stops audio playing and Power down the Audio Codec.
uint8_t BSP_AUDIO_OUT_SetVolume (uint8_t Volume)
 Controls the current audio volume level.
uint8_t BSP_AUDIO_OUT_SetMute (uint32_t Cmd)
 Enables or disables the MUTE mode by software.
uint8_t BSP_AUDIO_OUT_SetOutputMode (uint8_t Output)
 Switch dynamically (while audio file is played) the output target (speaker or headphone).
void BSP_AUDIO_OUT_SetFrequency (uint32_t AudioFreq)
 Updates the audio frequency.
void BSP_AUDIO_OUT_SetAudioFrameSlot (uint32_t AudioFrameSlot)
 Updates the Audio frame slot configuration.
void BSP_AUDIO_OUT_DeInit (void)
 Deinit the audio peripherals.
void HAL_SAI_TxCpltCallback (SAI_HandleTypeDef *hsai)
 Tx Transfer completed callbacks.
void HAL_SAI_TxHalfCpltCallback (SAI_HandleTypeDef *hsai)
 Tx Half Transfer completed callbacks.
void HAL_SAI_ErrorCallback (SAI_HandleTypeDef *hsai)
 SAI error callbacks.
__weak void BSP_AUDIO_OUT_TransferComplete_CallBack (void)
 Manages the DMA full Transfer complete event.
__weak void BSP_AUDIO_OUT_HalfTransfer_CallBack (void)
 Manages the DMA Half Transfer complete event.
__weak void BSP_AUDIO_OUT_Error_CallBack (void)
 Manages the DMA FIFO error event.
__weak void BSP_AUDIO_OUT_MspInit (SAI_HandleTypeDef *hsai, void *Params)
 Initializes BSP_AUDIO_OUT MSP.
__weak void BSP_AUDIO_OUT_MspDeInit (SAI_HandleTypeDef *hsai, void *Params)
 Deinitializes SAI MSP.
__weak void BSP_AUDIO_OUT_ClockConfig (SAI_HandleTypeDef *hsai, uint32_t AudioFreq, void *Params)
 Clock Config.
static void SAIx_Out_Init (uint32_t AudioFreq)
 Initializes the output Audio Codec audio interface (SAI).
static void SAIx_Out_DeInit (void)
 Deinitializes the output Audio Codec audio interface (SAI).

Function Documentation

void BSP_AUDIO_OUT_ChangeBuffer ( uint16_t *  pData,
uint16_t  Size 
)

Sends n-Bytes on the SAI interface.

Parameters:
pData,:pointer on data address
Size,:number of data to be written
Return values:
None

Definition at line 249 of file stm32746g_discovery_audio.c.

__weak void BSP_AUDIO_OUT_ClockConfig ( SAI_HandleTypeDef *  hsai,
uint32_t  AudioFreq,
void *  Params 
)

Clock Config.

Parameters:
hsai,:might be required to set audio peripheral predivider if any.
AudioFreq,:Audio frequency used to play the audio stream.
Params
Note:
This API is called by BSP_AUDIO_OUT_Init() and BSP_AUDIO_OUT_SetFrequency() Being __weak it can be overwritten by the application
Return values:
None

Definition at line 672 of file stm32746g_discovery_audio.c.

void BSP_AUDIO_OUT_DeInit ( void   )

Deinit the audio peripherals.

Return values:
None

Definition at line 446 of file stm32746g_discovery_audio.c.

__weak void BSP_AUDIO_OUT_Error_CallBack ( void   )

Manages the DMA FIFO error event.

Return values:
None

Definition at line 524 of file stm32746g_discovery_audio.c.

__weak void BSP_AUDIO_OUT_HalfTransfer_CallBack ( void   )

Manages the DMA Half Transfer complete event.

Return values:
None

Definition at line 516 of file stm32746g_discovery_audio.c.

uint8_t BSP_AUDIO_OUT_Init ( uint16_t  OutputDevice,
uint8_t  Volume,
uint32_t  AudioFreq 
)

Configures the audio peripherals.

Parameters:
OutputDevice,:OUTPUT_DEVICE_SPEAKER, OUTPUT_DEVICE_HEADPHONE, or OUTPUT_DEVICE_BOTH.
Volume,:Initial volume level (from 0 (Mute) to 100 (Max))
AudioFreq,:Audio frequency used to play the audio stream.
Note:
The I2S PLL input clock must be done in the user application.
Return values:
AUDIO_OKif correct communication, else wrong communication

Definition at line 174 of file stm32746g_discovery_audio.c.

__weak void BSP_AUDIO_OUT_MspDeInit ( SAI_HandleTypeDef *  hsai,
void *  Params 
)

Deinitializes SAI MSP.

Parameters:
hsai,:SAI handle
Params
Return values:
None

Definition at line 627 of file stm32746g_discovery_audio.c.

__weak void BSP_AUDIO_OUT_MspInit ( SAI_HandleTypeDef *  hsai,
void *  Params 
)

Initializes BSP_AUDIO_OUT MSP.

Parameters:
hsai,:SAI handle
Params
Return values:
None

Definition at line 534 of file stm32746g_discovery_audio.c.

uint8_t BSP_AUDIO_OUT_Pause ( void   )

This function Pauses the audio file stream.

In case of using DMA, the DMA Pause feature is used.

Note:
When calling BSP_AUDIO_OUT_Pause() function for pause, only BSP_AUDIO_OUT_Resume() function should be called for resume (use of BSP_AUDIO_OUT_Play() function for resume could lead to unexpected behaviour).
Return values:
AUDIO_OKif correct communication, else wrong communication

Definition at line 262 of file stm32746g_discovery_audio.c.

uint8_t BSP_AUDIO_OUT_Play ( uint16_t *  pBuffer,
uint32_t  Size 
)

Starts playing audio stream from a data buffer for a determined size.

Parameters:
pBuffer,:Pointer to the buffer
Size,:Number of audio data in BYTES unit. In memory, first element is for left channel, second element is for right channel
Return values:
AUDIO_OKif correct communication, else wrong communication

Definition at line 227 of file stm32746g_discovery_audio.c.

uint8_t BSP_AUDIO_OUT_Resume ( void   )

This function Resumes the audio file stream.

Note:
When calling BSP_AUDIO_OUT_Pause() function for pause, only BSP_AUDIO_OUT_Resume() function should be called for resume (use of BSP_AUDIO_OUT_Play() function for resume could lead to unexpected behaviour).
Return values:
AUDIO_OKif correct communication, else wrong communication

Definition at line 286 of file stm32746g_discovery_audio.c.

void BSP_AUDIO_OUT_SetAudioFrameSlot ( uint32_t  AudioFrameSlot )

Updates the Audio frame slot configuration.

Parameters:
AudioFrameSlot,:specifies the audio Frame slot This parameter can be one of the following values

  • CODEC_AUDIOFRAME_SLOT_0123
  • CODEC_AUDIOFRAME_SLOT_02
  • CODEC_AUDIOFRAME_SLOT_13
Note:
This API should be called after the BSP_AUDIO_OUT_Init() to adjust the audio frame slot.
Return values:
None

Definition at line 429 of file stm32746g_discovery_audio.c.

void BSP_AUDIO_OUT_SetFrequency ( uint32_t  AudioFreq )

Updates the audio frequency.

Parameters:
AudioFreq,:Audio frequency used to play the audio stream.
Note:
This API should be called after the BSP_AUDIO_OUT_Init() to adjust the audio frequency.
Return values:
None

Definition at line 402 of file stm32746g_discovery_audio.c.

uint8_t BSP_AUDIO_OUT_SetMute ( uint32_t  Cmd )

Enables or disables the MUTE mode by software.

Parameters:
Cmd,:Could be AUDIO_MUTE_ON to mute sound or AUDIO_MUTE_OFF to unmute the codec and restore previous volume level.
Return values:
AUDIO_OKif correct communication, else wrong communication

Definition at line 360 of file stm32746g_discovery_audio.c.

uint8_t BSP_AUDIO_OUT_SetOutputMode ( uint8_t  Output )

Switch dynamically (while audio file is played) the output target (speaker or headphone).

Parameters:
Output,:The audio output target: OUTPUT_DEVICE_SPEAKER, OUTPUT_DEVICE_HEADPHONE or OUTPUT_DEVICE_BOTH
Return values:
AUDIO_OKif correct communication, else wrong communication

Definition at line 381 of file stm32746g_discovery_audio.c.

uint8_t BSP_AUDIO_OUT_SetVolume ( uint8_t  Volume )

Controls the current audio volume level.

Parameters:
Volume,:Volume level to be set in percentage from 0% to 100% (0 for Mute and 100 for Max volume level).
Return values:
AUDIO_OKif correct communication, else wrong communication

Definition at line 340 of file stm32746g_discovery_audio.c.

uint8_t BSP_AUDIO_OUT_Stop ( uint32_t  Option )

Stops audio playing and Power down the Audio Codec.

Parameters:
Option,:could be one of the following parameters

  • CODEC_PDWN_SW: for software power off (by writing registers). Then no need to reconfigure the Codec after power on.
  • CODEC_PDWN_HW: completely shut down the codec (physically). Then need to reconfigure the Codec after power on.
Return values:
AUDIO_OKif correct communication, else wrong communication

Definition at line 312 of file stm32746g_discovery_audio.c.

__weak void BSP_AUDIO_OUT_TransferComplete_CallBack ( void   )

Manages the DMA full Transfer complete event.

Return values:
None

Definition at line 508 of file stm32746g_discovery_audio.c.

void HAL_SAI_ErrorCallback ( SAI_HandleTypeDef *  hsai )

SAI error callbacks.

Parameters:
hsai,:SAI handle
Return values:
None

Definition at line 482 of file stm32746g_discovery_audio.c.

void HAL_SAI_TxCpltCallback ( SAI_HandleTypeDef *  hsai )

Tx Transfer completed callbacks.

Parameters:
hsai,:SAI handle
Return values:
None

Definition at line 458 of file stm32746g_discovery_audio.c.

void HAL_SAI_TxHalfCpltCallback ( SAI_HandleTypeDef *  hsai )

Tx Half Transfer completed callbacks.

Parameters:
hsai,:SAI handle
Return values:
None

Definition at line 470 of file stm32746g_discovery_audio.c.

static void SAIx_Out_DeInit ( void   ) [static]

Deinitializes the output Audio Codec audio interface (SAI).

Return values:
None

Definition at line 777 of file stm32746g_discovery_audio.c.

static void SAIx_Out_Init ( uint32_t  AudioFreq ) [static]

Initializes the output Audio Codec audio interface (SAI).

Parameters:
AudioFreq,:Audio frequency to be configured for the SAI peripheral.
Note:
The default SlotActive configuration is set to CODEC_AUDIOFRAME_SLOT_0123 and user can update this configuration using
Return values:
None

Definition at line 721 of file stm32746g_discovery_audio.c.