Contains the BSP driver for the DISCO_F413ZH board.

Dependents:   DISCO_F413ZH-LCD-demo DISCO_F413ZH-touch-screen-demo DISCO_F413ZH-SD-demo DISCO_F413ZH-PSRAM-demo ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers stm32f413h_discovery_audio.h Source File

stm32f413h_discovery_audio.h

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32f413h_discovery_audio.h
00004   * @author  MCD Application Team
00005   * @brief   This file contains the common defines and functions prototypes for
00006   *          the stm32f413h_discovery_audio.c driver.
00007   ******************************************************************************
00008   * @attention
00009   *
00010   * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
00011   *
00012   * Redistribution and use in source and binary forms, with or without modification,
00013   * are permitted provided that the following conditions are met:
00014   *   1. Redistributions of source code must retain the above copyright notice,
00015   *      this list of conditions and the following disclaimer.
00016   *   2. Redistributions in binary form must reproduce the above copyright notice,
00017   *      this list of conditions and the following disclaimer in the documentation
00018   *      and/or other materials provided with the distribution.
00019   *   3. Neither the name of STMicroelectronics nor the names of its contributors
00020   *      may be used to endorse or promote products derived from this software
00021   *      without specific prior written permission.
00022   *
00023   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00024   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00025   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00026   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00027   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00028   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00029   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00030   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00031   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00032   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033   *
00034   ******************************************************************************
00035   */
00036 
00037 /* Define to prevent recursive inclusion -------------------------------------*/
00038 #ifndef __STM32F413H_DISCOVERY_AUDIO_H
00039 #define __STM32F413H_DISCOVERY_AUDIO_H
00040 
00041 #ifdef __cplusplus
00042  extern "C" {
00043 #endif 
00044 
00045 /* Includes ------------------------------------------------------------------*/
00046 /* Include audio component Driver */
00047 #include "../Components/wm8994/wm8994.h"
00048 #include "stm32f413h_discovery.h"
00049 
00050 /** @addtogroup BSP
00051   * @{
00052   */ 
00053 
00054 /** @addtogroup STM32F413H_DISCOVERY
00055   * @{
00056   */
00057     
00058 /** @addtogroup STM32F413H_DISCOVERY_AUDIO
00059   * @{
00060   */
00061 
00062 /** @defgroup STM32F413H_DISCOVERY_AUDIO_Exported_Types STM32F413H DISCOVERY Audio Exported Types
00063   * @{
00064   */
00065   
00066 typedef struct
00067 {
00068   uint32_t               Frequency;      /* Record Frequency */
00069   uint32_t               BitResolution;  /* Record bit resolution */
00070   uint32_t               ChannelNbr;     /* Record Channel Number */
00071   uint16_t               *pRecBuf;       /* Pointer to record user buffer */
00072   uint32_t               RecSize;        /* Size to record in mono, double size to record in stereo */
00073   uint32_t               InputDevice;    /* Audio Input Device */
00074   uint32_t               MultiBuffMode;  /* Multi buffer mode selection */
00075 }AUDIOIN_ContextTypeDef;
00076    
00077 /**
00078   * @}
00079   */ 
00080 
00081 /** @defgroup STM32F413H_DISCOVERY_AUDIO_Exported_Constants  STM32F413H DISCOVERY Audio Exported Constants
00082   * @{
00083   */
00084 
00085 /*------------------------------------------------------------------------------
00086                         AUDIO OUT CONFIGURATION
00087 ------------------------------------------------------------------------------*/
00088 /* SPI Configuration defines */
00089 #define AUDIO_OUT_I2Sx                           SPI2
00090 #define AUDIO_OUT_I2Sx_CLK_ENABLE()              __HAL_RCC_SPI2_CLK_ENABLE()
00091 #define AUDIO_OUT_I2Sx_CLK_DISABLE()             __HAL_RCC_SPI2_CLK_DISABLE()
00092 
00093 #define AUDIO_OUT_I2Sx_MCK_PIN                   GPIO_PIN_3
00094 #define AUDIO_OUT_I2Sx_MCK_GPIO_PORT             GPIOA
00095 #define AUDIO_OUT_I2Sx_MCK_GPIO_CLK_ENABLE()     __HAL_RCC_GPIOA_CLK_ENABLE()
00096 #define AUDIO_OUT_I2Sx_MCK_GPIO_CLK_DISABLE()    __HAL_RCC_GPIOA_CLK_DISABLE()
00097 #define AUDIO_OUT_I2Sx_MCK_AF                    GPIO_AF5_SPI2
00098 
00099 #define AUDIO_OUT_I2Sx_SCK_PIN                   GPIO_PIN_3
00100 #define AUDIO_OUT_I2Sx_SCK_GPIO_PORT             GPIOD
00101 #define AUDIO_OUT_I2Sx_SCK_GPIO_CLK_ENABLE()     __HAL_RCC_GPIOD_CLK_ENABLE()
00102 #define AUDIO_OUT_I2Sx_SCK_GPIO_CLK_DISABLE()    __HAL_RCC_GPIOD_CLK_DISABLE()
00103 #define AUDIO_OUT_I2Sx_SCK_AF                    GPIO_AF5_SPI2
00104 
00105 #define AUDIO_OUT_I2Sx_WS_PIN                    GPIO_PIN_9
00106 #define AUDIO_OUT_I2Sx_WS_GPIO_PORT              GPIOB
00107 #define AUDIO_OUT_I2Sx_WS_GPIO_CLK_ENABLE()      __HAL_RCC_GPIOB_CLK_ENABLE()
00108 #define AUDIO_OUT_I2Sx_WS_GPIO_CLK_DISABLE()     __HAL_RCC_GPIOB_CLK_DISABLE()
00109 #define AUDIO_OUT_I2Sx_WS_AF                     GPIO_AF5_SPI2
00110 
00111 #define AUDIO_OUT_I2Sx_SD_PIN                    GPIO_PIN_3
00112 #define AUDIO_OUT_I2Sx_SD_GPIO_PORT              GPIOC
00113 #define AUDIO_OUT_I2Sx_SD_GPIO_CLK_ENABLE()      __HAL_RCC_GPIOC_CLK_ENABLE()
00114 #define AUDIO_OUT_I2Sx_SD_GPIO_CLK_DISABLE()     __HAL_RCC_GPIOC_CLK_DISABLE()
00115 #define AUDIO_OUT_I2Sx_SD_AF                     GPIO_AF5_SPI2
00116 
00117 /* I2S DMA Stream Tx definitions */
00118 #define AUDIO_OUT_I2Sx_DMAx_CLK_ENABLE()         __HAL_RCC_DMA1_CLK_ENABLE()
00119 #define AUDIO_OUT_I2Sx_DMAx_CLK_DISABLE()        __HAL_RCC_DMA1_CLK_DISABLE()
00120 #define AUDIO_OUT_I2Sx_DMAx_STREAM               DMA1_Stream4
00121 #define AUDIO_OUT_I2Sx_DMAx_CHANNEL              DMA_CHANNEL_0
00122 #define AUDIO_OUT_I2Sx_DMAx_IRQ                  DMA1_Stream4_IRQn
00123 #define AUDIO_OUT_I2Sx_DMAx_PERIPH_DATA_SIZE     DMA_PDATAALIGN_HALFWORD
00124 #define AUDIO_OUT_I2Sx_DMAx_MEM_DATA_SIZE        DMA_MDATAALIGN_HALFWORD
00125 #define DMA_MAX_SIZE                             0xFFFF
00126    
00127 #define AUDIO_OUT_I2Sx_DMAx_IRQHandler           DMA1_Stream4_IRQHandler
00128   
00129    /* Select the interrupt preemption priority for the DMA interrupt */
00130 #define AUDIO_OUT_IRQ_PREPRIO                    ((uint32_t)0x0E)   /* Select the preemption priority level(0 is the highest) */
00131 
00132 
00133 /*------------------------------------------------------------------------------
00134                         AUDIO IN CONFIGURATION
00135 ------------------------------------------------------------------------------*/
00136 /* DFSDM Configuration defines */
00137 #define AUDIO_DFSDMx_MIC1_CHANNEL                      DFSDM1_Channel1    /* MP34DT01TR U1 microphone on PCB top side */
00138 #define AUDIO_DFSDMx_MIC2_CHANNEL                      DFSDM2_Channel1    /* MP34DT01TR U2 microphone on PCB top side */
00139 #define AUDIO_DFSDMx_MIC3_CHANNEL                      DFSDM2_Channel0    /* MP34DT01TR U3 microphone on PCB top side */
00140 #define AUDIO_DFSDMx_MIC4_CHANNEL                      DFSDM2_Channel7    /* MP34DT01TR U4 microphone on PCB top side */
00141 #define AUDIO_DFSDMx_MIC5_CHANNEL                      DFSDM2_Channel6    /* MP34DT01TR U5 microphone on PCB top side */
00142 
00143 #define AUDIO_DFSDMx_MIC1_CHANNEL_FOR_FILTER           DFSDM_CHANNEL_1
00144 #define AUDIO_DFSDMx_MIC2_CHANNEL_FOR_FILTER           DFSDM_CHANNEL_1
00145 #define AUDIO_DFSDMx_MIC3_CHANNEL_FOR_FILTER           DFSDM_CHANNEL_0
00146 #define AUDIO_DFSDMx_MIC4_CHANNEL_FOR_FILTER           DFSDM_CHANNEL_7
00147 #define AUDIO_DFSDMx_MIC5_CHANNEL_FOR_FILTER           DFSDM_CHANNEL_6
00148 
00149 #define AUDIO_DFSDMx_MIC1_FILTER                       DFSDM1_Filter0     /* Common MIC1 filter for MP34DT01TR (U1) microphone input */
00150 #define AUDIO_DFSDMx_MIC2_FILTER                       DFSDM2_Filter0     /* Common MIC2 filter for MP34DT01TR(U2) microphone input */
00151 #define AUDIO_DFSDMx_MIC3_FILTER                       DFSDM2_Filter1     /* Common MIC2 filter for MP34DT01TR(U3) microphone input */
00152 #define AUDIO_DFSDMx_MIC4_FILTER                       DFSDM2_Filter2     /* Common MIC2 filter for MP34DT01TR(U4) microphone input */
00153 #define AUDIO_DFSDMx_MIC5_FILTER                       DFSDM2_Filter3     /* Common MIC2 filter for MP34DT01TR(U5) microphone input */
00154 
00155 #define AUDIO_DFSDMx_MIC2_5_CLK_ENABLE()               __HAL_RCC_DFSDM2_CLK_ENABLE()
00156 #define AUDIO_DFSDMx_MIC1_CLK_ENABLE()                 __HAL_RCC_DFSDM1_CLK_ENABLE()
00157    
00158 #define AUDIO_DFSDMx_MIC1_CKOUT_PIN                          GPIO_PIN_8
00159 #define AUDIO_DFSDMx_MIC1_CKOUT_DMIC_GPIO_PORT               GPIOA
00160 #define AUDIO_DFSDMx_MIC1_CKOUT_DMIC_GPIO_CLK_ENABLE()       __HAL_RCC_GPIOA_CLK_ENABLE()
00161 #define AUDIO_DFSDMx_MIC1_CKOUT_DMIC_AF                      GPIO_AF6_DFSDM1
00162    
00163 #define AUDIO_DFSDMx_MIC1_DMIC_PIN                           GPIO_PIN_6
00164 #define AUDIO_DFSDMx_MIC1_DMIC_GPIO_PORT                     GPIOD
00165 #define AUDIO_DFSDMx_MIC1_DMIC_GPIO_CLK_ENABLE()             __HAL_RCC_GPIOD_CLK_ENABLE()
00166 #define AUDIO_DFSDMx_MIC1_DMIC_AF                            GPIO_AF6_DFSDM1
00167    
00168 #define AUDIO_DFSDMx_MIC2_5_CKOUT_PIN                        GPIO_PIN_2
00169 #define AUDIO_DFSDMx_MIC2_5_CKOUT_DMIC_GPIO_PORT             GPIOD
00170 #define AUDIO_DFSDMx_MIC2_5_CKOUT_DMIC_GPIO_CLK_ENABLE()     __HAL_RCC_GPIOD_CLK_ENABLE()
00171 #define AUDIO_DFSDMx_MIC2_5_CKOUT_DMIC_AF                    GPIO_AF3_DFSDM2
00172    
00173 #define AUDIO_DFSDMx_MIC23_DMIC_PIN                           GPIO_PIN_7
00174 #define AUDIO_DFSDMx_MIC23_DMIC_GPIO_PORT                     GPIOA
00175 #define AUDIO_DFSDMx_MIC23_DMIC_GPIO_CLK_ENABLE()             __HAL_RCC_GPIOA_CLK_ENABLE()
00176 #define AUDIO_DFSDMx_MIC23_DMIC_AF                            GPIO_AF7_DFSDM2  
00177    
00178 #define AUDIO_DFSDMx_MIC45_DMIC_PIN                           GPIO_PIN_7
00179 #define AUDIO_DFSDMx_MIC45_DMIC_GPIO_PORT                     GPIOB
00180 #define AUDIO_DFSDMx_MIC45_DMIC_GPIO_CLK_ENABLE()             __HAL_RCC_GPIOB_CLK_ENABLE()
00181 #define AUDIO_DFSDMx_MIC45_DMIC_AF                            GPIO_AF6_DFSDM2 
00182 
00183 /* DFSDM DMA Right and Left channels definitions */
00184 #define AUDIO_DFSDMx_DMAx_CLK_ENABLE()                 __HAL_RCC_DMA2_CLK_ENABLE()
00185 #define AUDIO_DFSDMx_DMAx_MIC1_STREAM                  DMA2_Stream6
00186 #define AUDIO_DFSDMx_DMAx_MIC1_CHANNEL                 DMA_CHANNEL_3
00187 #define AUDIO_DFSDMx_DMAx_MIC2_STREAM                  DMA2_Stream0
00188 #define AUDIO_DFSDMx_DMAx_MIC2_CHANNEL                 DMA_CHANNEL_8
00189 #define AUDIO_DFSDMx_DMAx_MIC3_STREAM                  DMA2_Stream1
00190 #define AUDIO_DFSDMx_DMAx_MIC3_CHANNEL                 DMA_CHANNEL_8
00191 #define AUDIO_DFSDMx_DMAx_MIC4_STREAM                  DMA2_Stream2
00192 #define AUDIO_DFSDMx_DMAx_MIC4_CHANNEL                 DMA_CHANNEL_8
00193 #define AUDIO_DFSDMx_DMAx_MIC5_STREAM                  DMA2_Stream7
00194 #define AUDIO_DFSDMx_DMAx_MIC5_CHANNEL                 DMA_CHANNEL_8
00195 #define AUDIO_DFSDMx_DMAx_MIC1_IRQ                     DMA2_Stream6_IRQn
00196 #define AUDIO_DFSDMx_DMAx_MIC2_IRQ                     DMA2_Stream0_IRQn
00197 #define AUDIO_DFSDMx_DMAx_MIC3_IRQ                     DMA2_Stream1_IRQn
00198 #define AUDIO_DFSDMx_DMAx_MIC4_IRQ                     DMA2_Stream2_IRQn
00199 #define AUDIO_DFSDMx_DMAx_MIC5_IRQ                     DMA2_Stream7_IRQn
00200 
00201 #define AUDIO_DFSDMx_DMAx_PERIPH_DATA_SIZE             DMA_PDATAALIGN_WORD
00202 #define AUDIO_DFSDMx_DMAx_MEM_DATA_SIZE                DMA_MDATAALIGN_WORD
00203    
00204 #define AUDIO_DFSDM_DMAx_MIC1_IRQHandler               DMA2_Stream6_IRQHandler
00205 #define AUDIO_DFSDM_DMAx_MIC2_IRQHandler               DMA2_Stream0_IRQHandler
00206 #define AUDIO_DFSDM_DMAx_MIC3_IRQHandler               DMA2_Stream1_IRQHandler
00207 #define AUDIO_DFSDM_DMAx_MIC4_IRQHandler               DMA2_Stream2_IRQHandler
00208 #define AUDIO_DFSDM_DMAx_MIC5_IRQHandler               DMA2_Stream7_IRQHandler
00209 
00210 
00211 /* Select the interrupt preemption priority and subpriority for the IT/DMA interrupt */
00212 #define AUDIO_IN_IRQ_PREPRIO                0x0F   /* Select the preemption priority level(0 is the highest) */
00213 
00214 /* HW defines for Analog mic configuration */
00215 #define AUDIO_IN_I2Sx                           SPI3
00216 #define AUDIO_IN_I2Sx_CLK_ENABLE()              __HAL_RCC_SPI3_CLK_ENABLE()
00217 #define AUDIO_IN_I2Sx_CLK_DISABLE()             __HAL_RCC_SPI3_CLK_DISABLE()
00218 
00219 #define AUDIO_IN_I2Sx_EXT_SD_PIN                GPIO_PIN_4
00220 #define AUDIO_IN_I2Sx_EXT_SD_GPIO_PORT          GPIOB
00221 #define AUDIO_IN_I2Sx_EXT_SD_GPIO_CLK_ENABLE()  __HAL_RCC_GPIOB_CLK_ENABLE()
00222 #define AUDIO_IN_I2Sx_EXT_SD_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
00223 #define AUDIO_IN_I2Sx_EXT_SD_AF                 GPIO_AF7_SPI3
00224 
00225 #define AUDIO_IN_CODEC_INT_PIN                  GPIO_PIN_2
00226 #define AUDIO_IN_CODEC_INT_GPIO_PORT            GPIOG
00227 #define AUDIO_IN_CODEC_INT_GPIO_CLK_ENABLE()    __HAL_RCC_GPIOG_CLK_ENABLE()
00228 #define AUDIO_IN_CODEC_INT_GPIO_CLK_DISABLE()   __HAL_RCC_GPIOG_CLK_DISABLE()
00229 #define AUDIO_IN_CODEC_INT_IRQ                  EXTI2_IRQn
00230 
00231 /* I2S DMA Stream Rx definitions */
00232 #define AUDIO_IN_I2Sx_DMAx_CLK_ENABLE()         __HAL_RCC_DMA1_CLK_ENABLE()
00233 #define AUDIO_IN_I2Sx_DMAx_CLK_DISABLE()        __HAL_RCC_DMA1_CLK_DISABLE()
00234 #define AUDIO_IN_I2Sx_DMAx_STREAM               DMA1_Stream0
00235 #define AUDIO_IN_I2Sx_DMAx_CHANNEL              DMA_CHANNEL_3
00236 #define AUDIO_IN_I2Sx_DMAx_IRQ                  DMA1_Stream0_IRQn
00237 #define AUDIO_IN_I2Sx_DMAx_PERIPH_DATA_SIZE     DMA_PDATAALIGN_HALFWORD
00238 #define AUDIO_IN_I2Sx_DMAx_MEM_DATA_SIZE        DMA_MDATAALIGN_HALFWORD
00239    
00240 #define AUDIO_IN_I2Sx_DMAx_IRQHandler           DMA1_Stream0_IRQHandler
00241 #define AUDIO_IN_I2Sx_DMAx_IRQ                  DMA1_Stream0_IRQn
00242 
00243 /*------------------------------------------------------------------------------
00244              CONFIGURATION: Audio Driver Configuration parameters
00245 ------------------------------------------------------------------------------*/
00246 
00247 #define AUDIODATA_SIZE                      2   /* 16-bits audio data size */
00248 
00249 /* Audio status definition */     
00250 #define AUDIO_OK                            ((uint8_t)0)
00251 #define AUDIO_ERROR                         ((uint8_t)1)
00252 #define AUDIO_TIMEOUT                       ((uint8_t)2)
00253 
00254 /* Audio out parameters */
00255 #define DEFAULT_AUDIO_OUT_FREQ              I2S_AUDIOFREQ_48K
00256 #define DEFAULT_AUDIO_OUT_BIT_RESOLUTION    ((uint8_t)16)
00257 #define DEFAULT_AUDIO_OUT_CHANNEL_NBR       ((uint8_t)2) /* Mono = 1, Stereo = 2 */
00258 #define DEFAULT_AUDIO_OUT_VOLUME            ((uint16_t)64)
00259 
00260 /* Audio in parameters */
00261 #define DEFAULT_AUDIO_IN_FREQ               I2S_AUDIOFREQ_16K
00262 #define DEFAULT_AUDIO_IN_BIT_RESOLUTION     ((uint8_t)16)
00263 #define DEFAULT_AUDIO_IN_CHANNEL_NBR        ((uint8_t)2) /* Mono = 1, Stereo = 2 */
00264 #define DEFAULT_AUDIO_IN_VOLUME             ((uint16_t)64)
00265    
00266 /*------------------------------------------------------------------------------
00267                             OUTPUT DEVICES definition
00268 ------------------------------------------------------------------------------*/
00269 
00270 /* Alias on existing output devices to adapt for 2 headphones output */
00271 #define OUTPUT_DEVICE_HEADPHONE1 OUTPUT_DEVICE_HEADPHONE
00272 #define OUTPUT_DEVICE_HEADPHONE2 OUTPUT_DEVICE_SPEAKER /* Headphone2 is connected to Speaker output of the wm8994 */
00273 
00274 /*------------------------------------------------------------------------------
00275                            INPUT DEVICES definition
00276 ------------------------------------------------------------------------------*/
00277 /* Analog microphone input from 3.5 audio jack connector */    
00278 #define INPUT_DEVICE_ANALOG_MIC        ((uint32_t)0x00000001)     
00279 /* MP34DT01TR digital microphone on PCB top side */
00280 #define INPUT_DEVICE_DIGITAL_MIC1      ((uint32_t)0x00000010)
00281 #define INPUT_DEVICE_DIGITAL_MIC2      ((uint32_t)0x00000020)
00282 #define INPUT_DEVICE_DIGITAL_MIC3      ((uint32_t)0x00000040)
00283 #define INPUT_DEVICE_DIGITAL_MIC4      ((uint32_t)0x00000080)
00284 #define INPUT_DEVICE_DIGITAL_MIC5      ((uint32_t)0x00000100)
00285 #define INPUT_DEVICE_DIGITAL_MIC       ((uint32_t)(INPUT_DEVICE_DIGITAL_MIC1 | INPUT_DEVICE_DIGITAL_MIC2)) 
00286 #define INPUT_DEVICE_DIGITAL_MIC_ALL   ((uint32_t)(INPUT_DEVICE_DIGITAL_MIC1 | INPUT_DEVICE_DIGITAL_MIC2 |\
00287                                                    INPUT_DEVICE_DIGITAL_MIC3 | INPUT_DEVICE_DIGITAL_MIC4 |\
00288                                                    INPUT_DEVICE_DIGITAL_MIC5)) 
00289 
00290 #define DFSDM_MIC_NUMBER               (5)
00291 
00292 /**
00293   * @}
00294   */
00295  
00296 /** @defgroup STM32F413H_DISCOVERY_AUDIO_Exported_Variables  STM32F413H DISCOVERY Audio Exported Variables
00297   * @{
00298   */
00299 extern __IO uint16_t AudioInVolume;
00300  /**
00301   * @}
00302   */
00303    
00304 /** @defgroup STM32F413H_DISCOVERY_AUDIO_Exported_Macros  STM32F413H DISCOVERY Audio Exported Macros
00305   * @{
00306   */
00307 #define DMA_MAX(x)           (((x) <= DMA_MAX_SIZE)? (x):DMA_MAX_SIZE)
00308 #define POS_VAL(VAL)         (POSITION_VAL(VAL) - 4) 
00309 /**
00310   * @}
00311   */ 
00312 
00313 /** @defgroup STM32F413H_DISCOVERY_AUDIO_OUT_Exported_Functions  STM32F413H DISCOVERY Audio OUT Exported Functions
00314   * @{
00315   */
00316 uint8_t BSP_AUDIO_OUT_Init(uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq);
00317 uint8_t BSP_AUDIO_OUT_Play(uint16_t* pBuffer, uint32_t Size);
00318 void    BSP_AUDIO_OUT_ChangeBuffer(uint16_t *pData, uint16_t Size);
00319 uint8_t BSP_AUDIO_OUT_Pause(void);
00320 uint8_t BSP_AUDIO_OUT_Resume(void);
00321 uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option);
00322 uint8_t BSP_AUDIO_OUT_SetVolume(uint8_t Volume);
00323 void    BSP_AUDIO_OUT_SetFrequency(uint32_t AudioFreq);
00324 uint8_t BSP_AUDIO_OUT_SetMute(uint32_t Cmd);
00325 uint8_t BSP_AUDIO_OUT_SetOutputMode(uint8_t Output);
00326 void    BSP_AUDIO_OUT_DeInit(void);
00327 
00328 /* User Callbacks: user has to implement these functions in his code if they are needed. */
00329 /* This function is called when the requested data has been completely transferred.*/
00330 void    BSP_AUDIO_OUT_TransferComplete_CallBack(void);
00331 
00332 /* This function is called when half of the requested buffer has been transferred. */
00333 void    BSP_AUDIO_OUT_HalfTransfer_CallBack(void);
00334 
00335 /* This function is called when an Interrupt due to transfer error on or peripheral
00336    error occurs. */
00337 void    BSP_AUDIO_OUT_Error_CallBack(void);
00338 
00339 /* These function can be modified in case the current settings (e.g. DMA stream)
00340    need to be changed for specific application needs */
00341 void  BSP_AUDIO_OUT_ClockConfig(I2S_HandleTypeDef *hi2s, uint32_t AudioFreq, void *Params);
00342 void  BSP_AUDIO_OUT_MspInit(I2S_HandleTypeDef *hi2s, void *Params);
00343 void  BSP_AUDIO_OUT_MspDeInit(I2S_HandleTypeDef *hi2s, void *Params);
00344 
00345 /**
00346   * @}
00347   */ 
00348 
00349 /** @defgroup STM32F413H_DISCOVERY_AUDIO_IN_Exported_Functions  STM32F413H DISCOVERY AudioIN Exported Functions
00350   * @{
00351   */
00352 uint8_t BSP_AUDIO_IN_Init(uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr);
00353 uint8_t BSP_AUDIO_IN_InitEx(uint32_t InputDevice, uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr);
00354 uint8_t BSP_AUDIO_IN_ConfigMicDefault(uint32_t InputDevice);
00355 uint8_t BSP_AUDIO_IN_ConfigDigitalMic(uint32_t InputDevice, void *Params);    
00356 uint8_t BSP_AUDIO_IN_AllocScratch (int32_t *pScratch, uint32_t size);
00357 uint8_t BSP_AUDIO_IN_Record(uint16_t *pBuf, uint32_t Size);
00358 uint8_t BSP_AUDIO_IN_RecordEx(uint32_t *pBuf, uint32_t Size);
00359 uint8_t BSP_AUDIO_IN_SetFrequency(uint32_t AudioFreq);
00360 uint8_t BSP_AUDIO_IN_Stop(void);
00361 uint8_t BSP_AUDIO_IN_StopEx(uint32_t InputDevice);
00362 uint8_t BSP_AUDIO_IN_Pause(void);
00363 uint8_t BSP_AUDIO_IN_PauseEx(uint32_t InputDevice);
00364 uint8_t BSP_AUDIO_IN_Resume(void);
00365 uint8_t BSP_AUDIO_IN_ResumeEx(uint32_t *pBuf, uint32_t InputDevice);
00366 uint8_t BSP_AUDIO_IN_SetVolume(uint8_t Volume);
00367 void    BSP_AUDIO_IN_DeInit(void);
00368 
00369 /* User Callbacks: user has to implement these functions in his code if they are needed. */
00370 /* This function should be implemented by the user application.
00371    It is called into this driver when the current buffer is filled to prepare the next
00372    buffer pointer and its size. */
00373 void    BSP_AUDIO_IN_TransferComplete_CallBack(void);
00374 void    BSP_AUDIO_IN_HalfTransfer_CallBack(void);
00375 void    BSP_AUDIO_IN_TransferComplete_CallBackEx(uint32_t InputDevice);
00376 void    BSP_AUDIO_IN_HalfTransfer_CallBackEx(uint32_t InputDevice);
00377 
00378 /* This function is called when an Interrupt due to transfer error on or peripheral
00379    error occurs. */
00380 void    BSP_AUDIO_IN_Error_Callback(void);
00381 
00382 /* These function can be modified in case the current settings (e.g. DMA stream)
00383    need to be changed for specific application needs */
00384 uint8_t BSP_AUDIO_IN_ClockConfig(uint32_t AudioFreq, void *Params);
00385 void    BSP_AUDIO_IN_MspInit(void *Params);
00386 void    BSP_AUDIO_IN_MspDeInit(void *Params);
00387 
00388 /**
00389   * @}
00390   */ 
00391 
00392 /**
00393   * @}
00394   */ 
00395 
00396 /**
00397   * @}
00398   */
00399 
00400 /**
00401   * @}
00402   */
00403 
00404 #ifdef __cplusplus
00405 }
00406 #endif
00407 
00408 #endif /* __STM32F413H_DISCOVERY_AUDIO_H */
00409 
00410 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/