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);
490 uint8_t index = 0, freqindex = 0xFF;
492 for(index = 0; index < 8; index++)
494 if(
I2SFreq[index] == AudioFreq)
502 if ((freqindex & 0x7) == 0)
546 GPIO_InitStruct.
Speed = GPIO_SPEED_FAST;
822 AppPDM[index] =
HTONS(PDMBuf[index]);
828 PDM_Filter((uint8_t*)&AppPDM[index], (uint16_t*)&(PCMBuf[index]), &
PDM_FilterHandler[index]);
833 PCMBuf[(index<<1)+1] = PCMBuf[index<<1];
876 if ((AudioFreq & 0x7) == 0)
918 GPIO_InitStruct.
Speed = GPIO_SPEED_FAST;
1045 for(index = 0; index < ChnlNbrIn; index++)
#define I2S_MODE_MASTER_TX
uint8_t BSP_AUDIO_OUT_SetVolume(uint8_t Volume)
Controls the current audio volume level.
uint8_t BSP_AUDIO_IN_SetVolume(uint8_t Volume)
Controls the audio in volume level.
__weak void BSP_AUDIO_IN_MspDeInit(I2S_HandleTypeDef *hi2s, void *Params)
DeInitializes BSP_AUDIO_IN MSP.
void HAL_I2S_TxHalfCpltCallback(I2S_HandleTypeDef *hi2s)
Tx Half Transfer completed callbacks.
#define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__)
__weak void BSP_AUDIO_OUT_MspInit(I2S_HandleTypeDef *hi2s, void *Params)
AUDIO OUT I2S MSP Init.
#define I2S3_WS_GPIO_PORT
uint8_t BSP_AUDIO_IN_PDMToPCM(uint16_t *PDMBuf, uint16_t *PCMBuf)
Converts audio format from PDM to PCM.
#define I2S2_SCK_GPIO_CLK_ENABLE()
void HAL_NVIC_EnableIRQ(IRQn_Type IRQn)
uint8_t BSP_AUDIO_OUT_Pause(void)
Pauses the audio file stream. In case of using DMA, the DMA Pause feature is used....
DMA handle Structure definition.
#define DEFAULT_AUDIO_IN_CHANNEL_NBR
uint8_t BSP_AUDIO_IN_Stop(void)
Stops audio recording.
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
I2S_HandleTypeDef hAudioInI2s
void HAL_I2S_TxCpltCallback(I2S_HandleTypeDef *hi2s)
Tx Transfer completed callbacks.
__IO uint16_t AudioInVolume
const uint32_t I2SPLLN[8]
void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s)
Rx Transfer completed callbacks.
I2S handle Structure definition.
#define __HAL_RCC_CRC_CLK_ENABLE()
void HAL_NVIC_DisableIRQ(IRQn_Type IRQn)
uint32_t PeriphClockSelection
uint8_t BSP_AUDIO_IN_Init(uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr)
Initializes wave recording.
#define I2S3_WS_CLK_ENABLE()
__weak void BSP_AUDIO_OUT_TransferComplete_CallBack(void)
Manages the DMA full Transfer complete event.
DMA_HandleTypeDef * hdmatx
#define AUDIO_I2C_ADDRESS
AUDIO I2C Interface pins.
static uint8_t I2S3_Init(uint32_t AudioFreq)
Initializes the Audio Codec audio interface (I2S).
#define RCC_PERIPHCLK_I2S
#define I2S3_DMAx_MEM_DATA_SIZE
__weak void BSP_AUDIO_IN_ClockConfig(I2S_HandleTypeDef *hi2s, uint32_t AudioFreq, void *Params)
Audio In Clock Config.
uint32_t PeriphDataAlignment
static AUDIO_DrvTypeDef * pAudioDrv
RCC_PLLI2SInitTypeDef PLLI2S
HAL_StatusTypeDef HAL_I2S_DMAPause(I2S_HandleTypeDef *hi2s)
uint8_t BSP_AUDIO_OUT_Play(uint16_t *pBuffer, uint32_t Size)
Starts playing audio stream from a data buffer for a determined size.
#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()
const uint32_t I2SFreq[8]
I2S_HandleTypeDef hAudioOutI2s
#define DMA_PERIPH_TO_MEMORY
HAL_StatusTypeDef HAL_I2S_Receive_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size)
PDM_Filter_Config_t PDM_FilterConfig[2]
void HAL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init)
#define I2S3_DMAx_CLK_ENABLE()
void HAL_I2S_RxHalfCpltCallback(I2S_HandleTypeDef *hi2s)
Rx Half Transfer completed callbacks.
PDM_Filter_Handler_t PDM_FilterHandler[2]
#define I2S2_DMAx_CLK_ENABLE()
HAL_StatusTypeDef HAL_I2S_DMAResume(I2S_HandleTypeDef *hi2s)
uint8_t BSP_AUDIO_IN_Pause(void)
Pauses the audio file stream.
HAL_I2S_StateTypeDef HAL_I2S_GetState(I2S_HandleTypeDef *hi2s)
uint32_t(* SetMute)(uint16_t, uint32_t)
void BSP_AUDIO_OUT_SetFrequency(uint32_t AudioFreq)
Update the audio frequency.
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
static void PDMDecoder_Init(uint32_t AudioFreq, uint32_t ChnlNbrIn, uint32_t ChnlNbrOut)
Initializes the PDM library.
DMA_Stream_TypeDef * Instance
#define I2S3_SCK_SD_WS_AF
uint32_t MemDataAlignment
This file contains the common defines and functions prototypes for stm32f4_discovery_audio....
__weak void BSP_AUDIO_OUT_Error_CallBack(void)
Manages the DMA FIFO error event.
void HAL_GPIO_DeInit(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin)
uint32_t(* Stop)(uint16_t, uint32_t)
void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s)
I2S error callbacks.
#define I2S3_MCK_GPIO_PORT
__weak void BSP_AUDIO_OUT_HalfTransfer_CallBack(void)
Manages the DMA Half Transfer complete event.
static uint8_t I2S2_Init(uint32_t AudioFreq)
Initializes the Audio Codec audio interface (I2S)
uint8_t BSP_AUDIO_OUT_SetOutputMode(uint8_t Output)
Switch dynamically (while audio file is played) the output target (speaker or headphone).
const uint32_t I2SPLLR[8]
#define I2S_MCLKOUTPUT_ENABLE
#define DMA_PBURST_SINGLE
uint8_t BSP_AUDIO_IN_Record(uint16_t *pbuf, uint32_t size)
Starts audio recording.
__weak void BSP_AUDIO_IN_Error_Callback(void)
Audio IN Error callback function.
#define DEFAULT_AUDIO_IN_VOLUME
uint32_t(* Resume)(uint16_t)
uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option)
Stops audio playing and Power down the Audio Codec.
DMA_HandleTypeDef * hdmarx
__weak void BSP_AUDIO_IN_MspInit(I2S_HandleTypeDef *hi2s, void *Params)
BSP AUDIO IN MSP Init.
__weak void BSP_AUDIO_IN_TransferComplete_CallBack(void)
User callback when record buffer is filled.
uint8_t BSP_AUDIO_IN_Resume(void)
Resumes the audio file stream.
#define CS43L22_ID
CS43L22 ID
#define DMA_FIFOMODE_ENABLE
#define I2S3_SCK_SD_CLK_ENABLE()
__weak void BSP_AUDIO_IN_HalfTransfer_CallBack(void)
Manages the DMA Half Transfer complete event.
#define DMA_FIFOMODE_DISABLE
uint32_t(* ReadID)(uint16_t)
#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()
__weak void BSP_AUDIO_OUT_ClockConfig(I2S_HandleTypeDef *hi2s, uint32_t AudioFreq, void *Params)
Clock Config.
HAL_StatusTypeDef HAL_DMA_DeInit(DMA_HandleTypeDef *hdma)
HAL_StatusTypeDef HAL_I2S_DMAStop(I2S_HandleTypeDef *hi2s)
#define I2S3_SCK_SD_GPIO_PORT
uint32_t(* Pause)(uint16_t)
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)
RCC extended clocks structure definition.
#define I2S_MCLKOUTPUT_DISABLE
#define I2S3_MCK_CLK_ENABLE()
#define I2S3_CLK_ENABLE()
uint8_t BSP_AUDIO_OUT_Init(uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq)
Configures the audio peripherals.
uint8_t BSP_AUDIO_OUT_Resume(void)
Resumes the audio file streaming. WARNING: When calling BSP_AUDIO_OUT_Pause() function for pause,...
#define __HAL_I2S_DISABLE(__HANDLE__)
Disable the specified SPI peripheral (in I2S mode).
uint32_t(* SetVolume)(uint16_t, uint8_t)
#define DMA_FIFO_THRESHOLD_FULL
AUDIO_DrvTypeDef cs43l22_drv
HAL_StatusTypeDef HAL_I2S_Transmit_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size)
__weak void BSP_AUDIO_OUT_MspDeInit(I2S_HandleTypeDef *hi2s, void *Params)
De-Initializes BSP_AUDIO_OUT MSP.
#define I2S2_DMAx_CHANNEL
void HAL_RCCEx_GetPeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit)
uint8_t BSP_AUDIO_OUT_SetMute(uint32_t Cmd)
Enables or disables the MUTE mode by software.
void HAL_GPIO_WritePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState)
#define I2S_MODE_MASTER_RX
void BSP_AUDIO_OUT_ChangeBuffer(uint16_t *pData, uint16_t Size)
Sends n-Bytes on the I2S interface.