Go to the documentation of this file.
159 const uint32_t
I2SFreq[8] = {8000, 11025, 16000, 22050, 32000, 44100, 48000, 96000};
160 const uint32_t
I2SPLLN[8] = {256, 429, 213, 429, 426, 271, 258, 344};
161 const uint32_t
I2SPLLR[8] = {5, 4, 4, 4, 4, 6, 3, 1};
195 static uint8_t
I2S3_Init(uint32_t AudioFreq);
196 static uint8_t
I2S2_Init(uint32_t AudioFreq);
197 static void PDMDecoder_Init(uint32_t AudioFreq, uint32_t ChnlNbrIn, uint32_t ChnlNbrOut);
450 if ((AudioFreq & 0x7) == 0)
513 uint8_t index = 0, freqindex = 0xFF;
515 for(index = 0; index < 8; index++)
517 if(
I2SFreq[index] == AudioFreq)
525 if ((freqindex & 0x7) == 0)
531 rccclkinit.
PLLI2S.PLLI2SM = 8;
542 rccclkinit.
PLLI2S.PLLI2SM = 8;
571 GPIO_InitStruct.
Speed = GPIO_SPEED_FAST;
846 AppPDM[index] =
HTONS(PDMBuf[index]);
852 PDM_Filter((uint8_t*)&AppPDM[index], (uint16_t*)&(PCMBuf[index]), &
PDM_FilterHandler[index]);
858 PCMBuf[(index<<1)+1] = PCMBuf[index<<1];
901 if ((AudioFreq & 0x7) == 0)
907 rccclkinit.
PLLI2S.PLLI2SM = 8;
918 rccclkinit.
PLLI2S.PLLI2SM = 8;
945 GPIO_InitStruct.
Speed = GPIO_SPEED_FAST;
1072 for(index = 0; index < ChnlNbrIn; index++)
#define I2S_MODE_MASTER_TX
#define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__)
void HAL_I2S_TxCpltCallback(I2S_HandleTypeDef *hi2s)
Tx Transfer completed callbacks.
#define I2S3_WS_GPIO_PORT
#define I2S2_SCK_GPIO_CLK_ENABLE()
void HAL_NVIC_EnableIRQ(IRQn_Type IRQn)
static AUDIO_DrvTypeDef * pAudioDrv
DMA handle Structure definition.
#define DEFAULT_AUDIO_IN_CHANNEL_NBR
__weak void BSP_AUDIO_IN_Error_Callback(void)
Audio IN Error callback function.
uint32_t(* Play)(uint16_t, uint16_t *, uint16_t)
GPIO Init structure definition
#define I2S2_CLK_ENABLE()
#define I2S2_CLK_DISABLE()
#define AUDIO_IN_IRQ_PREPRIO
void BSP_AUDIO_OUT_SetFrequency(uint32_t AudioFreq)
Update the audio frequency.
static void PDMDecoder_Init(uint32_t AudioFreq, uint32_t ChnlNbrIn, uint32_t ChnlNbrOut)
Initializes the PDM library.
uint8_t BSP_AUDIO_IN_PDMToPCM(uint16_t *PDMBuf, uint16_t *PCMBuf)
Converts audio format from PDM to PCM.
__weak void BSP_AUDIO_OUT_MspInit(I2S_HandleTypeDef *hi2s, void *Params)
AUDIO OUT I2S MSP Init.
__weak void BSP_AUDIO_IN_ClockConfig(I2S_HandleTypeDef *hi2s, uint32_t AudioFreq, void *Params)
Audio In Clock Config.
I2S handle Structure definition.
#define __HAL_RCC_CRC_CLK_ENABLE()
void HAL_NVIC_DisableIRQ(IRQn_Type IRQn)
uint32_t PeriphClockSelection
#define I2S3_WS_CLK_ENABLE()
__weak void BSP_AUDIO_IN_HalfTransfer_CallBack(void)
Manages the DMA Half Transfer complete event.
DMA_HandleTypeDef * hdmatx
#define AUDIO_I2C_ADDRESS
AUDIO I2C Interface pins.
#define RCC_PERIPHCLK_I2S
#define I2S3_DMAx_MEM_DATA_SIZE
uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option)
Stops audio playing and Power down the Audio Codec.
void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s)
Rx Transfer completed callbacks.
uint32_t PeriphDataAlignment
RCC_PLLI2SInitTypeDef PLLI2S
HAL_StatusTypeDef HAL_I2S_DMAPause(I2S_HandleTypeDef *hi2s)
void BSP_AUDIO_OUT_ChangeBuffer(uint16_t *pData, uint16_t Size)
Sends n-Bytes on the I2S interface.
#define INTERNAL_BUFF_SIZE
#define I2S2_SCK_GPIO_PORT
#define AUDIO_OUT_IRQ_PREPRIO
void HAL_Delay(uint32_t Delay)
This function provides minimum delay (in milliseconds) based on variable incremented.
#define I2S2_MOSI_GPIO_PORT
#define DMA_MBURST_SINGLE
#define I2S2_MOSI_GPIO_CLK_ENABLE()
static uint8_t I2S2_Init(uint32_t AudioFreq)
Initializes the Audio Codec audio interface (I2S)
This file contains the common defines and functions prototypes for stm32f411e_discovery_audio....
I2S_HandleTypeDef hAudioInI2s
#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_Stop(void)
Stops audio recording.
void HAL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init)
#define I2S3_DMAx_CLK_ENABLE()
#define I2S2_DMAx_CLK_ENABLE()
HAL_StatusTypeDef HAL_I2S_DMAResume(I2S_HandleTypeDef *hi2s)
__weak void BSP_AUDIO_IN_TransferComplete_CallBack(void)
User callback when record buffer is filled.
HAL_I2S_StateTypeDef HAL_I2S_GetState(I2S_HandleTypeDef *hi2s)
uint32_t(* SetMute)(uint16_t, uint32_t)
uint32_t(* Init)(uint16_t, uint16_t, uint8_t, uint32_t)
#define I2S3_DMAx_CHANNEL
HAL_StatusTypeDef HAL_I2S_Init(I2S_HandleTypeDef *hi2s)
#define I2S2_DMAx_PERIPH_DATA_SIZE
#define DMA_PRIORITY_HIGH
__weak void BSP_AUDIO_OUT_ClockConfig(I2S_HandleTypeDef *hi2s, uint32_t AudioFreq, void *Params)
Clock Config.
DMA_Stream_TypeDef * Instance
#define I2S3_SCK_SD_WS_AF
uint8_t BSP_AUDIO_IN_Pause(void)
Pauses the audio file stream.
uint32_t MemDataAlignment
void HAL_GPIO_DeInit(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin)
uint32_t(* Stop)(uint16_t, uint32_t)
#define I2S3_MCK_GPIO_PORT
void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s)
I2S error callbacks.
#define I2S_MCLKOUTPUT_ENABLE
#define DMA_PBURST_SINGLE
uint8_t BSP_AUDIO_OUT_Init(uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq)
Configures the audio peripherals.
uint8_t BSP_AUDIO_OUT_Pause(void)
Pauses the audio file stream. In case of using DMA, the DMA Pause feature is used....
uint8_t BSP_AUDIO_OUT_SetOutputMode(uint8_t Output)
Switch dynamically (while audio file is played) the output target (speaker or headphone).
#define DEFAULT_AUDIO_IN_VOLUME
uint32_t(* Resume)(uint16_t)
__weak void BSP_AUDIO_IN_MspDeInit(I2S_HandleTypeDef *hi2s, void *Params)
DeInitializes BSP_AUDIO_IN MSP.
DMA_HandleTypeDef * hdmarx
PDM_Filter_Handler_t PDM_FilterHandler[2]
#define CS43L22_ID
CS43L22 ID
#define DMA_FIFOMODE_ENABLE
void HAL_I2S_RxHalfCpltCallback(I2S_HandleTypeDef *hi2s)
Rx Half Transfer completed callbacks.
#define I2S3_SCK_SD_CLK_ENABLE()
PDM_Filter_Config_t PDM_FilterConfig[2]
#define DMA_FIFOMODE_DISABLE
uint32_t(* ReadID)(uint16_t)
const uint32_t I2SPLLN[8]
I2S_HandleTypeDef hAudioOutI2s
#define DMA_MEMORY_TO_PERIPH
HAL_StatusTypeDef HAL_RCCEx_PeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit)
HAL_StatusTypeDef HAL_DMA_Init(DMA_HandleTypeDef *hdma)
#define I2S2_DMAx_MEM_DATA_SIZE
#define I2S3_CLK_DISABLE()
HAL_StatusTypeDef HAL_DMA_DeInit(DMA_HandleTypeDef *hdma)
uint8_t BSP_AUDIO_IN_Resume(void)
Resumes the audio file stream.
HAL_StatusTypeDef HAL_I2S_DMAStop(I2S_HandleTypeDef *hi2s)
uint8_t BSP_AUDIO_IN_Record(uint16_t *pbuf, uint32_t size)
Starts audio recording.
#define I2S3_SCK_SD_GPIO_PORT
uint8_t BSP_AUDIO_OUT_Play(uint16_t *pBuffer, uint32_t Size)
Starts playing audio stream from a data buffer for a determined size.
uint32_t(* Pause)(uint16_t)
__weak void BSP_AUDIO_OUT_Error_CallBack(void)
Manages the DMA FIFO error event.
uint32_t(* SetOutputMode)(uint16_t, uint8_t)
#define I2S3_DMAx_PERIPH_DATA_SIZE
void HAL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority)
__IO uint16_t AudioInVolume
RCC extended clocks structure definition.
#define I2S_MCLKOUTPUT_DISABLE
#define I2S3_MCK_CLK_ENABLE()
__weak void BSP_AUDIO_OUT_HalfTransfer_CallBack(void)
Manages the DMA Half Transfer complete event.
#define I2S3_CLK_ENABLE()
const uint32_t I2SFreq[8]
__weak void BSP_AUDIO_OUT_MspDeInit(I2S_HandleTypeDef *hi2s, void *Params)
De-Initializes BSP_AUDIO_OUT MSP.
__weak void BSP_AUDIO_OUT_TransferComplete_CallBack(void)
Manages the DMA full Transfer complete event.
uint8_t BSP_AUDIO_OUT_SetMute(uint32_t Cmd)
Enables or disables the MUTE mode by software.
#define __HAL_I2S_DISABLE(__HANDLE__)
Disable the specified SPI peripheral (in I2S mode).
uint8_t BSP_AUDIO_IN_Init(uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr)
Initializes wave recording.
uint32_t(* SetVolume)(uint16_t, uint8_t)
#define DMA_FIFO_THRESHOLD_FULL
void HAL_I2S_TxHalfCpltCallback(I2S_HandleTypeDef *hi2s)
Tx Half Transfer completed callbacks.
static uint8_t I2S3_Init(uint32_t AudioFreq)
Initializes the Audio Codec audio interface (I2S).
uint8_t BSP_AUDIO_OUT_SetVolume(uint8_t Volume)
Controls the current audio volume level.
AUDIO_DrvTypeDef cs43l22_drv
HAL_StatusTypeDef HAL_I2S_Transmit_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size)
uint8_t BSP_AUDIO_OUT_Resume(void)
Resumes the audio file streaming. WARNING: When calling BSP_AUDIO_OUT_Pause() function for pause,...
__weak void BSP_AUDIO_IN_MspInit(I2S_HandleTypeDef *hi2s, void *Params)
BSP AUDIO IN MSP Init.
#define I2S2_DMAx_CHANNEL
void HAL_RCCEx_GetPeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit)
void HAL_GPIO_WritePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState)
#define I2S_MODE_MASTER_RX
uint8_t BSP_AUDIO_IN_SetVolume(uint8_t Volume)
Controls the audio in volume level.
const uint32_t I2SPLLR[8]