Go to the documentation of this file.
40 #ifndef __STM32469I_DISCOVERY_AUDIO_H
41 #define __STM32469I_DISCOVERY_AUDIO_H
48 #if defined(BSP_AUDIO_USE_RTOS)
55 #include "../Components/cs43l22/cs43l22.h"
57 #include "../../../Middlewares/ST/STM32_Audio/Addons/PDM/Inc/pdm2pcm_glo.h"
85 #define BSP_AUDIO_OUT_CIRCULARMODE ((uint32_t)0x00000001)
86 #define BSP_AUDIO_OUT_NORMALMODE ((uint32_t)0x00000002)
87 #define BSP_AUDIO_OUT_STEREOMODE ((uint32_t)0x00000004)
88 #define BSP_AUDIO_OUT_MONOMODE ((uint32_t)0x00000008)
105 #define CODEC_AUDIOFRAME_SLOT_0123 SAI_SLOTACTIVE_0 | SAI_SLOTACTIVE_1 | SAI_SLOTACTIVE_2 | SAI_SLOTACTIVE_3
107 #define CODEC_AUDIOFRAME_SLOT_02 SAI_SLOTACTIVE_0 | SAI_SLOTACTIVE_2
109 #define CODEC_AUDIOFRAME_SLOT_13 SAI_SLOTACTIVE_1 | SAI_SLOTACTIVE_3
115 #define AUDIO_SAIx SAI1_Block_A
116 #define AUDIO_SAIx_CLK_ENABLE() __HAL_RCC_SAI1_CLK_ENABLE()
117 #define AUDIO_SAIx_CLK_DISABLE() __HAL_RCC_SAI1_CLK_DISABLE()
118 #define AUDIO_SAIx_MCLK_SCK_SD_FS_AF GPIO_AF6_SAI1
120 #define AUDIO_SAIx_MCLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE()
121 #define AUDIO_SAIx_MCLK_DISABLE() __HAL_RCC_GPIOG_CLK_DISABLE()
123 #define AUDIO_SAIx_MCK_PIN GPIO_PIN_7
124 #define AUDIO_SAIx_MCLK_GPIO_PORT GPIOG
126 #define AUDIO_SAIx_SCK_SD_FS_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE()
127 #define AUDIO_SAIx_SCK_SD_FS_DISABLE() __HAL_RCC_GPIOE_CLK_DISABLE()
128 #define AUDIO_SAIx_FS_PIN GPIO_PIN_4
129 #define AUDIO_SAIx_SCK_PIN GPIO_PIN_5
130 #define AUDIO_SAIx_SD_PIN GPIO_PIN_6
131 #define AUDIO_SAIx_SCK_SD_FS_GPIO_PORT GPIOE
133 #define AUDIO_RESET_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE()
134 #define AUDIO_RESET_DISABLE() __HAL_RCC_GPIOE_CLK_DISABLE()
135 #define AUDIO_RESET_PIN GPIO_PIN_2
136 #define AUDIO_RESET_GPIO_PORT GPIOE
139 #define AUDIO_SAIx_DMAx_CLK_ENABLE() __HAL_RCC_DMA2_CLK_ENABLE()
140 #define AUDIO_SAIx_DMAx_CLK_DISABLE() __HAL_RCC_DMA2_CLK_DISABLE()
141 #define AUDIO_SAIx_DMAx_STREAM DMA2_Stream3
142 #define AUDIO_SAIx_DMAx_CHANNEL DMA_CHANNEL_0
143 #define AUDIO_SAIx_DMAx_IRQ DMA2_Stream3_IRQn
144 #define AUDIO_SAIx_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD
145 #define AUDIO_SAIx_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD
146 #define DMA_MAX_SZE 0xFFFF
148 #define AUDIO_SAIx_DMAx_IRQHandler DMA2_Stream3_IRQHandler
151 #define AUDIO_OUT_IRQ_PREPRIO 5
154 #define AUDIO_SAIx_PLL_DISABLE() HAL_RCCEx_DisablePLLSAI1()
159 #define AUDIO_I2Sx SPI3
160 #define AUDIO_I2Sx_CLK_ENABLE() __HAL_RCC_SPI3_CLK_ENABLE()
161 #define AUDIO_I2Sx_CLK_DISABLE() __HAL_RCC_SPI3_CLK_DISABLE()
162 #define AUDIO_I2Sx_SCK_PIN GPIO_PIN_3
163 #define AUDIO_I2Sx_SCK_GPIO_PORT GPIOB
164 #define AUDIO_I2Sx_SCK_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
165 #define AUDIO_I2Sx_SCK_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
166 #define AUDIO_I2Sx_SCK_AF GPIO_AF6_SPI3
168 #define AUDIO_I2Sx_SD_PIN GPIO_PIN_6
169 #define AUDIO_I2Sx_SD_GPIO_PORT GPIOD
170 #define AUDIO_I2Sx_SD_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
171 #define AUDIO_I2Sx_SD_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE()
172 #define AUDIO_I2Sx_SD_AF GPIO_AF5_I2S3ext
175 #define AUDIO_I2Sx_DMAx_CLK_ENABLE() __HAL_RCC_DMA1_CLK_ENABLE()
176 #define AUDIO_I2Sx_DMAx_CLK_DISABLE() __HAL_RCC_DMA1_CLK_DISABLE()
177 #define AUDIO_I2Sx_DMAx_STREAM DMA1_Stream2
178 #define AUDIO_I2Sx_DMAx_CHANNEL DMA_CHANNEL_0
179 #define AUDIO_I2Sx_DMAx_IRQ DMA1_Stream2_IRQn
180 #define AUDIO_I2Sx_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD
181 #define AUDIO_I2Sx_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD
183 #define AUDIO_I2Sx_DMAx_IRQHandler DMA1_Stream2_IRQHandler
186 #define AUDIO_IN_IRQ_PREPRIO ((uint32_t)6)
194 #define AUDIO_TIMx_CLK_ENABLE() __HAL_RCC_TIM4_CLK_ENABLE()
195 #define AUDIO_TIMx_CLK_DISABLE() __HAL_RCC_TIM4_CLK_DISABLE()
196 #define AUDIO_TIMx TIM4
197 #define AUDIO_TIMx_IN_CHANNEL TIM_CHANNEL_1
198 #define AUDIO_TIMx_OUT_CHANNEL TIM_CHANNEL_2
199 #define AUDIO_TIMx_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
200 #define AUDIO_TIMx_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE()
201 #define AUDIO_TIMx_GPIO_PORT GPIOD
202 #define AUDIO_TIMx_IN_GPIO_PIN GPIO_PIN_12
203 #define AUDIO_TIMx_OUT_GPIO_PIN GPIO_PIN_13
204 #define AUDIO_TIMx_AF GPIO_AF2_TIM4
210 #define AUDIODATA_SIZE 2
213 #define AUDIO_OK ((uint8_t)0)
214 #define AUDIO_ERROR ((uint8_t)1)
215 #define AUDIO_TIMEOUT ((uint8_t)2)
218 #define DEFAULT_AUDIO_IN_FREQ I2S_AUDIOFREQ_16K
219 #define DEFAULT_AUDIO_IN_BIT_RESOLUTION ((uint8_t)16)
220 #define DEFAULT_AUDIO_IN_CHANNEL_NBR ((uint8_t)2)
221 #define DEFAULT_AUDIO_IN_VOLUME ((uint16_t)64)
224 #define INTERNAL_BUFF_SIZE (128*DEFAULT_AUDIO_IN_FREQ/16000*DEFAULT_AUDIO_IN_CHANNEL_NBR)
226 #define PCM_OUT_SIZE (DEFAULT_AUDIO_IN_FREQ/1000*DEFAULT_AUDIO_IN_CHANNEL_NBR)
227 #define CHANNEL_DEMUX_MASK ((uint8_t)0x55)
234 #define CODEC_RESET_DELAY ((uint8_t)5)
255 #define DMA_MAX(x) (((x) <= DMA_MAX_SZE)? (x):DMA_MAX_SZE)
263 uint8_t
BSP_AUDIO_OUT_Init(uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq);
300 uint8_t
BSP_AUDIO_IN_Init(uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr);
uint8_t BSP_AUDIO_IN_Init(uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr)
Initializes wave recording.
void BSP_AUDIO_OUT_HalfTransfer_CallBack(void)
Manages the DMA Half Transfer complete event.
void BSP_AUDIO_IN_Error_Callback(void)
Audio IN Error callback function.
void BSP_AUDIO_IN_DeInit(void)
Deinit the audio IN peripherals.
I2S handle Structure definition.
uint8_t BSP_AUDIO_IN_Stop(void)
Stops audio recording.
void BSP_AUDIO_IN_HalfTransfer_CallBack(void)
Manages the DMA Half Transfer complete event.
uint8_t BSP_AUDIO_IN_PDMToPCM(uint16_t *PDMBuf, uint16_t *PCMBuf)
Converts audio format from PDM to PCM.
uint8_t BSP_AUDIO_IN_Record(uint16_t *pData, uint32_t Size)
Starts audio recording.
void BSP_AUDIO_IN_ClockConfig(I2S_HandleTypeDef *hi2s, void *Params)
Clock Config.
void BSP_AUDIO_IN_MspDeInit(I2S_HandleTypeDef *hi2s, void *Params)
DeInitializes BSP_AUDIO_IN MSP.
uint8_t BSP_AUDIO_OUT_Resume(void)
Resumes the audio file streaming. WARNING: When calling BSP_AUDIO_OUT_Pause() function for pause,...
uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option)
Stops audio playing and Power down the Audio Codec.
uint8_t BSP_AUDIO_OUT_SetMute(uint32_t Cmd)
Enables or disables the MUTE mode by software.
uint8_t BSP_AUDIO_OUT_Play(uint16_t *pBuffer, uint32_t Size)
Starts playing audio stream from a data buffer for a determined size.
void BSP_AUDIO_OUT_Error_CallBack(void)
Manages the DMA FIFO error event.
void BSP_AUDIO_OUT_ChangeBuffer(uint16_t *pData, uint16_t Size)
Sends n-Bytes on the I2S interface.
void BSP_AUDIO_OUT_DeInit(void)
Deinit the audio peripherals.
void BSP_AUDIO_OUT_TransferComplete_CallBack(void)
Manages the DMA full Transfer complete event.
void BSP_AUDIO_IN_TransferComplete_CallBack(void)
User callback when record buffer is filled.
uint8_t BSP_AUDIO_IN_Pause(void)
Pauses the audio file stream.
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_IN_Resume(void)
Resumes the audio file stream.
void BSP_AUDIO_OUT_MspDeInit(SAI_HandleTypeDef *hsai, void *Params)
Deinitializes BSP_AUDIO_OUT MSP.
void BSP_AUDIO_OUT_SetAudioFrameSlot(uint32_t AudioFrameSlot)
Updates the Audio frame slot configuration.
void BSP_AUDIO_OUT_MspInit(SAI_HandleTypeDef *hsai, void *Params)
Initializes BSP_AUDIO_OUT MSP.
void BSP_AUDIO_OUT_ClockConfig(SAI_HandleTypeDef *hsai, uint32_t AudioFreq, void *Params)
Clock Config.
uint8_t BSP_AUDIO_IN_SetVolume(uint8_t Volume)
Controls the audio in volume level.
void BSP_AUDIO_IN_MspInit(I2S_HandleTypeDef *hi2s, void *Params)
BSP AUDIO IN MSP Init.
void BSP_AUDIO_OUT_SetFrequency(uint32_t AudioFreq)
Update the audio frequency.
uint8_t BSP_AUDIO_OUT_SetVolume(uint8_t Volume)
Controls the current audio volume level.
uint8_t BSP_AUDIO_OUT_SetOutputMode(uint8_t Output)
Switch dynamically (while audio file is played) the output target (speaker or headphone).
__IO uint16_t AudioInVolume
This file contains definitions for STM32469I-Discovery LEDs, push-buttons hardware resources.