stm32h747i_discovery_audio.h
Go to the documentation of this file.
1 
21 /* Define to prevent recursive inclusion -------------------------------------*/
22 #ifndef STM32H747I_DISCO_AUDIO_H
23 #define STM32H747I_DISCO_AUDIO_H
24 
25 #ifdef __cplusplus
26  extern "C" {
27 #endif
28 
29 /* Includes ------------------------------------------------------------------*/
32 
33 #if (USE_AUDIO_CODEC_WM8994 > 0U)
34 /* Include audio component Driver */
35 #include "../Components/wm8994/wm8994.h"
36 #endif
37 #include "../Components/Common/audio.h"
38 
39 /* Include PDM to PCM lib header file */
40 #include "pdm2pcm_glo.h"
56 typedef struct
57 {
58  uint32_t Device;
59  uint32_t SampleRate;
60  uint32_t BitsPerSample;
61  uint32_t ChannelsNbr;
62  uint32_t Volume;
64 
65 typedef struct
66 {
67  uint32_t Instance; /* Audio IN instance */
68  uint32_t Device; /* Audio IN device to be used */
69  uint32_t SampleRate; /* Audio IN Sample rate */
70  uint32_t BitsPerSample; /* Audio IN Sample resolution */
71  uint32_t ChannelsNbr; /* Audio IN number of channel */
72  uint16_t *pBuff; /* Audio IN record buffer */
73  uint8_t **pMultiBuff; /* Audio IN multi-buffer */
74  uint32_t Size; /* Audio IN record buffer size */
75  uint32_t Volume; /* Audio IN volume */
76  uint32_t State; /* Audio IN State */
77  uint32_t IsMultiBuff; /* Audio IN multi-buffer usage */
78  uint32_t IsMspCallbacksValid; /* Is Msp Callbacks registred */
80 
81 typedef struct
82 {
83  uint32_t Instance; /* Audio OUT instance */
84  uint32_t Device; /* Audio OUT device to be used */
85  uint32_t SampleRate; /* Audio OUT Sample rate */
86  uint32_t BitsPerSample; /* Audio OUT Sample Bit Per Sample */
87  uint32_t Volume; /* Audio OUT volume */
88  uint32_t ChannelsNbr; /* Audio OUT number of channel */
89  uint32_t IsMute; /* Mute state */
90  uint32_t State; /* Audio OUT State */
91  uint32_t IsMspCallbacksValid; /* Is Msp Callbacks registred */
93 
94 typedef struct
95 {
96  uint32_t AudioFrequency;
97  uint32_t AudioMode;
98  uint32_t DataSize;
99  uint32_t MonoStereoMode;
100  uint32_t ClockStrobing;
101  uint32_t Synchro;
102  uint32_t OutputDrive;
103  uint32_t SynchroExt;
104  uint32_t FrameLength;
106  uint32_t SlotActive;
108 
109 
110 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
111 typedef struct
112 {
113  pSAI_CallbackTypeDef pMspSaiInitCb;
114  pSAI_CallbackTypeDef pMspSaiDeInitCb;
115 }BSP_AUDIO_OUT_Cb_t;
116 #endif /* (USE_HAL_SAI_REGISTER_CALLBACKS == 1) */
117 
118 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
119 typedef struct
120 {
121 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
122  void (* pMspSaiInitCb )(SAI_HandleTypeDef *);
123  void (* pMspSaiDeInitCb)(SAI_HandleTypeDef *);
124 #endif
125 }BSP_AUDIO_IN_Cb_t;
126 #endif /*(USE_HAL_SAI_REGISTER_CALLBACKS == 1) */
127 
135 /* Audio codec I2C address */
136 #define AUDIO_I2C_ADDRESS 0x34U
137 
138 /* Audio Out instances number */
139 #define AUDIO_OUT_INSTANCES_NBR 2U
140 
141 /* AUDIO FREQUENCY */
142 #define AUDIO_FREQUENCY_192K 192000U
143 #define AUDIO_FREQUENCY_176K 176400U
144 #define AUDIO_FREQUENCY_96K 96000U
145 #define AUDIO_FREQUENCY_88K 88200U
146 #define AUDIO_FREQUENCY_48K 48000U
147 #define AUDIO_FREQUENCY_44K 44100U
148 #define AUDIO_FREQUENCY_32K 32000U
149 #define AUDIO_FREQUENCY_22K 22050U
150 #define AUDIO_FREQUENCY_16K 16000U
151 #define AUDIO_FREQUENCY_11K 11025U
152 #define AUDIO_FREQUENCY_8K 8000U
153 
154 /* AUDIO RESOLUTION */
155 #define AUDIO_RESOLUTION_16B 16U
156 #define AUDIO_RESOLUTION_32B 32U
157 
158 /* Audio Out devices */
159 #define AUDIO_OUT_DEVICE_NONE 0U
160 #define AUDIO_OUT_DEVICE_SPEAKER 1U
161 #define AUDIO_OUT_DEVICE_HEADPHONE 2U
162 #define AUDIO_OUT_DEVICE_SPK_HP 3U
163 #define AUDIO_OUT_DEVICE_AUTO 4U
164 #define AUDIO_OUT_DEVICE_HDMI 5U
165 
166 /* Audio Mute state */
167 #define BSP_AUDIO_MUTE_DISABLED 0U
168 #define BSP_AUDIO_MUTE_ENABLED 1U
169 
170 /* Audio Out states */
171 #define AUDIO_OUT_STATE_RESET 0U
172 #define AUDIO_OUT_STATE_PLAYING 1U
173 #define AUDIO_OUT_STATE_STOP 2U
174 #define AUDIO_OUT_STATE_PAUSE 3U
175 
176 /* Audio Out states */
177 /* Volume Input Output selection */
178 #define AUDIO_VOLUME_INPUT 0U
179 #define AUDIO_VOLUME_OUTPUT 1U
180 
181 /* Codec commands */
182 #define CODEC_PDWN_SW 1U
183 #define CODEC_MUTE_ON 1U
184 #define CODEC_MUTE_OFF 0U
185 
186 /*------------------------------------------------------------------------------
187  USER SAI defines parameters
188  -----------------------------------------------------------------------------*/
195 /* To have 2 separate audio stream in Both headphone and speaker the 4 slot must be activated */
196 #define CODEC_AUDIOFRAME_SLOT_0123 SAI_SLOTACTIVE_0 | SAI_SLOTACTIVE_1 | SAI_SLOTACTIVE_2 | SAI_SLOTACTIVE_3
197 /* To have an audio stream in headphone only SAI Slot 0 and Slot 2 must be activated */
198 #define CODEC_AUDIOFRAME_SLOT_02 SAI_SLOTACTIVE_0 | SAI_SLOTACTIVE_2
199 /* To have an audio stream in speaker only SAI Slot 1 and Slot 3 must be activated */
200 #define CODEC_AUDIOFRAME_SLOT_13 SAI_SLOTACTIVE_1 | SAI_SLOTACTIVE_3
201 
202 /* SAI peripheral configuration defines */
203 #define AUDIO_OUT_SAIx SAI1_Block_A
204 #define AUDIO_OUT_SAIx_CLK_ENABLE() __HAL_RCC_SAI1_CLK_ENABLE()
205 #define AUDIO_OUT_SAIx_CLK_DISABLE() __HAL_RCC_SAI1_CLK_DISABLE()
206 
207 #define AUDIO_OUT_SAIx_MCLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE()
208 #define AUDIO_OUT_SAIx_MCLK_GPIO_PORT GPIOG
209 #define AUDIO_OUT_SAIx_MCLK_PIN GPIO_PIN_7
210 #define AUDIO_OUT_SAIx_MCLK_AF GPIO_AF6_SAI1
211 
212 #define AUDIO_OUT_SAIx_SCK_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE()
213 #define AUDIO_OUT_SAIx_SCK_GPIO_PORT GPIOE
214 #define AUDIO_OUT_SAIx_SCK_PIN GPIO_PIN_5
215 #define AUDIO_OUT_SAIx_SCK_AF GPIO_AF6_SAI1
216 
217 #define AUDIO_OUT_SAIx_SD_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE()
218 #define AUDIO_OUT_SAIx_SD_GPIO_PORT GPIOE
219 #define AUDIO_OUT_SAIx_SD_PIN GPIO_PIN_6
220 #define AUDIO_OUT_SAIx_SD_AF GPIO_AF6_SAI1
221 
222 #define AUDIO_OUT_SAIx_FS_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE()
223 #define AUDIO_OUT_SAIx_FS_GPIO_PORT GPIOE
224 #define AUDIO_OUT_SAIx_FS_PIN GPIO_PIN_4
225 #define AUDIO_OUT_SAIx_FS_AF GPIO_AF6_SAI1
226 
227 /* SAI DMA Stream definitions */
228 #define AUDIO_OUT_SAIx_DMAx_CLK_ENABLE() __HAL_RCC_DMA2_CLK_ENABLE()
229 #define AUDIO_OUT_SAIx_DMAx_STREAM DMA2_Stream1
230 #define AUDIO_OUT_SAIx_DMAx_REQUEST DMA_REQUEST_SAI1_A
231 #define AUDIO_OUT_SAIx_DMAx_IRQ DMA2_Stream1_IRQn
232 #define AUDIO_OUT_SAIx_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD
233 #define AUDIO_OUT_SAIx_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD
234 #define AUDIO_OUT_SAIx_DMAx_IRQHandler DMA2_Stream1_IRQHandler
235 
236 /*------------------------------------------------------------------------------
237  AUDIO IN defines parameters
238 ------------------------------------------------------------------------------*/
239 /* SAI peripheral configuration defines */
240 #define AUDIO_IN_SAIx SAI1_Block_B
241 #define AUDIO_IN_SAIx_CLK_ENABLE() __HAL_RCC_SAI1_CLK_ENABLE()
242 #define AUDIO_IN_SAIx_CLK_DISABLE() __HAL_RCC_SAI1_CLK_DISABLE()
243 #define AUDIO_IN_SAIx_AF GPIO_AF6_SAI1
244 #define AUDIO_IN_SAIx_SD_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE()
245 #define AUDIO_IN_SAIx_SD_GPIO_PORT GPIOE
246 #define AUDIO_IN_SAIx_SD_PIN GPIO_PIN_3
247 
248 /* SAI DMA Stream definitions */
249 #define AUDIO_IN_SAIx_DMAx_CLK_ENABLE() __HAL_RCC_DMA2_CLK_ENABLE()
250 #define AUDIO_IN_SAIx_DMAx_STREAM DMA2_Stream4
251 #define AUDIO_IN_SAIx_DMAx_REQUEST DMA_REQUEST_SAI1_B
252 #define AUDIO_IN_SAIx_DMAx_IRQ DMA2_Stream4_IRQn
253 #define AUDIO_IN_SAIx_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD
254 #define AUDIO_IN_SAIx_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD
255 
256 #define AUDIO_IN_SAIx_DMAx_IRQHandler DMA2_Stream4_IRQHandler
257 
258 #define AUDIO_IN_INT_GPIO_ENABLE() __HAL_RCC_GPIOJ_CLK_ENABLE()
259 #define AUDIO_IN_INT_GPIO_PORT GPIOJ
260 #define AUDIO_IN_INT_GPIO_PIN GPIO_PIN_15
261 #define AUDIO_IN_INT_IRQ EXTI15_10_IRQn
262 
263 /* SAI PDM input definitions */
264 #define AUDIO_IN_SAI_PDMx SAI4_Block_A
265 #define AUDIO_IN_SAI_PDMx_CLK_ENABLE() __HAL_RCC_SAI4_CLK_ENABLE()
266 #define AUDIO_IN_SAI_PDMx_CLK_DISABLE() __HAL_RCC_SAI4_CLK_DISABLE()
267 #define AUDIO_IN_SAI_PDMx_FS_SCK_AF GPIO_AF8_SAI4
268 #define AUDIO_IN_SAI_PDMx_FS_SCK_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE()
269 #define AUDIO_IN_SAI_PDMx_FS_SCK_GPIO_PORT GPIOE
270 #define AUDIO_IN_SAI_PDMx_FS_PIN GPIO_PIN_4
271 #define AUDIO_IN_SAI_PDMx_SCK_PIN GPIO_PIN_5
272 
273 #define AUDIO_IN_SAI_PDMx_CLK_IN_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE()
274 #define AUDIO_IN_SAI_PDMx_CLK_IN_PIN GPIO_PIN_2
275 #define AUDIO_IN_SAI_PDMx_CLK_IN_PORT GPIOE
276 #define AUDIO_IN_SAI_PDMx_DATA_IN_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
277 #define AUDIO_IN_SAI_PDMx_DATA_IN_PIN GPIO_PIN_1
278 #define AUDIO_IN_SAI_PDMx_DATA_IN_PORT GPIOC
279 #define AUDIO_IN_SAI_PDMx_DATA_CLK_AF GPIO_AF10_SAI4
280 #define AUDIO_IN_SAI_PDMx_IRQHandler SAI4_IRQHandler
281 #define AUDIO_IN_SAI_PDMx_IRQ SAI4_IRQn
282 
283 /* SAI PDM DMA Stream definitions */
284 #define AUDIO_IN_SAI_PDMx_DMAx_CLK_ENABLE() __HAL_RCC_BDMA_CLK_ENABLE()
285 #define AUDIO_IN_SAI_PDMx_DMAx_STREAM BDMA_Channel1
286 #define AUDIO_IN_SAI_PDMx_DMAx_REQUEST BDMA_REQUEST_SAI4_A
287 #define AUDIO_IN_SAI_PDMx_DMAx_IRQ BDMA_Channel1_IRQn
288 #define AUDIO_IN_SAI_PDMx_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD
289 #define AUDIO_IN_SAI_PDMx_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD
290 #define AUDIO_IN_SAI_PDMx_DMAx_IRQHandler BDMA_Channel1_IRQHandler
291 
292 /* Audio In devices */
293 
294 /* Analog microphone input from 3.5 audio jack connector */
295 #define AUDIO_IN_DEVICE_ANALOG_MIC 0x00U
296 /* MP34DT01TR digital microphone on PCB top side */
297 #define AUDIO_IN_DEVICE_DIGITAL_MIC 0x10U
298 
299 /* Audio In states */
300 #define AUDIO_IN_STATE_RESET 0U
301 #define AUDIO_IN_STATE_RECORDING 1U
302 #define AUDIO_IN_STATE_STOP 2U
303 #define AUDIO_IN_STATE_PAUSE 3U
304 
305 /* Audio In instances number:
306  Instance 0 is SAI path
307  Instance 2 is SAI PDM path
308  */
309 #define AUDIO_IN_INSTANCES_NBR 2U
310 
317 #define POS_VAL(VAL) (POSITION_VAL(VAL) - 4)
318 #define VOLUME_OUT_CONVERT(Volume) (((Volume) > 100)? 63:((uint8_t)(((Volume) * 63) / 100)))
319 #define VOLUME_IN_CONVERT(Volume) (((Volume) >= 100)? 239:((uint8_t)(((Volume) * 239) / 100)))
320 
328 /* Audio in and out component object */
329 extern void *Audio_CompObj;
330 /* Play */
333 
334 /* Audio in and out component object */
335 extern void *Audio_CompObj;
336 
346 int32_t BSP_AUDIO_OUT_Init(uint32_t Instance, BSP_AUDIO_Init_t* AudioInit);
347 int32_t BSP_AUDIO_OUT_DeInit(uint32_t Instance);
348 
349 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1U)
350 int32_t BSP_AUDIO_OUT_RegisterMspCallbacks (uint32_t Instance, BSP_AUDIO_OUT_Cb_t *CallBacks);
351 int32_t BSP_AUDIO_OUT_RegisterDefaultMspCallbacks (uint32_t Instance);
352 #endif /* (USE_HAL_SAI_REGISTER_CALLBACKS == 1U) */
353 int32_t BSP_AUDIO_OUT_Play(uint32_t Instance, uint8_t* pData, uint32_t NbrOfBytes);
354 int32_t BSP_AUDIO_OUT_Pause(uint32_t Instance);
355 int32_t BSP_AUDIO_OUT_Resume(uint32_t Instance);
356 int32_t BSP_AUDIO_OUT_Stop(uint32_t Instance);
357 int32_t BSP_AUDIO_OUT_Mute(uint32_t Instance);
358 int32_t BSP_AUDIO_OUT_UnMute(uint32_t Instance);
359 int32_t BSP_AUDIO_OUT_IsMute(uint32_t Instance, uint32_t *IsMute);
360 int32_t BSP_AUDIO_OUT_SetDevice(uint32_t Instance, uint32_t Device);
361 int32_t BSP_AUDIO_OUT_GetDevice(uint32_t Instance, uint32_t *Device);
362 int32_t BSP_AUDIO_OUT_SetSampleRate(uint32_t Instance, uint32_t SampleRate);
363 int32_t BSP_AUDIO_OUT_GetSampleRate(uint32_t Instance, uint32_t *SampleRate);
364 int32_t BSP_AUDIO_OUT_SetBitsPerSample(uint32_t Instance, uint32_t BitsPerSample);
365 int32_t BSP_AUDIO_OUT_GetBitsPerSample(uint32_t Instance, uint32_t *BitsPerSample);
366 int32_t BSP_AUDIO_OUT_SetChannelsNbr(uint32_t Instance, uint32_t ChannelNbr);
367 int32_t BSP_AUDIO_OUT_GetChannelsNbr(uint32_t Instance, uint32_t *ChannelNbr);
368 int32_t BSP_AUDIO_OUT_SetVolume(uint32_t Instance, uint32_t Volume);
369 int32_t BSP_AUDIO_OUT_GetVolume(uint32_t Instance, uint32_t *Volume);
370 int32_t BSP_AUDIO_OUT_GetState(uint32_t Instance, uint32_t *State);
371 
372 void BSP_AUDIO_OUT_IRQHandler(uint32_t Instance);
373 
374 /* User Callbacks: user has to implement these functions in his code if they are needed. */
375 /* This function is called when the requested data has been completely transferred.*/
376 void BSP_AUDIO_OUT_TransferComplete_CallBack(uint32_t Instance);
377 
378 /* This function is called when half of the requested buffer has been transferred. */
379 void BSP_AUDIO_OUT_HalfTransfer_CallBack(uint32_t Instance);
380 
381 /* This function is called when an Interrupt due to transfer error on or peripheral
382  error occurs. */
383 void BSP_AUDIO_OUT_Error_CallBack(uint32_t Instance);
384 
385 /* These function can be modified in case the current settings need to be changed
386  for specific application needs */
387 HAL_StatusTypeDef MX_SAI1_ClockConfig(SAI_HandleTypeDef *hsai, uint32_t SampleRate);
388 HAL_StatusTypeDef MX_SAI4_ClockConfig(SAI_HandleTypeDef *hsai, uint32_t SampleRate);
397 int32_t BSP_AUDIO_IN_Init(uint32_t Instance, BSP_AUDIO_Init_t* AudioInit);
398 int32_t BSP_AUDIO_IN_DeInit(uint32_t Instance);
399 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
400 int32_t BSP_AUDIO_IN_RegisterDefaultMspCallbacks (uint32_t Instance);
401 int32_t BSP_AUDIO_IN_RegisterMspCallbacks (uint32_t Instance, BSP_AUDIO_IN_Cb_t *CallBacks);
402 #endif /*(USE_HAL_SAI_REGISTER_CALLBACKS == 1) */
403 int32_t BSP_AUDIO_IN_Record(uint32_t Instance, uint8_t* pBuf, uint32_t NbrOfBytes);
404 int32_t BSP_AUDIO_IN_Stop(uint32_t Instance);
405 int32_t BSP_AUDIO_IN_Pause(uint32_t Instance);
406 int32_t BSP_AUDIO_IN_Resume(uint32_t Instance);
407 int32_t BSP_AUDIO_IN_SetDevice(uint32_t Instance, uint32_t Device);
408 int32_t BSP_AUDIO_IN_GetDevice(uint32_t Instance, uint32_t *Device);
409 int32_t BSP_AUDIO_IN_SetSampleRate(uint32_t Instance, uint32_t SampleRate);
410 int32_t BSP_AUDIO_IN_GetSampleRate(uint32_t Instance, uint32_t *SampleRate);
411 int32_t BSP_AUDIO_IN_SetBitsPerSample(uint32_t Instance, uint32_t BitsPerSample);
412 int32_t BSP_AUDIO_IN_GetBitsPerSample(uint32_t Instance, uint32_t *BitsPerSample);
413 int32_t BSP_AUDIO_IN_SetChannelsNbr(uint32_t Instance, uint32_t ChannelNbr);
414 int32_t BSP_AUDIO_IN_GetChannelsNbr(uint32_t Instance, uint32_t *ChannelNbr);
415 int32_t BSP_AUDIO_IN_SetVolume(uint32_t Instance, uint32_t Volume);
416 int32_t BSP_AUDIO_IN_GetVolume(uint32_t Instance, uint32_t *Volume);
417 int32_t BSP_AUDIO_IN_GetState(uint32_t Instance, uint32_t *State);
418 
419 /* Specific PDM recodr APIs */
420 int32_t BSP_AUDIO_IN_PDMToPCM_Init(uint32_t Instance, uint32_t AudioFreq, uint32_t ChnlNbrIn, uint32_t ChnlNbrOut);
421 int32_t BSP_AUDIO_IN_PDMToPCM(uint32_t Instance, uint16_t *PDMBuf, uint16_t *PCMBuf);
422 int32_t BSP_AUDIO_IN_RecordPDM(uint32_t Instance, uint8_t* pBuf, uint32_t NbrOfBytes);
423 void BSP_AUDIO_IN_IRQHandler(uint32_t Instance, uint32_t InputDevice);
424 /* User Callbacks: user has to implement these functions in his code if they are needed. */
425 /* This function should be implemented by the user application.
426  It is called into this driver when the current buffer is filled to prepare the next
427  buffer pointer and its size. */
428 void BSP_AUDIO_IN_TransferComplete_CallBack(uint32_t Instance);
429 void BSP_AUDIO_IN_HalfTransfer_CallBack(uint32_t Instance);
430 
431 /* This function is called when an Interrupt due to transfer error on or peripheral
432  error occurs. */
433 void BSP_AUDIO_IN_Error_CallBack(uint32_t Instance);
434 /* These function can be modified in case the current settings (e.g. DMA stream)
435  need to be changed for specific application needs */
438 
455 #ifdef __cplusplus
456 }
457 #endif
458 
459 #endif /* STM32H747I_DISCO_AUDIO_H */
460 
461 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
AUDIO_OUT_Ctx_t
Definition: stm32h747i_discovery_audio.h:81
BSP_AUDIO_OUT_SetVolume
uint8_t BSP_AUDIO_OUT_SetVolume(uint8_t Volume)
Controls the current audio volume level.
Definition: stm32f4_discovery_audio.c:381
BSP_AUDIO_IN_SetVolume
uint8_t BSP_AUDIO_IN_SetVolume(uint8_t Volume)
Controls the audio in volume level.
Definition: stm32f4_discovery_audio.c:799
BSP_AUDIO_Init_t::SampleRate
uint32_t SampleRate
Definition: stm32h747i_discovery_audio.h:59
BSP_AUDIO_Init_t
Definition: stm32h747i_discovery_audio.h:56
HAL_StatusTypeDef
HAL_StatusTypeDef
HAL Status structures definition
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:40
BSP_AUDIO_IN_PDMToPCM
uint8_t BSP_AUDIO_IN_PDMToPCM(uint16_t *PDMBuf, uint16_t *PCMBuf)
Converts audio format from PDM to PCM.
Definition: stm32f4_discovery_audio.c:814
MX_SAI_Config_t::ClockStrobing
uint32_t ClockStrobing
Definition: stm32h747i_discovery_audio.h:100
BSP_AUDIO_IN_SetDevice
int32_t BSP_AUDIO_IN_SetDevice(uint32_t Instance, uint32_t Device)
Set Audio In device.
Definition: stm32h747i_discovery_audio.c:2110
BSP_AUDIO_OUT_GetSampleRate
int32_t BSP_AUDIO_OUT_GetSampleRate(uint32_t Instance, uint32_t *SampleRate)
Get the audio frequency.
Definition: stm32h747i_discovery_audio.c:1041
BSP_AUDIO_OUT_Pause
uint8_t BSP_AUDIO_OUT_Pause(void)
Pauses the audio file stream. In case of using DMA, the DMA Pause feature is used....
Definition: stm32f4_discovery_audio.c:301
BSP_AUDIO_OUT_Mute
int32_t BSP_AUDIO_OUT_Mute(uint32_t Instance)
Enables the MUTE.
Definition: stm32h747i_discovery_audio.c:833
MX_SAI_Config_t::FrameLength
uint32_t FrameLength
Definition: stm32h747i_discovery_audio.h:104
BSP_AUDIO_IN_Stop
uint8_t BSP_AUDIO_IN_Stop(void)
Stops audio recording.
Definition: stm32f4_discovery_audio.c:754
BSP_AUDIO_IN_SetChannelsNbr
int32_t BSP_AUDIO_IN_SetChannelsNbr(uint32_t Instance, uint32_t ChannelNbr)
Set Audio In Channel number.
Definition: stm32h747i_discovery_audio.c:2291
BSP_AUDIO_Init_t::ChannelsNbr
uint32_t ChannelsNbr
Definition: stm32h747i_discovery_audio.h:61
AUDIO_OUT_Ctx_t::Device
uint32_t Device
Definition: stm32h747i_discovery_audio.h:84
BSP_AUDIO_IN_DeInit
void BSP_AUDIO_IN_DeInit(void)
Deinit the audio IN peripherals.
Definition: stm32469i_discovery_audio.c:1036
AUDIO_OUT_Ctx_t::Volume
uint32_t Volume
Definition: stm32h747i_discovery_audio.h:87
AUDIO_OUT_Ctx_t::IsMspCallbacksValid
uint32_t IsMspCallbacksValid
Definition: stm32h747i_discovery_audio.h:91
haudio_out_sai
SAI_HandleTypeDef haudio_out_sai
Definition: stm32469i_discovery_audio.c:170
BSP_AUDIO_IN_GetVolume
int32_t BSP_AUDIO_IN_GetVolume(uint32_t Instance, uint32_t *Volume)
Get the current audio in volume level.
Definition: stm32h747i_discovery_audio.c:2363
BSP_AUDIO_IN_Init
uint8_t BSP_AUDIO_IN_Init(uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr)
Initializes wave recording.
Definition: stm32f4_discovery_audio.c:705
MX_SAI1_Block_B_Init
__weak HAL_StatusTypeDef MX_SAI1_Block_B_Init(SAI_HandleTypeDef *hsai, MX_SAI_Config_t *MXConfig)
Initializes the Audio Codec audio in instance (SAI).
Definition: stm32h747i_discovery_audio.c:1652
BSP_AUDIO_OUT_TransferComplete_CallBack
__weak void BSP_AUDIO_OUT_TransferComplete_CallBack(void)
Manages the DMA full Transfer complete event.
Definition: stm32f4_discovery_audio.c:637
BSP_AUDIO_OUT_GetChannelsNbr
int32_t BSP_AUDIO_OUT_GetChannelsNbr(uint32_t Instance, uint32_t *ChannelNbr)
Get the audio Channels number.
Definition: stm32h747i_discovery_audio.c:1226
BSP_AUDIO_IN_Error_CallBack
__weak void BSP_AUDIO_IN_Error_CallBack(void)
Audio IN Error callback function.
Definition: stm32f769i_discovery_audio.c:1637
BSP_AUDIO_IN_PDMToPCM_Init
int32_t BSP_AUDIO_IN_PDMToPCM_Init(uint32_t Instance, uint32_t AudioFreq, uint32_t ChnlNbrIn, uint32_t ChnlNbrOut)
Initialize the PDM library.
Definition: stm32h747i_discovery_audio.c:1866
BSP_AUDIO_OUT_GetState
int32_t BSP_AUDIO_OUT_GetState(uint32_t Instance, uint32_t *State)
Get Audio Out state.
Definition: stm32h747i_discovery_audio.c:1250
AUDIO_IN_Ctx_t::Volume
uint32_t Volume
Definition: stm32h747i_discovery_audio.h:75
BSP_AUDIO_OUT_Play
uint8_t BSP_AUDIO_OUT_Play(uint16_t *pBuffer, uint32_t Size)
Starts playing audio stream from a data buffer for a determined size.
Definition: stm32f4_discovery_audio.c:266
AUDIO_IN_Ctx_t::pMultiBuff
uint8_t ** pMultiBuff
Definition: stm32h747i_discovery_audio.h:73
BSP_AUDIO_IN_GetBitsPerSample
int32_t BSP_AUDIO_IN_GetBitsPerSample(uint32_t Instance, uint32_t *BitsPerSample)
Get Audio In Resolution.
Definition: stm32h747i_discovery_audio.c:2269
MX_SAI_Config_t::DataSize
uint32_t DataSize
Definition: stm32h747i_discovery_audio.h:98
Audio_CompObj
void * Audio_CompObj
Definition: stm32h747i_discovery_audio.h:335
BSP_AUDIO_OUT_IRQHandler
void BSP_AUDIO_OUT_IRQHandler(uint32_t Instance)
Definition: stm32h747i_discovery_audio.c:1268
BSP_AUDIO_IN_GetChannelsNbr
int32_t BSP_AUDIO_IN_GetChannelsNbr(uint32_t Instance, uint32_t *ChannelNbr)
Get Audio In Channel number.
Definition: stm32h747i_discovery_audio.c:2314
MX_SAI_Config_t
Definition: stm32h747i_discovery_audio.h:94
MX_SAI_Config_t::Synchro
uint32_t Synchro
Definition: stm32h747i_discovery_audio.h:101
haudio_in_sai
SAI_HandleTypeDef haudio_in_sai
Definition: stm32f769i_discovery_audio.c:228
AUDIO_IN_Ctx_t::IsMspCallbacksValid
uint32_t IsMspCallbacksValid
Definition: stm32h747i_discovery_audio.h:78
MX_SAI_Config_t::MonoStereoMode
uint32_t MonoStereoMode
Definition: stm32h747i_discovery_audio.h:99
BSP_AUDIO_OUT_SetDevice
int32_t BSP_AUDIO_OUT_SetDevice(uint32_t Instance, uint32_t Device)
Switch dynamically (while audio file is played) the output target (speaker or headphone).
Definition: stm32h747i_discovery_audio.c:917
BSP_AUDIO_IN_Pause
uint8_t BSP_AUDIO_IN_Pause(void)
Pauses the audio file stream.
Definition: stm32f4_discovery_audio.c:771
BSP_AUDIO_IN_RecordPDM
int32_t BSP_AUDIO_IN_RecordPDM(uint32_t Instance, uint8_t *pBuf, uint32_t NbrOfBytes)
Start audio recording.
Definition: stm32h747i_discovery_audio.c:2082
MX_SAI_Config_t::ActiveFrameLength
uint32_t ActiveFrameLength
Definition: stm32h747i_discovery_audio.h:105
MX_SAI4_Block_A_Init
__weak HAL_StatusTypeDef MX_SAI4_Block_A_Init(SAI_HandleTypeDef *hsai, MX_SAI_Config_t *MXConfig)
Initializes the Audio Codec audio in instance (SAI).
Definition: stm32h747i_discovery_audio.c:1708
stm32h747i_discovery_errno.h
__SAI_HandleTypeDef
Definition: stm32f7xx_hal_sai.h:191
AUDIO_OUT_Ctx_t::ChannelsNbr
uint32_t ChannelsNbr
Definition: stm32h747i_discovery_audio.h:88
MX_SAI1_ClockConfig
__weak HAL_StatusTypeDef MX_SAI1_ClockConfig(SAI_HandleTypeDef *hsai, uint32_t SampleRate)
SAI clock Config.
Definition: stm32h747i_discovery_audio.c:444
MX_SAI_Config_t::AudioMode
uint32_t AudioMode
Definition: stm32h747i_discovery_audio.h:97
stm32h747i_discovery_conf.h
BSP_AUDIO_OUT_DeInit
void BSP_AUDIO_OUT_DeInit(void)
Deinit the audio peripherals.
Definition: stm32469i_discovery_audio.c:592
MX_SAI_Config_t::SlotActive
uint32_t SlotActive
Definition: stm32h747i_discovery_audio.h:106
BSP_AUDIO_OUT_Error_CallBack
__weak void BSP_AUDIO_OUT_Error_CallBack(void)
Manages the DMA FIFO error event.
Definition: stm32f4_discovery_audio.c:651
BSP_AUDIO_OUT_SetSampleRate
int32_t BSP_AUDIO_OUT_SetSampleRate(uint32_t Instance, uint32_t SampleRate)
Updates the audio frequency.
Definition: stm32h747i_discovery_audio.c:972
BSP_AUDIO_OUT_GetVolume
int32_t BSP_AUDIO_OUT_GetVolume(uint32_t Instance, uint32_t *Volume)
Get the current audio volume level.
Definition: stm32h747i_discovery_audio.c:812
BSP_AUDIO_OUT_HalfTransfer_CallBack
__weak void BSP_AUDIO_OUT_HalfTransfer_CallBack(void)
Manages the DMA Half Transfer complete event.
Definition: stm32f4_discovery_audio.c:644
AUDIO_IN_Ctx_t::State
uint32_t State
Definition: stm32h747i_discovery_audio.h:76
MX_SAI_Config_t::AudioFrequency
uint32_t AudioFrequency
Definition: stm32h747i_discovery_audio.h:96
BSP_AUDIO_OUT_SetBitsPerSample
int32_t BSP_AUDIO_OUT_SetBitsPerSample(uint32_t Instance, uint32_t BitsPerSample)
Set the audio Resolution.
Definition: stm32h747i_discovery_audio.c:1064
BSP_AUDIO_IN_SetSampleRate
int32_t BSP_AUDIO_IN_SetSampleRate(uint32_t Instance, uint32_t SampleRate)
Set Audio In frequency.
Definition: stm32h747i_discovery_audio.c:2170
MX_SAI_Config_t::OutputDrive
uint32_t OutputDrive
Definition: stm32h747i_discovery_audio.h:102
AUDIO_OUT_Ctx_t::IsMute
uint32_t IsMute
Definition: stm32h747i_discovery_audio.h:89
BSP_AUDIO_OUT_UnMute
int32_t BSP_AUDIO_OUT_UnMute(uint32_t Instance)
Disables the MUTE mode.
Definition: stm32h747i_discovery_audio.c:863
BSP_AUDIO_IN_Record
uint8_t BSP_AUDIO_IN_Record(uint16_t *pbuf, uint32_t size)
Starts audio recording.
Definition: stm32f4_discovery_audio.c:737
MX_SAI_Config_t::SynchroExt
uint32_t SynchroExt
Definition: stm32h747i_discovery_audio.h:103
BSP_AUDIO_OUT_GetDevice
int32_t BSP_AUDIO_OUT_GetDevice(uint32_t Instance, uint32_t *Device)
Get the Output Device.
Definition: stm32h747i_discovery_audio.c:947
BSP_AUDIO_OUT_Stop
uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option)
Stops audio playing and Power down the Audio Codec.
Definition: stm32f4_discovery_audio.c:349
BSP_AUDIO_OUT_SetChannelsNbr
int32_t BSP_AUDIO_OUT_SetChannelsNbr(uint32_t Instance, uint32_t ChannelNbr)
Set the audio Channels number.
Definition: stm32h747i_discovery_audio.c:1170
AUDIO_OUT_Ctx_t::Instance
uint32_t Instance
Definition: stm32h747i_discovery_audio.h:83
BSP_AUDIO_IN_TransferComplete_CallBack
__weak void BSP_AUDIO_IN_TransferComplete_CallBack(void)
User callback when record buffer is filled.
Definition: stm32f4_discovery_audio.c:1001
BSP_AUDIO_IN_Resume
uint8_t BSP_AUDIO_IN_Resume(void)
Resumes the audio file stream.
Definition: stm32f4_discovery_audio.c:784
Audio_Out_Ctx
AUDIO_OUT_Ctx_t Audio_Out_Ctx[]
Definition: stm32h747i_discovery_audio.c:174
BSP_AUDIO_Init_t::Volume
uint32_t Volume
Definition: stm32h747i_discovery_audio.h:62
AUDIO_IN_Ctx_t::Device
uint32_t Device
Definition: stm32h747i_discovery_audio.h:68
BSP_AUDIO_IN_HalfTransfer_CallBack
__weak void BSP_AUDIO_IN_HalfTransfer_CallBack(void)
Manages the DMA Half Transfer complete event.
Definition: stm32f4_discovery_audio.c:1011
BSP_AUDIO_OUT_GetBitsPerSample
int32_t BSP_AUDIO_OUT_GetBitsPerSample(uint32_t Instance, uint32_t *BitsPerSample)
Get the audio Resolution.
Definition: stm32h747i_discovery_audio.c:1146
Audio_In_Ctx
AUDIO_IN_Ctx_t Audio_In_Ctx[]
Definition: stm32h747i_discovery_audio.c:177
AUDIO_IN_Ctx_t::BitsPerSample
uint32_t BitsPerSample
Definition: stm32h747i_discovery_audio.h:70
AUDIO_IN_Ctx_t::SampleRate
uint32_t SampleRate
Definition: stm32h747i_discovery_audio.h:69
AUDIO_IN_Ctx_t::IsMultiBuff
uint32_t IsMultiBuff
Definition: stm32h747i_discovery_audio.h:77
BSP_AUDIO_IN_GetState
int32_t BSP_AUDIO_IN_GetState(uint32_t Instance, uint32_t *State)
Get Audio In device.
Definition: stm32h747i_discovery_audio.c:2385
BSP_AUDIO_IN_GetSampleRate
int32_t BSP_AUDIO_IN_GetSampleRate(uint32_t Instance, uint32_t *SampleRate)
Get Audio In frequency.
Definition: stm32h747i_discovery_audio.c:2207
AUDIO_IN_Ctx_t::Size
uint32_t Size
Definition: stm32h747i_discovery_audio.h:74
BSP_AUDIO_Init_t::BitsPerSample
uint32_t BitsPerSample
Definition: stm32h747i_discovery_audio.h:60
BSP_AUDIO_IN_IRQHandler
void BSP_AUDIO_IN_IRQHandler(uint32_t Instance, uint32_t InputDevice)
This function handles Audio Out DMA interrupt requests.
Definition: stm32h747i_discovery_audio.c:2409
BSP_AUDIO_IN_SetBitsPerSample
int32_t BSP_AUDIO_IN_SetBitsPerSample(uint32_t Instance, uint32_t BitsPerSample)
Set Audio In Resolution.
Definition: stm32h747i_discovery_audio.c:2231
BSP_AUDIO_OUT_IsMute
int32_t BSP_AUDIO_OUT_IsMute(uint32_t Instance, uint32_t *IsMute)
Check whether the MUTE mode is enabled or not.
Definition: stm32h747i_discovery_audio.c:894
MX_SAI4_ClockConfig
__weak HAL_StatusTypeDef MX_SAI4_ClockConfig(SAI_HandleTypeDef *hsai, uint32_t SampleRate)
SAI clock Config.
Definition: stm32h747i_discovery_audio.c:485
AUDIO_OUT_Ctx_t::SampleRate
uint32_t SampleRate
Definition: stm32h747i_discovery_audio.h:85
AUDIO_IN_Ctx_t::ChannelsNbr
uint32_t ChannelsNbr
Definition: stm32h747i_discovery_audio.h:71
AUDIO_OUT_Ctx_t::BitsPerSample
uint32_t BitsPerSample
Definition: stm32h747i_discovery_audio.h:86
MX_SAI1_Block_A_Init
__weak HAL_StatusTypeDef MX_SAI1_Block_A_Init(SAI_HandleTypeDef *hsai, MX_SAI_Config_t *MXConfig)
Initializes the Audio Codec audio out instance (SAI).
Definition: stm32h747i_discovery_audio.c:384
AUDIO_IN_Ctx_t::pBuff
uint16_t * pBuff
Definition: stm32h747i_discovery_audio.h:72
BSP_AUDIO_IN_GetDevice
int32_t BSP_AUDIO_IN_GetDevice(uint32_t Instance, uint32_t *Device)
Get Audio In device.
Definition: stm32h747i_discovery_audio.c:2148
BSP_AUDIO_Init_t::Device
uint32_t Device
Definition: stm32h747i_discovery_audio.h:58
BSP_AUDIO_OUT_Init
uint8_t BSP_AUDIO_OUT_Init(uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq)
Configures the audio peripherals.
Definition: stm32f4_discovery_audio.c:214
BSP_AUDIO_OUT_Resume
uint8_t BSP_AUDIO_OUT_Resume(void)
Resumes the audio file streaming. WARNING: When calling BSP_AUDIO_OUT_Pause() function for pause,...
Definition: stm32f4_discovery_audio.c:325
AUDIO_OUT_Ctx_t::State
uint32_t State
Definition: stm32h747i_discovery_audio.h:90
AUDIO_IN_Ctx_t
Definition: stm32h747i_discovery_audio.h:65
AUDIO_IN_Ctx_t::Instance
uint32_t Instance
Definition: stm32h747i_discovery_audio.h:67


picovoice_driver
Author(s):
autogenerated on Fri Apr 1 2022 02:14:54