Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: DISCO_L4R9I-LCD-demo
stm32l4r9i_discovery_audio.h
00001 /** 00002 ****************************************************************************** 00003 * @file stm32l4r9i_discovery_audio.h 00004 * @author MCD Application Team 00005 * @brief This file contains the common defines and functions prototypes for 00006 * the stm32l4r9i_discovery_audio.c driver. 00007 ****************************************************************************** 00008 * @attention 00009 * 00010 * <h2><center>© Copyright (c) 2017 STMicroelectronics. 00011 * All rights reserved.</center></h2> 00012 * 00013 * This software component is licensed by ST under BSD 3-Clause license, 00014 * the "License"; You may not use this file except in compliance with the 00015 * License. You may obtain a copy of the License at: 00016 * opensource.org/licenses/BSD-3-Clause 00017 * 00018 ****************************************************************************** 00019 */ 00020 00021 /* Define to prevent recursive inclusion -------------------------------------*/ 00022 #ifndef __STM32L4R9I_DISCOVERY_AUDIO_H 00023 #define __STM32L4R9I_DISCOVERY_AUDIO_H 00024 00025 #ifdef __cplusplus 00026 extern "C" { 00027 #endif 00028 00029 /* Includes ------------------------------------------------------------------*/ 00030 #if defined(BSP_AUDIO_USE_RTOS) 00031 #include "k_mem.h" 00032 #else 00033 #include <stdlib.h> 00034 #endif 00035 /* Include audio component Driver */ 00036 #include "../Components/cs42l51/cs42l51.h" 00037 #include "stm32l4r9i_discovery.h" 00038 00039 /** @addtogroup BSP 00040 * @{ 00041 */ 00042 00043 /** @addtogroup STM32L4R9I_DISCOVERY 00044 * @{ 00045 */ 00046 00047 /** @addtogroup STM32L4R9I_DISCOVERY_AUDIO 00048 * @{ 00049 */ 00050 00051 /** @defgroup STM32L4R9I_DISCOVERY_AUDIO_Exported_Types Exported Types 00052 * @{ 00053 */ 00054 typedef void (*Audio_CallbackTypeDef)(void); 00055 00056 /** 00057 * @} 00058 */ 00059 00060 /** @defgroup STM32L4R9I_DISCOVERY_AUDIO_Exported_Constants Exported Constants 00061 * @{ 00062 */ 00063 /** @defgroup BSP_Audio_Out_Option BSP Audio Out Option 00064 * @{ 00065 */ 00066 #define BSP_AUDIO_OUT_CIRCULARMODE ((uint32_t)0x00000001) /* BUFFER CIRCULAR MODE */ 00067 #define BSP_AUDIO_OUT_NORMALMODE ((uint32_t)0x00000002) /* BUFFER NORMAL MODE */ 00068 #define BSP_AUDIO_OUT_STEREOMODE ((uint32_t)0x00000004) /* STEREO MODE */ 00069 #define BSP_AUDIO_OUT_MONOMODE ((uint32_t)0x00000008) /* MONO MODE */ 00070 /** 00071 * @} 00072 */ 00073 00074 /** @defgroup BSP_Audio_Sample_Rate BSP Audio Sample Rate 00075 * @{ 00076 */ 00077 #define BSP_AUDIO_FREQUENCY_96K SAI_AUDIO_FREQUENCY_96K 00078 #define BSP_AUDIO_FREQUENCY_48K SAI_AUDIO_FREQUENCY_48K 00079 #define BSP_AUDIO_FREQUENCY_44K SAI_AUDIO_FREQUENCY_44K 00080 #define BSP_AUDIO_FREQUENCY_32K SAI_AUDIO_FREQUENCY_32K 00081 #define BSP_AUDIO_FREQUENCY_22K SAI_AUDIO_FREQUENCY_22K 00082 #define BSP_AUDIO_FREQUENCY_16K SAI_AUDIO_FREQUENCY_16K 00083 #define BSP_AUDIO_FREQUENCY_11K SAI_AUDIO_FREQUENCY_11K 00084 #define BSP_AUDIO_FREQUENCY_8K SAI_AUDIO_FREQUENCY_8K 00085 /** 00086 * @} 00087 */ 00088 /*------------------------------------------------------------------------------ 00089 USER SAI defines parameters 00090 -----------------------------------------------------------------------------*/ 00091 /* SAI DMA Channel definitions */ 00092 #define DMA_MAX_SZE (uint32_t)0xFFFF 00093 00094 /* Disable SAIx PLL */ 00095 #define AUDIO_SAIx_PLL_DISABLE() HAL_RCCEx_DisablePLLSAI1() 00096 00097 /*------------------------------------------------------------------------------ 00098 CONFIGURATION: Audio Driver Configuration parameters 00099 ------------------------------------------------------------------------------*/ 00100 00101 #define AUDIODATA_SIZE 2 /* 16-bits audio data size */ 00102 00103 /* Audio status definition */ 00104 #define AUDIO_OK 0 00105 #define AUDIO_ERROR 1 00106 #define AUDIO_TIMEOUT 2 00107 00108 /* Audio out parameters */ 00109 #define DEFAULT_AUDIO_OUT_FREQ BSP_AUDIO_FREQUENCY_48K 00110 #define DEFAULT_AUDIO_OUT_BIT_RESOLUTION ((uint8_t)16) 00111 #define DEFAULT_AUDIO_OUT_CHANNEL_NBR ((uint8_t)2) /* Mono = 1, Stereo = 2 */ 00112 #define DEFAULT_AUDIO_OUT_VOLUME ((uint16_t)80) 00113 00114 /* AudioFreq * DataSize (2 bytes) * NumChannels (Stereo: 2) */ 00115 #define DEFAULT_AUDIO_IN_FREQ BSP_AUDIO_FREQUENCY_16K 00116 #define DEFAULT_AUDIO_IN_BIT_RESOLUTION 16 00117 #define DEFAULT_AUDIO_IN_CHANNEL_NBR 1 /* Mono = 1, Stereo = 2 */ 00118 #define DEFAULT_AUDIO_IN_VOLUME 80 00119 00120 /*------------------------------------------------------------------------------ 00121 OPTIONAL Configuration defines parameters 00122 ------------------------------------------------------------------------------*/ 00123 00124 /* Delay for the Codec to be correctly reset */ 00125 #define CODEC_RESET_DELAY 5 00126 00127 /*------------------------------------------------------------------------------ 00128 INPUT DEVICES definition 00129 ------------------------------------------------------------------------------*/ 00130 /* MP34DT01TR digital microphone on PCB top side */ 00131 #define INPUT_DEVICE_DIGITAL_MIC1 0x20 /* Left microphone */ 00132 #define INPUT_DEVICE_DIGITAL_MIC2 0x40 /* Right microphone */ 00133 #define INPUT_DEVICE_DIGITAL_MIC (INPUT_DEVICE_DIGITAL_MIC1 | INPUT_DEVICE_DIGITAL_MIC2) 00134 /* Analog microphone input from 3.5 audio jack connector */ 00135 #define INPUT_DEVICE_ANALOG_MIC INPUT_DEVICE_MIC1 00136 00137 /** 00138 * @} 00139 */ 00140 00141 /** @defgroup STM32L4R9I_DISCOVERY_AUDIO_Exported_Variables Exported Variables 00142 * @{ 00143 */ 00144 extern SAI_HandleTypeDef BSP_AUDIO_hSai_Tx; 00145 extern SAI_HandleTypeDef BSP_AUDIO_hSai_Rx; 00146 extern DFSDM_Filter_HandleTypeDef BSP_AUDIO_hDfsdmLeftFilter; 00147 extern DFSDM_Filter_HandleTypeDef BSP_AUDIO_hDfsdmRightFilter; 00148 00149 /** 00150 * @} 00151 */ 00152 00153 /** @defgroup STM32L4R9I_DISCOVERY_AUDIO_Exported_Macros Exported Macros 00154 * @{ 00155 */ 00156 #define DMA_MAX(_X_) (((_X_) <= DMA_MAX_SZE)? (_X_):DMA_MAX_SZE) 00157 00158 /** 00159 * @} 00160 */ 00161 00162 /* Exported functions --------------------------------------------------------*/ 00163 /** @defgroup STM32L4R9I_DISCOVERY_AUDIO_Exported_Functions Exported Functions 00164 * @{ 00165 */ 00166 uint8_t BSP_AUDIO_OUT_Init(uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq); 00167 uint8_t BSP_AUDIO_OUT_DeInit(void); 00168 uint8_t BSP_AUDIO_OUT_Play(uint16_t* pData, uint32_t Size); 00169 uint8_t BSP_AUDIO_OUT_ChangeBuffer(uint16_t *pData, uint16_t Size); 00170 uint8_t BSP_AUDIO_OUT_Pause(void); 00171 uint8_t BSP_AUDIO_OUT_Resume(void); 00172 uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option); 00173 uint8_t BSP_AUDIO_OUT_SetVolume(uint8_t Volume); 00174 uint8_t BSP_AUDIO_OUT_SetFrequency(uint32_t AudioFreq); 00175 void BSP_AUDIO_OUT_ChangeAudioConfig(uint32_t AudioOutOption); 00176 uint8_t BSP_AUDIO_OUT_SetMute(uint32_t Cmd); 00177 uint8_t BSP_AUDIO_OUT_SetOutputMode(uint8_t Output); 00178 void BSP_AUDIO_OUT_RegisterCallbacks(Audio_CallbackTypeDef ErrorCallback, 00179 Audio_CallbackTypeDef HalfTransferCallback, 00180 Audio_CallbackTypeDef TransferCompleteCallback); 00181 00182 uint8_t BSP_AUDIO_IN_Init(uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr); 00183 uint8_t BSP_AUDIO_IN_InitEx(uint16_t InputDevice, uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr); 00184 uint8_t BSP_AUDIO_IN_DeInit(void); 00185 uint8_t BSP_AUDIO_IN_Record(uint16_t *pData, uint32_t Size); 00186 uint8_t BSP_AUDIO_IN_SetFrequency(uint32_t AudioFreq); 00187 uint8_t BSP_AUDIO_IN_Stop(void); 00188 uint8_t BSP_AUDIO_IN_Pause(void); 00189 uint8_t BSP_AUDIO_IN_Resume(void); 00190 void BSP_AUDIO_IN_RegisterCallbacks(Audio_CallbackTypeDef ErrorCallback, 00191 Audio_CallbackTypeDef HalfTransferCallback, 00192 Audio_CallbackTypeDef TransferCompleteCallback); 00193 /** 00194 * @} 00195 */ 00196 00197 /** 00198 * @} 00199 */ 00200 00201 /** 00202 * @} 00203 */ 00204 00205 /** 00206 * @} 00207 */ 00208 00209 #ifdef __cplusplus 00210 } 00211 #endif 00212 00213 #endif /* __STM32L4R9I_DISCOVERY_AUDIO_H */ 00214 00215 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Generated on Wed Jul 13 2022 19:15:17 by
