Classes | Macros | Functions | Variables
stm32h747i_discovery_audio.h File Reference

This file contains the common defines and functions prototypes for the stm32h747i_discovery_audio.c driver. More...

#include "stm32h747i_discovery_conf.h"
#include "stm32h747i_discovery_errno.h"
#include "../Components/Common/audio.h"
#include "pdm2pcm_glo.h"
Include dependency graph for stm32h747i_discovery_audio.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  AUDIO_IN_Ctx_t
 
struct  AUDIO_OUT_Ctx_t
 
struct  BSP_AUDIO_Init_t
 
struct  MX_SAI_Config_t
 

Macros

#define AUDIO_FREQUENCY_11K   11025U
 
#define AUDIO_FREQUENCY_16K   16000U
 
#define AUDIO_FREQUENCY_176K   176400U
 
#define AUDIO_FREQUENCY_192K   192000U
 
#define AUDIO_FREQUENCY_22K   22050U
 
#define AUDIO_FREQUENCY_32K   32000U
 
#define AUDIO_FREQUENCY_44K   44100U
 
#define AUDIO_FREQUENCY_48K   48000U
 
#define AUDIO_FREQUENCY_88K   88200U
 
#define AUDIO_FREQUENCY_8K   8000U
 
#define AUDIO_FREQUENCY_96K   96000U
 
#define AUDIO_I2C_ADDRESS   0x34U
 
#define AUDIO_IN_DEVICE_ANALOG_MIC   0x00U
 
#define AUDIO_IN_DEVICE_DIGITAL_MIC   0x10U
 
#define AUDIO_IN_INSTANCES_NBR   2U
 
#define AUDIO_IN_INT_GPIO_ENABLE()   __HAL_RCC_GPIOJ_CLK_ENABLE()
 
#define AUDIO_IN_INT_GPIO_PIN   GPIO_PIN_15
 
#define AUDIO_IN_INT_GPIO_PORT   GPIOJ
 
#define AUDIO_IN_INT_IRQ   EXTI15_10_IRQn
 
#define AUDIO_IN_SAI_PDMx   SAI4_Block_A
 
#define AUDIO_IN_SAI_PDMx_CLK_DISABLE()   __HAL_RCC_SAI4_CLK_DISABLE()
 
#define AUDIO_IN_SAI_PDMx_CLK_ENABLE()   __HAL_RCC_SAI4_CLK_ENABLE()
 
#define AUDIO_IN_SAI_PDMx_CLK_IN_ENABLE()   __HAL_RCC_GPIOE_CLK_ENABLE()
 
#define AUDIO_IN_SAI_PDMx_CLK_IN_PIN   GPIO_PIN_2
 
#define AUDIO_IN_SAI_PDMx_CLK_IN_PORT   GPIOE
 
#define AUDIO_IN_SAI_PDMx_DATA_CLK_AF   GPIO_AF10_SAI4
 
#define AUDIO_IN_SAI_PDMx_DATA_IN_ENABLE()   __HAL_RCC_GPIOC_CLK_ENABLE()
 
#define AUDIO_IN_SAI_PDMx_DATA_IN_PIN   GPIO_PIN_1
 
#define AUDIO_IN_SAI_PDMx_DATA_IN_PORT   GPIOC
 
#define AUDIO_IN_SAI_PDMx_DMAx_CLK_ENABLE()   __HAL_RCC_BDMA_CLK_ENABLE()
 
#define AUDIO_IN_SAI_PDMx_DMAx_IRQ   BDMA_Channel1_IRQn
 
#define AUDIO_IN_SAI_PDMx_DMAx_IRQHandler   BDMA_Channel1_IRQHandler
 
#define AUDIO_IN_SAI_PDMx_DMAx_MEM_DATA_SIZE   DMA_MDATAALIGN_HALFWORD
 
#define AUDIO_IN_SAI_PDMx_DMAx_PERIPH_DATA_SIZE   DMA_PDATAALIGN_HALFWORD
 
#define AUDIO_IN_SAI_PDMx_DMAx_REQUEST   BDMA_REQUEST_SAI4_A
 
#define AUDIO_IN_SAI_PDMx_DMAx_STREAM   BDMA_Channel1
 
#define AUDIO_IN_SAI_PDMx_FS_PIN   GPIO_PIN_4
 
#define AUDIO_IN_SAI_PDMx_FS_SCK_AF   GPIO_AF8_SAI4
 
#define AUDIO_IN_SAI_PDMx_FS_SCK_ENABLE()   __HAL_RCC_GPIOE_CLK_ENABLE()
 
#define AUDIO_IN_SAI_PDMx_FS_SCK_GPIO_PORT   GPIOE
 
#define AUDIO_IN_SAI_PDMx_IRQ   SAI4_IRQn
 
#define AUDIO_IN_SAI_PDMx_IRQHandler   SAI4_IRQHandler
 
#define AUDIO_IN_SAI_PDMx_SCK_PIN   GPIO_PIN_5
 
#define AUDIO_IN_SAIx   SAI1_Block_B
 
#define AUDIO_IN_SAIx_AF   GPIO_AF6_SAI1
 
#define AUDIO_IN_SAIx_CLK_DISABLE()   __HAL_RCC_SAI1_CLK_DISABLE()
 
#define AUDIO_IN_SAIx_CLK_ENABLE()   __HAL_RCC_SAI1_CLK_ENABLE()
 
#define AUDIO_IN_SAIx_DMAx_CLK_ENABLE()   __HAL_RCC_DMA2_CLK_ENABLE()
 
#define AUDIO_IN_SAIx_DMAx_IRQ   DMA2_Stream4_IRQn
 
#define AUDIO_IN_SAIx_DMAx_IRQHandler   DMA2_Stream4_IRQHandler
 
#define AUDIO_IN_SAIx_DMAx_MEM_DATA_SIZE   DMA_MDATAALIGN_HALFWORD
 
#define AUDIO_IN_SAIx_DMAx_PERIPH_DATA_SIZE   DMA_PDATAALIGN_HALFWORD
 
#define AUDIO_IN_SAIx_DMAx_REQUEST   DMA_REQUEST_SAI1_B
 
#define AUDIO_IN_SAIx_DMAx_STREAM   DMA2_Stream4
 
#define AUDIO_IN_SAIx_SD_ENABLE()   __HAL_RCC_GPIOE_CLK_ENABLE()
 
#define AUDIO_IN_SAIx_SD_GPIO_PORT   GPIOE
 
#define AUDIO_IN_SAIx_SD_PIN   GPIO_PIN_3
 
#define AUDIO_IN_STATE_PAUSE   3U
 
#define AUDIO_IN_STATE_RECORDING   1U
 
#define AUDIO_IN_STATE_RESET   0U
 
#define AUDIO_IN_STATE_STOP   2U
 
#define AUDIO_OUT_DEVICE_AUTO   4U
 
#define AUDIO_OUT_DEVICE_HDMI   5U
 
#define AUDIO_OUT_DEVICE_HEADPHONE   2U
 
#define AUDIO_OUT_DEVICE_NONE   0U
 
#define AUDIO_OUT_DEVICE_SPEAKER   1U
 
#define AUDIO_OUT_DEVICE_SPK_HP   3U
 
#define AUDIO_OUT_INSTANCES_NBR   2U
 
#define AUDIO_OUT_SAIx   SAI1_Block_A
 
#define AUDIO_OUT_SAIx_CLK_DISABLE()   __HAL_RCC_SAI1_CLK_DISABLE()
 
#define AUDIO_OUT_SAIx_CLK_ENABLE()   __HAL_RCC_SAI1_CLK_ENABLE()
 
#define AUDIO_OUT_SAIx_DMAx_CLK_ENABLE()   __HAL_RCC_DMA2_CLK_ENABLE()
 
#define AUDIO_OUT_SAIx_DMAx_IRQ   DMA2_Stream1_IRQn
 
#define AUDIO_OUT_SAIx_DMAx_IRQHandler   DMA2_Stream1_IRQHandler
 
#define AUDIO_OUT_SAIx_DMAx_MEM_DATA_SIZE   DMA_MDATAALIGN_HALFWORD
 
#define AUDIO_OUT_SAIx_DMAx_PERIPH_DATA_SIZE   DMA_PDATAALIGN_HALFWORD
 
#define AUDIO_OUT_SAIx_DMAx_REQUEST   DMA_REQUEST_SAI1_A
 
#define AUDIO_OUT_SAIx_DMAx_STREAM   DMA2_Stream1
 
#define AUDIO_OUT_SAIx_FS_AF   GPIO_AF6_SAI1
 
#define AUDIO_OUT_SAIx_FS_ENABLE()   __HAL_RCC_GPIOE_CLK_ENABLE()
 
#define AUDIO_OUT_SAIx_FS_GPIO_PORT   GPIOE
 
#define AUDIO_OUT_SAIx_FS_PIN   GPIO_PIN_4
 
#define AUDIO_OUT_SAIx_MCLK_AF   GPIO_AF6_SAI1
 
#define AUDIO_OUT_SAIx_MCLK_ENABLE()   __HAL_RCC_GPIOG_CLK_ENABLE()
 
#define AUDIO_OUT_SAIx_MCLK_GPIO_PORT   GPIOG
 
#define AUDIO_OUT_SAIx_MCLK_PIN   GPIO_PIN_7
 
#define AUDIO_OUT_SAIx_SCK_AF   GPIO_AF6_SAI1
 
#define AUDIO_OUT_SAIx_SCK_ENABLE()   __HAL_RCC_GPIOE_CLK_ENABLE()
 
#define AUDIO_OUT_SAIx_SCK_GPIO_PORT   GPIOE
 
#define AUDIO_OUT_SAIx_SCK_PIN   GPIO_PIN_5
 
#define AUDIO_OUT_SAIx_SD_AF   GPIO_AF6_SAI1
 
#define AUDIO_OUT_SAIx_SD_ENABLE()   __HAL_RCC_GPIOE_CLK_ENABLE()
 
#define AUDIO_OUT_SAIx_SD_GPIO_PORT   GPIOE
 
#define AUDIO_OUT_SAIx_SD_PIN   GPIO_PIN_6
 
#define AUDIO_OUT_STATE_PAUSE   3U
 
#define AUDIO_OUT_STATE_PLAYING   1U
 
#define AUDIO_OUT_STATE_RESET   0U
 
#define AUDIO_OUT_STATE_STOP   2U
 
#define AUDIO_RESOLUTION_16B   16U
 
#define AUDIO_RESOLUTION_32B   32U
 
#define AUDIO_VOLUME_INPUT   0U
 
#define AUDIO_VOLUME_OUTPUT   1U
 
#define BSP_AUDIO_MUTE_DISABLED   0U
 
#define BSP_AUDIO_MUTE_ENABLED   1U
 
#define CODEC_AUDIOFRAME_SLOT_0123   SAI_SLOTACTIVE_0 | SAI_SLOTACTIVE_1 | SAI_SLOTACTIVE_2 | SAI_SLOTACTIVE_3
 
#define CODEC_AUDIOFRAME_SLOT_02   SAI_SLOTACTIVE_0 | SAI_SLOTACTIVE_2
 
#define CODEC_AUDIOFRAME_SLOT_13   SAI_SLOTACTIVE_1 | SAI_SLOTACTIVE_3
 
#define CODEC_MUTE_OFF   0U
 
#define CODEC_MUTE_ON   1U
 
#define CODEC_PDWN_SW   1U
 
#define POS_VAL(VAL)   (POSITION_VAL(VAL) - 4)
 
#define VOLUME_IN_CONVERT(Volume)   (((Volume) >= 100)? 239:((uint8_t)(((Volume) * 239) / 100)))
 
#define VOLUME_OUT_CONVERT(Volume)   (((Volume) > 100)? 63:((uint8_t)(((Volume) * 63) / 100)))
 

Functions

int32_t BSP_AUDIO_IN_DeInit (uint32_t Instance)
 Deinit the audio IN peripherals. More...
 
__weak void BSP_AUDIO_IN_Error_CallBack (uint32_t Instance)
 Audio IN Error callback function. More...
 
int32_t BSP_AUDIO_IN_GetBitsPerSample (uint32_t Instance, uint32_t *BitsPerSample)
 Get Audio In Resolution. More...
 
int32_t BSP_AUDIO_IN_GetChannelsNbr (uint32_t Instance, uint32_t *ChannelNbr)
 Get Audio In Channel number. More...
 
int32_t BSP_AUDIO_IN_GetDevice (uint32_t Instance, uint32_t *Device)
 Get Audio In device. More...
 
int32_t BSP_AUDIO_IN_GetSampleRate (uint32_t Instance, uint32_t *SampleRate)
 Get Audio In frequency. More...
 
int32_t BSP_AUDIO_IN_GetState (uint32_t Instance, uint32_t *State)
 Get Audio In device. More...
 
int32_t BSP_AUDIO_IN_GetVolume (uint32_t Instance, uint32_t *Volume)
 Get the current audio in volume level. More...
 
__weak void BSP_AUDIO_IN_HalfTransfer_CallBack (uint32_t Instance)
 Manages the DMA Half Transfer complete event. More...
 
int32_t BSP_AUDIO_IN_Init (uint32_t Instance, BSP_AUDIO_Init_t *AudioInit)
 Initialize wave recording. More...
 
void BSP_AUDIO_IN_IRQHandler (uint32_t Instance, uint32_t InputDevice)
 This function handles Audio Out DMA interrupt requests. More...
 
int32_t BSP_AUDIO_IN_Pause (uint32_t Instance)
 Pause the audio file stream. More...
 
int32_t BSP_AUDIO_IN_PDMToPCM (uint32_t Instance, uint16_t *PDMBuf, uint16_t *PCMBuf)
 Converts audio format from PDM to PCM. More...
 
int32_t BSP_AUDIO_IN_PDMToPCM_Init (uint32_t Instance, uint32_t AudioFreq, uint32_t ChnlNbrIn, uint32_t ChnlNbrOut)
 Initialize the PDM library. More...
 
int32_t BSP_AUDIO_IN_Record (uint32_t Instance, uint8_t *pBuf, uint32_t NbrOfBytes)
 Start audio recording. More...
 
int32_t BSP_AUDIO_IN_RecordPDM (uint32_t Instance, uint8_t *pBuf, uint32_t NbrOfBytes)
 Start audio recording. More...
 
int32_t BSP_AUDIO_IN_Resume (uint32_t Instance)
 Resume the audio file stream. More...
 
int32_t BSP_AUDIO_IN_SetBitsPerSample (uint32_t Instance, uint32_t BitsPerSample)
 Set Audio In Resolution. More...
 
int32_t BSP_AUDIO_IN_SetChannelsNbr (uint32_t Instance, uint32_t ChannelNbr)
 Set Audio In Channel number. More...
 
int32_t BSP_AUDIO_IN_SetDevice (uint32_t Instance, uint32_t Device)
 Set Audio In device. More...
 
int32_t BSP_AUDIO_IN_SetSampleRate (uint32_t Instance, uint32_t SampleRate)
 Set Audio In frequency. More...
 
int32_t BSP_AUDIO_IN_SetVolume (uint32_t Instance, uint32_t Volume)
 Set the current audio in volume level. More...
 
int32_t BSP_AUDIO_IN_Stop (uint32_t Instance)
 Stop audio recording. More...
 
__weak void BSP_AUDIO_IN_TransferComplete_CallBack (uint32_t Instance)
 User callback when record buffer is filled. More...
 
int32_t BSP_AUDIO_OUT_DeInit (uint32_t Instance)
 De-initializes the audio out peripheral. More...
 
__weak void BSP_AUDIO_OUT_Error_CallBack (uint32_t Instance)
 Manages the DMA FIFO error event. More...
 
int32_t BSP_AUDIO_OUT_GetBitsPerSample (uint32_t Instance, uint32_t *BitsPerSample)
 Get the audio Resolution. More...
 
int32_t BSP_AUDIO_OUT_GetChannelsNbr (uint32_t Instance, uint32_t *ChannelNbr)
 Get the audio Channels number. More...
 
int32_t BSP_AUDIO_OUT_GetDevice (uint32_t Instance, uint32_t *Device)
 Get the Output Device. More...
 
int32_t BSP_AUDIO_OUT_GetSampleRate (uint32_t Instance, uint32_t *SampleRate)
 Get the audio frequency. More...
 
int32_t BSP_AUDIO_OUT_GetState (uint32_t Instance, uint32_t *State)
 Get Audio Out state. More...
 
int32_t BSP_AUDIO_OUT_GetVolume (uint32_t Instance, uint32_t *Volume)
 Get the current audio volume level. More...
 
__weak void BSP_AUDIO_OUT_HalfTransfer_CallBack (uint32_t Instance)
 Manages the DMA Half Transfer complete event. More...
 
int32_t BSP_AUDIO_OUT_Init (uint32_t Instance, BSP_AUDIO_Init_t *AudioInit)
 Configures the audio peripherals. More...
 
void BSP_AUDIO_OUT_IRQHandler (uint32_t Instance)
 
int32_t BSP_AUDIO_OUT_IsMute (uint32_t Instance, uint32_t *IsMute)
 Check whether the MUTE mode is enabled or not. More...
 
int32_t BSP_AUDIO_OUT_Mute (uint32_t Instance)
 Enables the MUTE. More...
 
int32_t BSP_AUDIO_OUT_Pause (uint32_t Instance)
 This function Pauses the audio file stream. In case of using DMA, the DMA Pause feature is used. More...
 
int32_t BSP_AUDIO_OUT_Play (uint32_t Instance, uint8_t *pData, uint32_t NbrOfBytes)
 Default BSP AUDIO OUT Msp Callbacks. More...
 
int32_t BSP_AUDIO_OUT_Resume (uint32_t Instance)
 Resumes the audio file stream. More...
 
int32_t BSP_AUDIO_OUT_SetBitsPerSample (uint32_t Instance, uint32_t BitsPerSample)
 Set the audio Resolution. More...
 
int32_t BSP_AUDIO_OUT_SetChannelsNbr (uint32_t Instance, uint32_t ChannelNbr)
 Set the audio Channels number. More...
 
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). More...
 
int32_t BSP_AUDIO_OUT_SetSampleRate (uint32_t Instance, uint32_t SampleRate)
 Updates the audio frequency. More...
 
int32_t BSP_AUDIO_OUT_SetVolume (uint32_t Instance, uint32_t Volume)
 Controls the current audio volume level. More...
 
int32_t BSP_AUDIO_OUT_Stop (uint32_t Instance)
 Stops audio playing and Power down the Audio Codec. More...
 
__weak void BSP_AUDIO_OUT_TransferComplete_CallBack (uint32_t Instance)
 Manages the DMA full Transfer complete event. More...
 
int32_t BSP_AUDIO_OUT_UnMute (uint32_t Instance)
 Disables the MUTE mode. More...
 
__weak HAL_StatusTypeDef MX_SAI1_Block_A_Init (SAI_HandleTypeDef *hsai, MX_SAI_Config_t *MXConfig)
 Initializes the Audio Codec audio out instance (SAI). More...
 
__weak HAL_StatusTypeDef MX_SAI1_Block_B_Init (SAI_HandleTypeDef *hsai, MX_SAI_Config_t *MXConfig)
 Initializes the Audio Codec audio in instance (SAI). More...
 
__weak HAL_StatusTypeDef MX_SAI1_ClockConfig (SAI_HandleTypeDef *hsai, uint32_t SampleRate)
 SAI clock Config. More...
 
__weak HAL_StatusTypeDef MX_SAI4_Block_A_Init (SAI_HandleTypeDef *hsai, MX_SAI_Config_t *MXConfig)
 Initializes the Audio Codec audio in instance (SAI). More...
 
__weak HAL_StatusTypeDef MX_SAI4_ClockConfig (SAI_HandleTypeDef *hsai, uint32_t SampleRate)
 SAI clock Config. More...
 

Variables

void * Audio_CompObj
 
AUDIO_IN_Ctx_t Audio_In_Ctx []
 
AUDIO_OUT_Ctx_t Audio_Out_Ctx []
 
SAI_HandleTypeDef haudio_in_sai
 
SAI_HandleTypeDef haudio_out_sai
 

Detailed Description

This file contains the common defines and functions prototypes for the stm32h747i_discovery_audio.c driver.

Author
MCD Application Team
Attention

© Copyright (c) 2018 STMicroelectronics. All rights reserved.

This software component is licensed by ST under BSD 3-Clause license, the "License"; You may not use this file except in compliance with the License. You may obtain a copy of the License at: opensource.org/licenses/BSD-3-Clause

Definition in file stm32h747i_discovery_audio.h.



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