STSW-STLKT01: Drivers/BSP/SensorTile/SensorTile_audio_out.h Source File

STSW-STLKT01

STSW-STLKT01
SensorTile_audio_out.h
Go to the documentation of this file.
1 
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __SENSORTILE_AUDIO_OUT_H
40 #define __SENSORTILE_AUDIO_OUT_H
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46  /* Includes ------------------------------------------------------------------*/
47 #include "PCM1774_CODEC_driver.h"
48 #include "SensorTile.h"
49 
74  typedef enum
75  {
76  CODEX_SENSORS_AUTO = -1, /* Always first element and equal to -1 */
77  PCM1774_0 = 0 /* . */
78  } CODEX_ID_t;
86  extern DMA_HandleTypeDef hdma_dfsdmReg_FLT[];
96 #define CODEC_SENSORS_MAX_NUM 2
97 
98 #ifndef AUDIO_OK
99 #define AUDIO_OK ((uint8_t)0)
100 #endif
101 #ifndef AUDIO_ERROR
102 #define AUDIO_ERROR ((uint8_t)1)
103 #endif
104 #ifndef AUDIO_TIMEOUT
105 #define AUDIO_TIMEOUT ((uint8_t)2)
106 #endif
107 
108 #ifndef AUDIO_FREQUENCY_192K
109 #define AUDIO_FREQUENCY_192K ((uint32_t)192000)
110 #endif
111 #ifndef AUDIO_FREQUENCY_96K
112 #define AUDIO_FREQUENCY_96K ((uint32_t)96000)
113 #endif
114 #ifndef AUDIO_FREQUENCY_48K
115 #define AUDIO_FREQUENCY_48K ((uint32_t)48000)
116 #endif
117 #ifndef AUDIO_FREQUENCY_44K
118 #define AUDIO_FREQUENCY_44K ((uint32_t)44100)
119 #endif
120 #ifndef AUDIO_FREQUENCY_32K
121 #define AUDIO_FREQUENCY_32K ((uint32_t)32000)
122 #endif
123 #ifndef AUDIO_FREQUENCY_22K
124 #define AUDIO_FREQUENCY_22K ((uint32_t)22050)
125 #endif
126 #ifndef AUDIO_FREQUENCY_16K
127 #define AUDIO_FREQUENCY_16K ((uint32_t)16000)
128 #endif
129 #ifndef AUDIO_FREQUENCY_11K
130 #define AUDIO_FREQUENCY_11K ((uint32_t)11025)
131 #endif
132 #ifndef AUDIO_FREQUENCY_8K
133 #define AUDIO_FREQUENCY_8K ((uint32_t)8000)
134 #endif
135 
136 
137  /* To have 2 separate audio stream in Both headphone and speaker the 4 slot must be activated */
138 #define CODEC_AUDIOFRAME_SLOT_0123 SAI_SLOTACTIVE_0 | SAI_SLOTACTIVE_1 | SAI_SLOTACTIVE_2 | SAI_SLOTACTIVE_3
139  /* To have an audio stream in headphone only SAI Slot 0 and Slot 2 must be activated */
140 #define CODEC_AUDIOFRAME_SLOT_02 SAI_SLOTACTIVE_0 | SAI_SLOTACTIVE_2
141  /* To have an audio stream in speaker only SAI Slot 1 and Slot 3 must be activated */
142 #define CODEC_AUDIOFRAME_SLOT_13 SAI_SLOTACTIVE_1 | SAI_SLOTACTIVE_3
143 
144  /* SAI peripheral configuration defines */
145 #define AUDIO_SAIx SAI2_Block_A
146 #define AUDIO_SAIx_CLK_ENABLE() __HAL_RCC_SAI2_CLK_ENABLE()
147 #define AUDIO_SAIx_MCKB_SCKB_SDB_FSB_AF GPIO_AF13_SAI2
148 
149 #define AUDIO_SAIx_MCKB_SCKB_SDB_FSB_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE()
150 #define AUDIO_SAIx_FSB_PIN GPIO_PIN_10
151 #define AUDIO_SAIx_SCKB_PIN GPIO_PIN_9
152 #define AUDIO_SAIx_SDB_PIN GPIO_PIN_12
153 #define AUDIO_SAIx_MCKB_PIN GPIO_PIN_11
154 #define AUDIO_SAIx_MCKB_SCKB_SDB_FSB_GPIO_PORT GPIOG
155 
156  /* SAI DMA Channel definitions */
157 #define AUDIO_SAIx_DMAx_CLK_ENABLE() __HAL_RCC_DMA2_CLK_ENABLE()
158 #define AUDIO_SAIx_DMAx_CHANNEL DMA2_Channel3
159 #define AUDIO_SAIx_DMAx_IRQ DMA2_Channel3_IRQn
160 #define AUDIO_SAIx_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD
161 #define AUDIO_SAIx_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD
162 #define DMA_MAX_SZE (uint32_t)0xFFFF
163 
164 #define AUDIO_SAIx_DMAx_IRQHandler DMA2_Channel3_IRQHandler
165 
166  /* Select the interrupt preemption priority for the DMA interrupt */
167 #define AUDIO_OUT_IRQ_PREPRIO 7 /* Select the preemption priority level(0 is the highest) */
168 
169 
178 #define DMA_MAX(_X_) (((_X_) <= DMA_MAX_SZE)? (_X_):DMA_MAX_SZE)
179 
187  uint8_t BSP_AUDIO_OUT_Init(CODEX_ID_t id, void **handle, uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq);
188  uint8_t BSP_AUDIO_OUT_Play(void *handle, uint16_t* pBuffer, uint32_t Size);
189  uint8_t BSP_AUDIO_OUT_Pause(void *handle);
190  uint8_t BSP_AUDIO_OUT_Resume(void *handle);
191  uint8_t BSP_AUDIO_OUT_SetFrequency(void *handle, uint32_t AudioFreq);
192  uint8_t BSP_AUDIO_OUT_ClockConfig(uint32_t AudioFreq, void *Params);
193  uint8_t BSP_AUDIO_OUT_SetOutputMode(void *handle, uint8_t Output);
194  uint8_t BSP_AUDIO_OUT_SetMute(void *handle, uint32_t Cmd);
195  uint8_t BSP_AUDIO_OUT_SetVolume(void *handle, uint8_t Volume);
196  uint8_t BSP_AUDIO_OUT_Stop(void *handle, uint32_t Option);
197  /* User Callbacks: user has to implement these functions in his code if they are needed. */
198  /* These functions should be implemented by the user application.*/
201  void BSP_AUDIO_OUT_Error_CallBack(void);
218 #ifdef __cplusplus
219 }
220 #endif
221 
222 #endif /* __SENSORTILE_AUDIO_OUT_H */
223 
224 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
225 
uint8_t BSP_AUDIO_OUT_SetVolume(void *handle, uint8_t Volume)
Controls the current audio volume level.
uint8_t BSP_AUDIO_OUT_Pause(void *handle)
This function Pauses the audio file stream. In case of using DMA, the DMA Pause feature is used...
uint8_t BSP_AUDIO_OUT_SetFrequency(void *handle, uint32_t AudioFreq)
Update the audio frequency.
__weak uint8_t BSP_AUDIO_OUT_ClockConfig(uint32_t AudioFreq, void *Params)
Clock Config.
uint8_t BSP_AUDIO_OUT_Init(CODEX_ID_t id, void **handle, uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq)
Configures the audio peripherals.
__weak void BSP_AUDIO_OUT_HalfTransfer_CallBack(void)
Manages the DMA Half Transfer complete event.
uint8_t BSP_AUDIO_OUT_SetMute(void *handle, uint32_t Cmd)
Enables or disables the MUTE mode by software.
This file contains definitions for SensorTile.c file.
uint8_t BSP_AUDIO_OUT_Stop(void *handle, uint32_t Option)
Stops audio playing and Power down the Audio Codec.
__weak void BSP_AUDIO_OUT_Error_CallBack(void)
Manages the DMA FIFO error event.
uint8_t BSP_AUDIO_OUT_Resume(void *handle)
This function Resumes the audio file stream.
uint8_t BSP_AUDIO_OUT_Play(void *handle, uint16_t *pBuffer, uint32_t Size)
Starts playing audio stream from a data buffer for a determined size.
__weak void BSP_AUDIO_OUT_TransferComplete_CallBack(void)
Manages the DMA full Transfer complete event.
Generated by   doxygen 1.8.13