STM3210C_EVAL BSP User Manual: stm3210c_eval_audio.c File Reference

STM3210C EVAL BSP Drivers

stm3210c_eval_audio.c File Reference

This file provides the Audio driver for the STM3210C-Eval board. More...

Go to the source code of this file.

Functions

static void I2SOUT_MspInit (void)
 AUDIO OUT I2S MSP Init.
static void I2SOUT_Init (uint32_t AudioFreq)
 Initializes the Audio Codec audio interface (I2S)
uint8_t BSP_AUDIO_OUT_Init (uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq)
 Configure 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 I2S 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)
 Update the audio frequency.
void HAL_I2S_TxCpltCallback (I2S_HandleTypeDef *hi2s)
 Tx Transfer completed callbacks.
void HAL_I2S_TxHalfCpltCallback (I2S_HandleTypeDef *hi2s)
 Tx Transfer Half completed callbacks.
void HAL_I2S_ErrorCallback (I2S_HandleTypeDef *hi2s)
 I2S 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.

Variables

static AUDIO_DrvTypeDef * pAudioDrv
I2S_HandleTypeDef hAudioOutI2s

Detailed Description

This file provides the Audio driver for the STM3210C-Eval board.

Author:
MCD Application Team
Version:
V6.0.1
Date:
18-December-2015
  ==============================================================================
                     ##### How to use this driver #####
  ==============================================================================  
   [..] 
  (#) This driver supports STM32F107xC devices on STM3210C-Eval Kit:
       (++) to play an audio file (all functions names start by BSP_AUDIO_OUT_xxx)

  [..] 
   (#) PLAY A FILE:
       (++) Call the function BSP_AUDIO_OUT_Init(
              OutputDevice: physical output mode (OUTPUT_DEVICE_SPEAKER, 
                           OUTPUT_DEVICE_HEADPHONE, OUTPUT_DEVICE_AUTO or 
                           OUTPUT_DEVICE_BOTH)
              Volume: initial volume to be set (0 is min (mute), 100 is max (100%)
              AudioFreq: Audio frequency in Hz (8000, 16000, 22500, 32000 ...)
              this parameter is relative to the audio file/stream type.
               )
           This function configures all the hardware required for the audio application 
           (codec, I2C, I2S, GPIOs, DMA and interrupt if needed). This function returns 0
           if configuration is OK.
           If the returned value is different from 0 or the function is stuck then the 
           communication with the codec (try to un-plug the power or reset device in this case).
              (+++) OUTPUT_DEVICE_SPEAKER: only speaker will be set as output for the 
                    audio stream.
              (+++) OUTPUT_DEVICE_HEADPHONE: only headphones will be set as output for 
                    the audio stream.
              (+++) OUTPUT_DEVICE_AUTO: Selection of output device is made through external 
                    switch (implemented into the audio jack on the evaluation board). 
                    When the Headphone is connected it is used as output. 
                    When the headphone is disconnected from the audio jack, the output is
                    automatically switched to Speaker.
              (+++) OUTPUT_DEVICE_BOTH: both Speaker and Headphone are used as outputs 
                    for the audio stream at the same time.
       (++) Call the function BSP_AUDIO_OUT_Play(
                pBuffer: pointer to the audio data file address
                Size: size of the buffer to be sent in Bytes
               )
              to start playing (for the first time) from the audio file/stream.
       (++) Call the function BSP_AUDIO_OUT_Pause() to pause playing 
       (++) Call the function BSP_AUDIO_OUT_Resume() to resume playing.
            Note. After calling BSP_AUDIO_OUT_Pause() function for pause, 
            only BSP_AUDIO_OUT_Resume() should be called for resume 
            (it is not allowed to call BSP_AUDIO_OUT_Play() in this case).
            Note. This function should be called only when the audio file is played 
            or paused (not stopped).
       (++) For each mode, you may need to implement the relative callback functions 
            into your code.
            The Callback functions are named BSP_AUDIO_OUT_XXXCallBack() and only 
            their prototypes are declared in the stm3210c_eval_audio.h file. 
            (refer to the example for more details on the callbacks implementations)
       (++) To Stop playing, to modify the volume level, the frequency or to mute, 
            use the functions BSP_AUDIO_OUT_Stop(), BSP_AUDIO_OUT_SetVolume(), 
            AUDIO_OUT_SetFrequency() BSP_AUDIO_OUT_SetOutputMode and BSP_AUDIO_OUT_SetMute().
       (++) The driver API and the callback functions are at the end of the 
            stm3210c_eval_audio.h file.
   
       (++) This driver provide the High Audio Layer: consists of the function API 
            exported in the stm3210c_eval_audio.h file (BSP_AUDIO_OUT_Init(), 
            BSP_AUDIO_OUT_Play() ...)
       (++) This driver provide also the Media Access Layer (MAL): which consists 
            of functions allowing to access the media containing/providing the 
            audio file/stream. These functions are also included as local functions into
            the stm3210c_eval_audio.c file (I2SOUT_Init()...)
       
  [..] 
                     ##### Known Limitations #####
  ==============================================================================  
   (#) When using the Speaker, if the audio file quality is not high enough, the 
       speaker output may produce high and uncomfortable noise level. To avoid 
       this issue, to use speaker output properly, try to increase audio file 
       sampling rate (typically higher than 48KHz).
       This operation will lead to larger file size.
       
   (#) Communication with the audio codec (through I2C) may be corrupted if it 
       is interrupted by some user interrupt routines (in this case, interrupts 
       could be disabled just before the start of communication then re-enabled 
       when it is over). Note that this communication is only done at the 
       configuration phase (BSP_AUDIO_OUT_Init() or BSP_AUDIO_OUT_Stop()) 
       and when Volume control modification is performed (BSP_AUDIO_OUT_SetVolume() 
       or BSP_AUDIO_OUT_SetMute()or BSP_AUDIO_OUT_SetOutputMode()). 
       When the audio data is played, no communication is required with the audio codec.
       
   (#) Parsing of audio file is not implemented (in order to determine audio file
       properties: Mono/Stereo, Data size, File size, Audio Frequency, Audio Data 
       header size ...). The configuration is fixed for the given audio file.
       
   (#) Mono audio streaming is not supported (in order to play mono audio streams, 
       each data should be sent twice on the I2S or should be duplicated on the 
       source buffer. Or convert the stream in stereo before playing).
       
   (#) Supports only 16-bit audio data size.

  
Attention:

© COPYRIGHT(c) 2015 STMicroelectronics

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file stm3210c_eval_audio.c.

Generated on Thu Dec 10 2015 17:13:52 for STM3210C_EVAL BSP User Manual by   doxygen 1.7.6.1