Go to the documentation of this file.
130 #define OUTPUT_DEVICE_HEADPHONE1 OUTPUT_DEVICE_HEADPHONE
133 #define OUTPUT_DEVICE_HEADPHONE2 OUTPUT_DEVICE_SPEAKER
144 #define SAIClockDivider(__FREQUENCY__) \
145 (__FREQUENCY__ == AUDIO_FREQUENCY_8K) ? 12 \
146 : (__FREQUENCY__ == AUDIO_FREQUENCY_11K) ? 2 \
147 : (__FREQUENCY__ == AUDIO_FREQUENCY_16K) ? 6 \
148 : (__FREQUENCY__ == AUDIO_FREQUENCY_22K) ? 1 \
149 : (__FREQUENCY__ == AUDIO_FREQUENCY_32K) ? 3 \
150 : (__FREQUENCY__ == AUDIO_FREQUENCY_44K) ? 0 \
151 : (__FREQUENCY__ == AUDIO_FREQUENCY_48K) ? 2 : 1 \
179 0x00, 0x01, 0x00, 0x01, 0x02, 0x03, 0x02, 0x03,
180 0x00, 0x01, 0x00, 0x01, 0x02, 0x03, 0x02, 0x03,
181 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07,
182 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07,
183 0x00, 0x01, 0x00, 0x01, 0x02, 0x03, 0x02, 0x03,
184 0x00, 0x01, 0x00, 0x01, 0x02, 0x03, 0x02, 0x03,
185 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07,
186 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07,
187 0x08, 0x09, 0x08, 0x09, 0x0a, 0x0b, 0x0a, 0x0b,
188 0x08, 0x09, 0x08, 0x09, 0x0a, 0x0b, 0x0a, 0x0b,
189 0x0c, 0x0d, 0x0c, 0x0d, 0x0e, 0x0f, 0x0e, 0x0f,
190 0x0c, 0x0d, 0x0c, 0x0d, 0x0e, 0x0f, 0x0e, 0x0f,
191 0x08, 0x09, 0x08, 0x09, 0x0a, 0x0b, 0x0a, 0x0b,
192 0x08, 0x09, 0x08, 0x09, 0x0a, 0x0b, 0x0a, 0x0b,
193 0x0c, 0x0d, 0x0c, 0x0d, 0x0e, 0x0f, 0x0e, 0x0f,
194 0x0c, 0x0d, 0x0c, 0x0d, 0x0e, 0x0f, 0x0e, 0x0f
206 static uint8_t
SAIx_Init(uint32_t AudioFreq);
208 static void I2Sx_Init(uint32_t AudioFreq);
214 static void PDMDecoder_Init(uint32_t AudioFreq, uint32_t ChnlNbrIn, uint32_t ChnlNbrOut);
669 gpio_init_structure.
Speed = GPIO_SPEED_HIGH;
684 gpio_init_structure.
Speed = GPIO_SPEED_HIGH;
692 gpio_init_structure.
Speed = GPIO_SPEED_HIGH;
1053 uint8_t byte1 = 0, byte2 = 0;
1059 byte2 = (PDMBuf[index] >> 8)& 0xFF;
1060 byte1 = (PDMBuf[index] & 0xFF);
1068 PDM_Filter((uint8_t*)&app_pdm[index], (uint16_t*)&(PCMBuf[index]), &
PDM_FilterHandler[index]);
1178 gpio_init_structure.
Speed = GPIO_SPEED_FAST;
1285 for(index = 0; index < ChnlNbrIn; index++)
1369 gpio_init_structure.
Speed = GPIO_SPEED_HIGH;
1445 HAL_TIM_SlaveConfigSynchronization(&
haudio_tim, &s_slave_config);
1450 s_oc_config.
Pulse = 1;
#define AUDIO_SAIx_DMAx_MEM_DATA_SIZE
#define TIM_OCPOLARITY_HIGH
#define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__)
#define AUDIO_TIMx_CLK_DISABLE()
#define AUDIO_I2Sx_SD_GPIO_PORT
void BSP_AUDIO_OUT_ChangeBuffer(uint16_t *pData, uint16_t Size)
Sends n-Bytes on the SAI interface.
#define SAI_FREE_PROTOCOL
This file contains the common defines and functions prototypes for the stm32469i_discovery_audio....
#define AUDIO_FREQUENCY_11K
#define TIM_OCNIDLESTATE_SET
#define SAI_FIFOTHRESHOLD_1QF
#define __HAL_I2S_ENABLE(__HANDLE__)
Enable the specified SPI peripheral (in I2S mode).
static void TIMx_Init(void)
Configure TIM as a clock divider by 2. I2S_SCK is externally connected to TIMx input channel.
uint8_t BSP_AUDIO_OUT_SetMute(uint32_t Cmd)
Enables or disables the MUTE mode by software.
uint32_t TriggerPrescaler
void HAL_NVIC_EnableIRQ(IRQn_Type IRQn)
uint8_t BSP_AUDIO_IN_Stop(void)
Stops audio recording.
HAL_StatusTypeDef HAL_SAI_DMAStop(SAI_HandleTypeDef *hsai)
#define SAI_CLOCKSTROBING_FALLINGEDGE
void HAL_I2S_RxHalfCpltCallback(I2S_HandleTypeDef *hi2s)
Rx Half Transfer completed callbacks.
uint32_t ActiveFrameLength
DMA handle Structure definition.
#define DEFAULT_AUDIO_IN_CHANNEL_NBR
#define AUDIO_TIMx_OUT_GPIO_PIN
static void TIMx_DeInit(void)
Configure TIM as a clock divider by 2. I2S_SCK is externally connected to TIMx input channel.
uint32_t(* Play)(uint16_t, uint16_t *, uint16_t)
GPIO Init structure definition
__weak void BSP_AUDIO_OUT_ClockConfig(SAI_HandleTypeDef *hsai, uint32_t AudioFreq, void *Params)
Clock Config.
#define AUDIO_TIMx_GPIO_PORT
DMA_HandleTypeDef * hdmatx
HAL_StatusTypeDef HAL_SAI_DMAPause(SAI_HandleTypeDef *hsai)
#define TIM_COUNTERMODE_UP
#define AUDIO_TIMx_IN_GPIO_PIN
#define AUDIO_IN_IRQ_PREPRIO
HAL_StatusTypeDef HAL_TIM_PWM_ConfigChannel(TIM_HandleTypeDef *htim, TIM_OC_InitTypeDef *sConfig, uint32_t Channel)
#define SAI_SLOTSIZE_DATASIZE
void BSP_AUDIO_OUT_SetAudioFrameSlot(uint32_t AudioFrameSlot)
Updates the Audio frame slot configuration.
#define TIM_CLOCKPOLARITY_NONINVERTED
void BSP_AUDIO_IN_DeInit(void)
Deinit the audio IN peripherals.
#define TIM_OCIDLESTATE_SET
HAL_StatusTypeDef HAL_SAI_DeInit(SAI_HandleTypeDef *hsai)
I2S handle Structure definition.
#define __HAL_RCC_CRC_CLK_ENABLE()
SAI_HandleTypeDef haudio_out_sai
void HAL_NVIC_DisableIRQ(IRQn_Type IRQn)
#define TIM_OCNPOLARITY_HIGH
uint32_t PeriphClockSelection
__weak void BSP_AUDIO_OUT_MspInit(SAI_HandleTypeDef *hsai, void *Params)
Initializes BSP_AUDIO_OUT MSP.
#define TIM_CLOCKPRESCALER_DIV1
void BSP_AUDIO_OUT_SetFrequency(uint32_t AudioFreq)
Updates the audio frequency.
HAL_SAI_StateTypeDef HAL_SAI_GetState(SAI_HandleTypeDef *hsai)
#define SAI_FS_CHANNEL_IDENTIFICATION
#define AUDIO_RESET_ENABLE()
#define AUDIO_I2C_ADDRESS
AUDIO I2C Interface pins.
#define RCC_PERIPHCLK_I2S
#define BSP_AUDIO_OUT_STEREOMODE
uint32_t PeriphDataAlignment
RCC_PLLI2SInitTypeDef PLLI2S
HAL_StatusTypeDef HAL_I2S_DMAPause(I2S_HandleTypeDef *hi2s)
#define INTERNAL_BUFF_SIZE
#define AUDIO_OUT_IRQ_PREPRIO
SAI_Block_TypeDef * Instance
void HAL_Delay(uint32_t Delay)
This function provides minimum delay (in milliseconds) based on variable incremented.
uint16_t __IO AudioInVolume
#define DMA_MBURST_SINGLE
#define AUDIO_SAIx_SD_PIN
#define AUDIO_TIMx_GPIO_CLK_ENABLE()
#define AUDIO_I2Sx_CLK_DISABLE()
#define DMA_PERIPH_TO_MEMORY
HAL_StatusTypeDef HAL_I2S_Receive_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size)
uint8_t BSP_AUDIO_IN_Record(uint16_t *pbuf, uint32_t size)
Starts audio recording.
__weak void BSP_AUDIO_IN_MspDeInit(I2S_HandleTypeDef *hi2s, void *Params)
DeInitializes BSP_AUDIO_IN MSP.
#define AUDIO_SAIx_CLK_DISABLE()
AUDIO_DrvTypeDef * audio_drv
uint8_t BSP_AUDIO_IN_Init(uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr)
Initializes wave recording.
void HAL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init)
uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option)
Stops audio playing and Power down the Audio Codec.
#define AUDIO_SAIx_DMAx_STREAM
TIM Input Capture Configuration Structure definition.
uint8_t BSP_AUDIO_OUT_Pause(void)
This function Pauses the audio file stream. In case of using DMA, the DMA Pause feature is used.
#define AUDIO_RESET_GPIO_PORT
#define TIM_OCFAST_DISABLE
void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s)
I2S error callbacks.
HAL_StatusTypeDef HAL_I2S_DMAResume(I2S_HandleTypeDef *hi2s)
#define AUDIO_FREQUENCY_22K
#define AUDIO_SAIx_DMAx_CHANNEL
HAL_I2S_StateTypeDef HAL_I2S_GetState(I2S_HandleTypeDef *hi2s)
HAL_StatusTypeDef HAL_TIM_IC_Init(TIM_HandleTypeDef *htim)
uint32_t(* SetMute)(uint16_t, uint32_t)
__weak void BSP_AUDIO_OUT_TransferComplete_CallBack(void)
Manages the DMA full Transfer complete event.
uint32_t(* Init)(uint16_t, uint16_t, uint8_t, uint32_t)
#define AUDIO_I2Sx_SD_PIN
uint8_t BSP_AUDIO_OUT_SetOutputMode(uint8_t Output)
Switch dynamically (while audio file is being played) the output target (speaker or headphone).
HAL_StatusTypeDef HAL_TIM_PWM_Start(TIM_HandleTypeDef *htim, uint32_t Channel)
#define CHANNEL_DEMUX_MASK
HAL_StatusTypeDef HAL_I2S_Init(I2S_HandleTypeDef *hi2s)
#define AUDIO_SAIx_DMAx_IRQ
#define AUDIO_FREQUENCY_44K
__weak void BSP_AUDIO_IN_MspInit(I2S_HandleTypeDef *hi2s, void *Params)
BSP AUDIO IN MSP Init.
#define AUDIO_SAIx_MCK_PIN
#define AUDIO_SAIx_SCK_SD_FS_GPIO_PORT
#define DMA_PRIORITY_HIGH
void BSP_AUDIO_OUT_DeInit(void)
Deinit the audio peripherals.
#define TIM_CLOCKSOURCE_ETRMODE1
DMA_Stream_TypeDef * Instance
PDM_Filter_Config_t PDM_FilterConfig[2]
HAL_StatusTypeDef HAL_SAI_DMAResume(SAI_HandleTypeDef *hsai)
#define AUDIO_SAIx_DMAx_PERIPH_DATA_SIZE
TIM Output Compare Configuration Structure definition.
uint32_t MemDataAlignment
#define AUDIO_SAIx_MCLK_SCK_SD_FS_AF
TIM Time Base Handle Structure definition.
void HAL_GPIO_DeInit(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin)
uint32_t(* Stop)(uint16_t, uint32_t)
#define AUDIO_TIMx_OUT_CHANNEL
void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai)
SAI error callbacks.
uint8_t BSP_AUDIO_OUT_SetVolume(uint8_t Volume)
Controls the current audio volume level.
#define SAI_OUTPUTDRIVE_ENABLE
#define AUDIO_I2Sx_SD_GPIO_CLK_ENABLE()
#define AUDIO_I2Sx_SCK_GPIO_PORT
Clock Configuration Handle Structure definition.
void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai)
Tx Half Transfer completed callbacks.
#define AUDIO_SAIx_DMAx_CLK_ENABLE()
static void TIMx_IC_MspDeInit(TIM_HandleTypeDef *htim)
Initializes the TIM INput Capture MSP.
#define BSP_AUDIO_OUT_CIRCULARMODE
#define DMA_PBURST_SINGLE
#define AUDIO_I2Sx_DMAx_CHANNEL
#define __HAL_SAI_DISABLE(__HANDLE__)
static void I2Sx_DeInit(void)
Deinitializes the Audio Codec audio interface (I2S).
void BSP_AUDIO_OUT_ChangeAudioConfig(uint32_t AudioOutOption)
Changes the Audio Out Configuration.
#define SAI_MODEMASTER_TX
HAL_StatusTypeDef HAL_TIM_ConfigClockSource(TIM_HandleTypeDef *htim, TIM_ClockConfigTypeDef *sClockSourceConfig)
__weak void BSP_AUDIO_OUT_Error_CallBack(void)
Manages the DMA FIFO error event.
#define AUDIO_I2Sx_SCK_AF
uint8_t Channel_Demux[128]
#define DEFAULT_AUDIO_IN_VOLUME
HAL_StatusTypeDef HAL_TIM_IC_Stop(TIM_HandleTypeDef *htim, uint32_t Channel)
TIM_HandleTypeDef haudio_tim
HAL_StatusTypeDef HAL_TIM_IC_DeInit(TIM_HandleTypeDef *htim)
uint32_t(* Resume)(uint16_t)
HAL_StatusTypeDef HAL_TIM_IC_ConfigChannel(TIM_HandleTypeDef *htim, TIM_IC_InitTypeDef *sConfig, uint32_t Channel)
void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai)
Tx Transfer completed callbacks.
#define __HAL_SAI_ENABLE(__HANDLE__)
DMA_HandleTypeDef * hdmarx
PDM_Filter_Handler_t PDM_FilterHandler[2]
#define AUDIO_I2Sx_DMAx_STREAM
#define AUDIO_I2Sx_CLK_ENABLE()
uint8_t BSP_AUDIO_IN_SetVolume(uint8_t Volume)
Controls the audio in volume level.
#define CS43L22_ID
CS43L22 ID
#define DMA_FIFOMODE_ENABLE
#define TIM_SLAVEMODE_EXTERNAL1
HAL_StatusTypeDef HAL_TIM_PWM_Stop(TIM_HandleTypeDef *htim, uint32_t Channel)
#define SAI_MASTERDIVIDER_ENABLE
I2S_HandleTypeDef haudio_in_i2s
static void PDMDecoder_Init(uint32_t AudioFreq, uint32_t ChnlNbrIn, uint32_t ChnlNbrOut)
Initializes the PDM library.
uint8_t BSP_AUDIO_OUT_Resume(void)
This function Resumes the audio file stream. WARNING: When calling BSP_AUDIO_OUT_Pause() function for...
#define DMA_FIFOMODE_DISABLE
uint32_t(* ReadID)(uint16_t)
static uint8_t SAIx_Init(uint32_t AudioFreq)
Initializes the Audio Codec audio interface (SAI).
#define AUDIO_SAIx_MCLK_ENABLE()
__weak void BSP_AUDIO_OUT_HalfTransfer_CallBack(void)
Manages the DMA Half Transfer complete event.
#define DMA_MEMORY_TO_PERIPH
HAL_StatusTypeDef HAL_RCCEx_PeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit)
HAL_StatusTypeDef HAL_DMA_Init(DMA_HandleTypeDef *hdma)
#define AUDIO_I2Sx_DMAx_IRQ
__weak void BSP_AUDIO_OUT_MspDeInit(SAI_HandleTypeDef *hsai, void *Params)
Deinitializes BSP_AUDIO_OUT MSP.
#define AUDIO_SAIx_SCK_PIN
HAL_StatusTypeDef HAL_TIM_IC_Start(TIM_HandleTypeDef *htim, uint32_t Channel)
HAL_StatusTypeDef HAL_DMA_DeInit(DMA_HandleTypeDef *hdma)
#define AUDIO_SAIx_CLK_ENABLE()
uint8_t BSP_AUDIO_OUT_Play(uint16_t *pBuffer, uint32_t Size)
Starts playing audio stream from a data buffer for a determined size.
TIM_Base_InitTypeDef Init
#define SAI_FS_ACTIVE_LOW
static void I2Sx_Init(uint32_t AudioFreq)
Initializes the Audio Codec audio interface (I2S)
#define CODEC_AUDIOFRAME_SLOT_0123
#define TIM_TRIGGERPOLARITY_NONINVERTED
HAL_StatusTypeDef HAL_SAI_Init(SAI_HandleTypeDef *hsai)
#define AUDIO_I2Sx_DMAx_CLK_ENABLE()
uint32_t(* Pause)(uint16_t)
#define AUDIO_I2Sx_SCK_PIN
uint32_t(* SetOutputMode)(uint16_t, uint8_t)
#define AUDIO_I2Sx_DMAx_MEM_DATA_SIZE
uint8_t BSP_AUDIO_IN_Pause(void)
Pauses the audio file stream.
void HAL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority)
__weak void BSP_AUDIO_IN_ClockConfig(I2S_HandleTypeDef *hi2s, void *Params)
Clock Config.
#define AUDIO_SAIx_MCLK_GPIO_PORT
RCC extended clocks structure definition.
#define I2S_MCLKOUTPUT_DISABLE
uint8_t BSP_AUDIO_OUT_Init(uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq)
Configures the audio peripherals.
#define GPIO_MODE_OUTPUT_PP
#define AUDIO_I2Sx_DMAx_PERIPH_DATA_SIZE
#define AUDIO_TIMx_IN_CHANNEL
#define __HAL_I2S_DISABLE(__HANDLE__)
Disable the specified SPI peripheral (in I2S mode).
uint32_t(* SetVolume)(uint16_t, uint8_t)
HAL_StatusTypeDef HAL_I2S_DeInit(I2S_HandleTypeDef *hi2s)
#define DMA_FIFO_THRESHOLD_FULL
static void SAIx_DeInit(void)
Deinitializes the Audio Codec audio interface (SAI).
#define AUDIO_SAIx_SCK_SD_FS_ENABLE()
#define AUDIO_TIMx_CLK_ENABLE()
uint8_t BSP_AUDIO_IN_PDMToPCM(uint16_t *PDMBuf, uint16_t *PCMBuf)
Converts audio format from PDM to PCM.
__weak void BSP_AUDIO_IN_HalfTransfer_CallBack(void)
Manages the DMA Half Transfer complete event.
SAI_SlotInitTypeDef SlotInit
uint8_t BSP_AUDIO_IN_Resume(void)
Resumes the audio file stream.
SAI_FrameInitTypeDef FrameInit
AUDIO_DrvTypeDef cs43l22_drv
#define AUDIO_I2Sx_SCK_GPIO_CLK_ENABLE()
#define SAI_FS_BEFOREFIRSTBIT
#define AUDIO_SAIx_FS_PIN
__weak void BSP_AUDIO_IN_TransferComplete_CallBack(void)
User callback when record buffer is filled.
void HAL_RCCEx_GetPeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit)
__weak void BSP_AUDIO_IN_Error_Callback(void)
Audio IN Error callback function.
void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s)
Rx Transfer completed callbacks.
HAL_StatusTypeDef HAL_SAI_Transmit_DMA(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size)
static void TIMx_IC_MspInit(TIM_HandleTypeDef *htim)
Initializes the TIM INput Capture MSP.
void HAL_GPIO_WritePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState)
#define I2S_MODE_MASTER_RX
TIM Slave configuration Structure definition.