stm32f769i_discovery_audio.c
Go to the documentation of this file.
1 
128 /* Dependencies
129 - stm32f769i_discovery.c
130 - stm32f7xx_hal_sai.c
131 - stm32f7xx_hal_dfsdm.c
132 - stm32f7xx_hal_dma.c
133 - stm32f7xx_hal_gpio.c
134 - stm32f7xx_hal_cortex.c
135 - stm32f7xx_hal_rcc_ex.h
136 - wm8994.c
137 EndDependencies */
138 
139 /* Includes ------------------------------------------------------------------*/
141 
159 typedef struct
160 {
161  uint16_t *pRecBuf; /* Pointer to record user buffer */
162  uint32_t RecSize; /* Size to record in mono, double size to record in stereo */
164 
179 /*### RECORD ###*/
180 #define DFSDM_OVER_SAMPLING(__FREQUENCY__) \
181  (__FREQUENCY__ == AUDIO_FREQUENCY_8K) ? 256 \
182  : (__FREQUENCY__ == AUDIO_FREQUENCY_11K) ? 256 \
183  : (__FREQUENCY__ == AUDIO_FREQUENCY_16K) ? 128 \
184  : (__FREQUENCY__ == AUDIO_FREQUENCY_22K) ? 128 \
185  : (__FREQUENCY__ == AUDIO_FREQUENCY_32K) ? 64 \
186  : (__FREQUENCY__ == AUDIO_FREQUENCY_44K) ? 64 \
187  : (__FREQUENCY__ == AUDIO_FREQUENCY_48K) ? 40 : 20 \
188 
189 #define DFSDM_CLOCK_DIVIDER(__FREQUENCY__) \
190  (__FREQUENCY__ == AUDIO_FREQUENCY_8K) ? 24 \
191  : (__FREQUENCY__ == AUDIO_FREQUENCY_11K) ? 4 \
192  : (__FREQUENCY__ == AUDIO_FREQUENCY_16K) ? 24 \
193  : (__FREQUENCY__ == AUDIO_FREQUENCY_22K) ? 4 \
194  : (__FREQUENCY__ == AUDIO_FREQUENCY_32K) ? 24 \
195  : (__FREQUENCY__ == AUDIO_FREQUENCY_44K) ? 4 \
196  : (__FREQUENCY__ == AUDIO_FREQUENCY_48K) ? 25 : 25 \
197 
198 #define DFSDM_FILTER_ORDER(__FREQUENCY__) \
199  (__FREQUENCY__ == AUDIO_FREQUENCY_8K) ? DFSDM_FILTER_SINC3_ORDER \
200  : (__FREQUENCY__ == AUDIO_FREQUENCY_11K) ? DFSDM_FILTER_SINC3_ORDER \
201  : (__FREQUENCY__ == AUDIO_FREQUENCY_16K) ? DFSDM_FILTER_SINC3_ORDER \
202  : (__FREQUENCY__ == AUDIO_FREQUENCY_22K) ? DFSDM_FILTER_SINC3_ORDER \
203  : (__FREQUENCY__ == AUDIO_FREQUENCY_32K) ? DFSDM_FILTER_SINC4_ORDER \
204  : (__FREQUENCY__ == AUDIO_FREQUENCY_44K) ? DFSDM_FILTER_SINC3_ORDER \
205  : (__FREQUENCY__ == AUDIO_FREQUENCY_48K) ? DFSDM_FILTER_SINC3_ORDER : DFSDM_FILTER_SINC5_ORDER \
206 
207 #define DFSDM_RIGHT_BIT_SHIFT(__FREQUENCY__) \
208  (__FREQUENCY__ == AUDIO_FREQUENCY_8K) ? 8 \
209  : (__FREQUENCY__ == AUDIO_FREQUENCY_11K) ? 8 \
210  : (__FREQUENCY__ == AUDIO_FREQUENCY_16K) ? 3 \
211  : (__FREQUENCY__ == AUDIO_FREQUENCY_22K) ? 4 \
212  : (__FREQUENCY__ == AUDIO_FREQUENCY_32K) ? 7 \
213  : (__FREQUENCY__ == AUDIO_FREQUENCY_44K) ? 0 \
214  : (__FREQUENCY__ == AUDIO_FREQUENCY_48K) ? 0 : 4 \
215 
216 /* Saturate the record PCM sample */
217 #define SaturaLH(N, L, H) (((N)<(L))?(L):(((N)>(H))?(H):(N)))
218 
225 /* PLAY */
229 
230 /* RECORD */
232 
239 
246 
247 /* Buffers for right and left samples */
249 static __IO int32_t ScratchSize;
250 /* Cannel number to be used: 2 channels by default */
252 /* Input device to be used: digital microphones by default */
254 
255 /* Buffers status flags */
256 static uint32_t DmaTopLeftRecHalfCplt = 0;
257 static uint32_t DmaTopLeftRecCplt = 0;
258 static uint32_t DmaTopRightRecHalfCplt = 0;
259 static uint32_t DmaTopRightRecCplt = 0;
260 static uint32_t DmaButtomLeftRecHalfCplt = 0;
261 static uint32_t DmaButtomLeftRecCplt = 0;
262 static uint32_t DmaButtomRightRecHalfCplt = 0;
263 static uint32_t DmaButtomRightRecCplt = 0;
264 
265 /* Application Buffer Trigger */
266 static __IO uint32_t AppBuffTrigger = 0;
267 static __IO uint32_t AppBuffHalf = 0;
268 
276 static void SAIx_Out_Init(uint32_t AudioFreq);
277 static void SAIx_Out_DeInit(void);
278 static void SAI_AUDIO_IN_MspInit(SAI_HandleTypeDef *hsai, void *Params);
279 static void SAI_AUDIO_IN_MspDeInit(SAI_HandleTypeDef *hsai, void *Params);
280 static void SAIx_In_Init(uint32_t AudioFreq);
281 static void SAIx_In_DeInit(void);
282 static void DFSDMx_ChannelMspInit(void);
283 static void DFSDMx_FilterMspInit(void);
284 static void DFSDMx_ChannelMspDeInit(void);
285 static void DFSDMx_FilterMspDeInit(void);
286 static uint8_t DFSDMx_Init(uint32_t AudioFreq);
287 static uint8_t DFSDMx_DeInit(void);
288 
305 uint8_t BSP_AUDIO_OUT_Init(uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq)
306 {
307  uint8_t ret = AUDIO_ERROR;
308  uint32_t deviceid = 0x00;
309 
310  /* Disable SAI */
311  SAIx_Out_DeInit();
312 
313  /* PLL clock is set depending by the AudioFreq (44.1khz vs 48khz groups) */
315 
316  /* SAI data transfer preparation:
317  Prepare the Media to be used for the audio transfer from memory to SAI peripheral */
320  {
321  /* Init the SAI MSP: this __weak function can be redefined by the application*/
323  }
324  SAIx_Out_Init(AudioFreq);
325 
326  /* wm8994 codec initialization */
327  deviceid = wm8994_drv.ReadID(AUDIO_I2C_ADDRESS);
328 
329  if((deviceid) == WM8994_ID)
330  {
331  /* Reset the Codec Registers */
333  /* Initialize the audio driver structure */
334  audio_drv = &wm8994_drv;
335  ret = AUDIO_OK;
336  }
337  else
338  {
339  ret = AUDIO_ERROR;
340  }
341 
342  if(ret == AUDIO_OK)
343  {
344  /* Initialize the codec internal registers */
345  audio_drv->Init(AUDIO_I2C_ADDRESS, OutputDevice, Volume, AudioFreq);
346  }
347 
348  return ret;
349 }
350 
357 uint8_t BSP_AUDIO_OUT_Play(uint16_t* pBuffer, uint32_t Size)
358 {
359  /* Call the audio Codec Play function */
360  if(audio_drv->Play(AUDIO_I2C_ADDRESS, (uint16_t *)pBuffer, Size) != 0)
361  {
362  return AUDIO_ERROR;
363  }
364  else
365  {
366  /* Update the Media layer and enable it for play */
367  HAL_SAI_Transmit_DMA(&haudio_out_sai, (uint8_t*) pBuffer, DMA_MAX(Size / AUDIODATA_SIZE));
368 
369  return AUDIO_OK;
370  }
371 }
372 
379 void BSP_AUDIO_OUT_ChangeBuffer(uint16_t *pData, uint16_t Size)
380 {
381  HAL_SAI_Transmit_DMA(&haudio_out_sai, (uint8_t*) pData, Size);
382 }
383 
392 uint8_t BSP_AUDIO_OUT_Pause(void)
393 {
394  /* Call the Audio Codec Pause/Resume function */
396  {
397  return AUDIO_ERROR;
398  }
399  else
400  {
401  /* Call the Media layer pause function */
403 
404  /* Return AUDIO_OK when all operations are correctly done */
405  return AUDIO_OK;
406  }
407 }
408 
416 uint8_t BSP_AUDIO_OUT_Resume(void)
417 {
418  /* Call the Audio Codec Pause/Resume function */
420  {
421  return AUDIO_ERROR;
422  }
423  else
424  {
425  /* Call the Media layer pause/resume function */
427 
428  /* Return AUDIO_OK when all operations are correctly done */
429  return AUDIO_OK;
430  }
431 }
432 
442 uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option)
443 {
444  /* Call the Media layer stop function */
446 
447  /* Call Audio Codec Stop function */
448  if(audio_drv->Stop(AUDIO_I2C_ADDRESS, Option) != 0)
449  {
450  return AUDIO_ERROR;
451  }
452  else
453  {
454  if(Option == CODEC_PDWN_HW)
455  {
456  /* Wait at least 100us */
457  HAL_Delay(1);
458  }
459  /* Return AUDIO_OK when all operations are correctly done */
460  return AUDIO_OK;
461  }
462 }
463 
470 uint8_t BSP_AUDIO_OUT_SetVolume(uint8_t Volume)
471 {
472  /* Call the codec volume control function with converted volume value */
473  if(audio_drv->SetVolume(AUDIO_I2C_ADDRESS, Volume) != 0)
474  {
475  return AUDIO_ERROR;
476  }
477  else
478  {
479  /* Return AUDIO_OK when all operations are correctly done */
480  return AUDIO_OK;
481  }
482 }
483 
490 uint8_t BSP_AUDIO_OUT_SetMute(uint32_t Cmd)
491 {
492  /* Call the Codec Mute function */
493  if(audio_drv->SetMute(AUDIO_I2C_ADDRESS, Cmd) != 0)
494  {
495  return AUDIO_ERROR;
496  }
497  else
498  {
499  /* Return AUDIO_OK when all operations are correctly done */
500  return AUDIO_OK;
501  }
502 }
503 
511 uint8_t BSP_AUDIO_OUT_SetOutputMode(uint8_t Output)
512 {
513  /* Call the Codec output device function */
515  {
516  return AUDIO_ERROR;
517  }
518  else
519  {
520  /* Return AUDIO_OK when all operations are correctly done */
521  return AUDIO_OK;
522  }
523 }
524 
532 void BSP_AUDIO_OUT_SetFrequency(uint32_t AudioFreq)
533 {
534  /* PLL clock is set depending by the AudioFreq (44.1khz vs 48khz groups) */
536 
537  /* Disable SAI peripheral to allow access to SAI internal registers */
539 
540  /* Update the SAI audio frequency configuration */
541  haudio_out_sai.Init.AudioFrequency = AudioFreq;
543 
544  /* Enable SAI peripheral to generate MCLK */
546 }
547 
555 void BSP_AUDIO_OUT_SetAudioFrameSlot(uint32_t AudioFrameSlot)
556 {
557  /* Disable SAI peripheral to allow access to SAI internal registers */
559 
560  /* Update the SAI audio frame slot configuration */
561  haudio_out_sai.SlotInit.SlotActive = AudioFrameSlot;
563 
564  /* Enable SAI peripheral to generate MCLK */
566 }
567 
573 {
574  SAIx_Out_DeInit();
575  /* DeInit the SAI MSP : this __weak function can be rewritten by the application */
577 }
578 
585 {
586  /* Manage the remaining file size and new address offset: This function
587  should be coded by user (its prototype is already declared in stm32f769i_discovery_audio.h) */
589 }
590 
597 {
598  /* Manage the remaining file size and new address offset: This function
599  should be coded by user (its prototype is already declared in stm32f769i_discovery_audio.h) */
601 }
602 
609 {
610  if(hsai->Instance == AUDIO_OUT_SAIx)
611  {
613  }
614  else
615  {
617  }
618 }
619 
625 {
626 }
627 
633 {
634 }
635 
641 {
642 }
643 
650 __weak void BSP_AUDIO_OUT_MspInit(SAI_HandleTypeDef *hsai, void *Params)
651 {
652  static DMA_HandleTypeDef hdma_sai_tx;
653  GPIO_InitTypeDef gpio_init_structure;
654 
655  /* Enable SAI clock */
657 
658 
659  /* Enable GPIO clock */
662 
663  /* CODEC_SAI pins configuration: FS, SCK, MCK and SD pins ------------------*/
665  gpio_init_structure.Mode = GPIO_MODE_AF_PP;
666  gpio_init_structure.Pull = GPIO_NOPULL;
667  gpio_init_structure.Speed = GPIO_SPEED_HIGH;
668  gpio_init_structure.Alternate = AUDIO_OUT_SAIx_AF;
669  HAL_GPIO_Init(AUDIO_OUT_SAIx_SD_FS_SCK_GPIO_PORT, &gpio_init_structure);
670 
671  gpio_init_structure.Pin = AUDIO_OUT_SAIx_MCLK_PIN;
672  HAL_GPIO_Init(AUDIO_OUT_SAIx_MCLK_GPIO_PORT, &gpio_init_structure);
673 
674  /* Enable the DMA clock */
676 
677  if(hsai->Instance == AUDIO_OUT_SAIx)
678  {
679  /* Configure the hdma_saiTx handle parameters */
681  hdma_sai_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
682  hdma_sai_tx.Init.PeriphInc = DMA_PINC_DISABLE;
683  hdma_sai_tx.Init.MemInc = DMA_MINC_ENABLE;
686  hdma_sai_tx.Init.Mode = DMA_CIRCULAR;
687  hdma_sai_tx.Init.Priority = DMA_PRIORITY_HIGH;
688  hdma_sai_tx.Init.FIFOMode = DMA_FIFOMODE_ENABLE;
690  hdma_sai_tx.Init.MemBurst = DMA_MBURST_SINGLE;
691  hdma_sai_tx.Init.PeriphBurst = DMA_PBURST_SINGLE;
692 
693  hdma_sai_tx.Instance = AUDIO_OUT_SAIx_DMAx_STREAM;
694 
695  /* Associate the DMA handle */
696  __HAL_LINKDMA(hsai, hdmatx, hdma_sai_tx);
697 
698  /* Deinitialize the Stream for new transfer */
699  HAL_DMA_DeInit(&hdma_sai_tx);
700 
701  /* Configure the DMA Stream */
702  HAL_DMA_Init(&hdma_sai_tx);
703  }
704 
705  /* SAI DMA IRQ Channel configuration */
708 }
709 
716 static void SAI_AUDIO_IN_MspInit(SAI_HandleTypeDef *hsai, void *Params)
717 {
718  static DMA_HandleTypeDef hdma_sai_rx;
719  GPIO_InitTypeDef gpio_init_structure;
720 
721  /* Enable SAI clock */
723 
724  /* Enable SD GPIO clock */
726  /* CODEC_SAI pin configuration: SD pin */
727  gpio_init_structure.Pin = AUDIO_IN_SAIx_SD_PIN;
728  gpio_init_structure.Mode = GPIO_MODE_AF_PP;
729  gpio_init_structure.Pull = GPIO_NOPULL;
730  gpio_init_structure.Speed = GPIO_SPEED_FAST;
731  gpio_init_structure.Alternate = AUDIO_IN_SAIx_AF;
732  HAL_GPIO_Init(AUDIO_IN_SAIx_SD_GPIO_PORT, &gpio_init_structure);
733 
734  /* Enable Audio INT GPIO clock */
736  /* Audio INT pin configuration: input */
737  gpio_init_structure.Pin = AUDIO_IN_INT_GPIO_PIN;
738  gpio_init_structure.Mode = GPIO_MODE_INPUT;
739  gpio_init_structure.Pull = GPIO_NOPULL;
740  gpio_init_structure.Speed = GPIO_SPEED_FAST;
741  HAL_GPIO_Init(AUDIO_IN_INT_GPIO_PORT, &gpio_init_structure);
742 
743  /* Enable the DMA clock */
745 
746  if(hsai->Instance == AUDIO_IN_SAIx)
747  {
748  /* Configure the hdma_sai_rx handle parameters */
750  hdma_sai_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
751  hdma_sai_rx.Init.PeriphInc = DMA_PINC_DISABLE;
752  hdma_sai_rx.Init.MemInc = DMA_MINC_ENABLE;
755  hdma_sai_rx.Init.Mode = DMA_CIRCULAR;
756  hdma_sai_rx.Init.Priority = DMA_PRIORITY_HIGH;
757  hdma_sai_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
759  hdma_sai_rx.Init.MemBurst = DMA_MBURST_SINGLE;
760  hdma_sai_rx.Init.PeriphBurst = DMA_MBURST_SINGLE;
761 
762  hdma_sai_rx.Instance = AUDIO_IN_SAIx_DMAx_STREAM;
763 
764  /* Associate the DMA handle */
765  __HAL_LINKDMA(hsai, hdmarx, hdma_sai_rx);
766 
767  /* Deinitialize the Stream for new transfer */
768  HAL_DMA_DeInit(&hdma_sai_rx);
769 
770  /* Configure the DMA Stream */
771  HAL_DMA_Init(&hdma_sai_rx);
772  }
773 
774  /* SAI DMA IRQ Channel configuration */
777 
778  /* Audio INT IRQ Channel configuration */
781 }
782 
789 static void SAI_AUDIO_IN_MspDeInit(SAI_HandleTypeDef *hsai, void *Params)
790 {
791  GPIO_InitTypeDef gpio_init_structure;
792 
793  /* SAI DMA IRQ Channel deactivation */
795 
796  if(hsai->Instance == AUDIO_IN_SAIx)
797  {
798  /* Deinitialize the DMA stream */
799  HAL_DMA_DeInit(hsai->hdmatx);
800  }
801 
802  /* Disable SAI peripheral */
803  __HAL_SAI_DISABLE(hsai);
804 
805  /* Deactivates CODEC_SAI pin SD by putting them in input mode */
806  gpio_init_structure.Pin = AUDIO_IN_SAIx_SD_PIN;
807  HAL_GPIO_DeInit(AUDIO_IN_SAIx_SD_GPIO_PORT, gpio_init_structure.Pin);
808 
809  gpio_init_structure.Pin = AUDIO_IN_INT_GPIO_PIN;
810  HAL_GPIO_DeInit(AUDIO_IN_INT_GPIO_PORT, gpio_init_structure.Pin);
811 
812  /* Disable SAI clock */
814 }
815 
822 __weak void BSP_AUDIO_OUT_MspDeInit(SAI_HandleTypeDef *hsai, void *Params)
823 {
824  GPIO_InitTypeDef gpio_init_structure;
825 
826  /* SAI DMA IRQ Channel deactivation */
828 
829  if(hsai->Instance == AUDIO_OUT_SAIx)
830  {
831  /* Deinitialize the DMA stream */
832  HAL_DMA_DeInit(hsai->hdmatx);
833  }
834 
835  /* Disable SAI peripheral */
836  __HAL_SAI_DISABLE(hsai);
837 
838  /* Deactivates CODEC_SAI pins FS, SCK, MCK and SD by putting them in input mode */
841 
842  gpio_init_structure.Pin = AUDIO_OUT_SAIx_MCLK_PIN;
843  HAL_GPIO_DeInit(AUDIO_OUT_SAIx_MCLK_GPIO_PORT, gpio_init_structure.Pin);
844 
845  /* Disable SAI clock */
847 
848  /* GPIO pins clock and DMA clock can be shut down in the applic
849  by surcharging this __weak function */
850 }
851 
861 __weak void BSP_AUDIO_OUT_ClockConfig(SAI_HandleTypeDef *hsai, uint32_t AudioFreq, void *Params)
862 {
863  RCC_PeriphCLKInitTypeDef rcc_ex_clk_init_struct;
864 
865  HAL_RCCEx_GetPeriphCLKConfig(&rcc_ex_clk_init_struct);
866 
867  /* Set the PLL configuration according to the audio frequency */
868  if((AudioFreq == AUDIO_FREQUENCY_11K) || (AudioFreq == AUDIO_FREQUENCY_22K) || (AudioFreq == AUDIO_FREQUENCY_44K))
869  {
870  /* Configure PLLSAI prescalers */
871  /* PLLSAI_VCO: VCO_429M
872  SAI_CLK(first level) = PLLSAI_VCO/PLLSAIQ = 429/2 = 214.5 Mhz
873  SAI_CLK_x = SAI_CLK(first level)/PLLSAIDIVQ = 214.5/19 = 11.289 Mhz */
874  rcc_ex_clk_init_struct.PeriphClockSelection = RCC_PERIPHCLK_SAI1;
875  rcc_ex_clk_init_struct.Sai1ClockSelection = RCC_SAI1CLKSOURCE_PLLI2S;
876  rcc_ex_clk_init_struct.PLLI2S.PLLI2SN = 429;
877  rcc_ex_clk_init_struct.PLLI2S.PLLI2SQ = 2;
878  rcc_ex_clk_init_struct.PLLI2SDivQ = 19;
879 
880  HAL_RCCEx_PeriphCLKConfig(&rcc_ex_clk_init_struct);
881 
882  }
883  else /* AUDIO_FREQUENCY_8K, AUDIO_FREQUENCY_16K, AUDIO_FREQUENCY_48K, AUDIO_FREQUENCY_96K */
884  {
885  /* SAI clock config
886  PLLSAI_VCO: VCO_344M
887  SAI_CLK(first level) = PLLSAI_VCO/PLLSAIQ = 344/7 = 49.142 Mhz
888  SAI_CLK_x = SAI_CLK(first level)/PLLSAIDIVQ = 49.142/1 = 49.142 Mhz */
889  rcc_ex_clk_init_struct.PeriphClockSelection = RCC_PERIPHCLK_SAI1;
890  rcc_ex_clk_init_struct.Sai1ClockSelection = RCC_SAI1CLKSOURCE_PLLI2S;
891  rcc_ex_clk_init_struct.PLLI2S.PLLI2SN = 344;
892  rcc_ex_clk_init_struct.PLLI2S.PLLI2SQ = 7;
893  rcc_ex_clk_init_struct.PLLI2SDivQ = 1;
894 
895  HAL_RCCEx_PeriphCLKConfig(&rcc_ex_clk_init_struct);
896  }
897 }
898 
899 /*******************************************************************************
900  Static Functions
901 *******************************************************************************/
902 
910 static void SAIx_Out_Init(uint32_t AudioFreq)
911 {
912  /* Initialize the haudio_out_sai Instance parameter */
914 
915  /* Disable SAI peripheral to allow access to SAI internal registers */
917 
918  /* Configure SAI_Block_x
919  LSBFirst: Disabled
920  DataSize: 16 */
922  haudio_out_sai.Init.AudioFrequency = AudioFreq;
936 
937  /* Configure SAI_Block_x Frame
938  Frame Length: 64
939  Frame active Length: 32
940  FS Definition: Start frame + Channel Side identification
941  FS Polarity: FS active Low
942  FS Offset: FS asserted one bit before the first bit of slot 0 */
948 
949  /* Configure SAI Block_x Slot
950  Slot First Bit Offset: 0
951  Slot Size : 16
952  Slot Number: 4
953  Slot Active: All slot actives */
958 
960 
961  /* Enable SAI peripheral to generate MCLK */
963 }
964 
969 static void SAIx_Out_DeInit(void)
970 {
971  /* Initialize the haudio_out_sai Instance parameter */
973 
974  /* Disable SAI peripheral */
976 
978 }
979 
987 static void SAIx_In_Init(uint32_t AudioFreq)
988 {
989  /* Initialize SAI1 block A in MASTER TX */
990  /* Initialize the haudio_out_sai Instance parameter */
992 
993  /* Disable SAI peripheral to allow access to SAI internal registers */
995 
996  /* Configure SAI_Block_x
997  LSBFirst: Disabled
998  DataSize: 16 */
1000  haudio_out_sai.Init.AudioFrequency = AudioFreq;
1013  haudio_out_sai.Init.Mckdiv = 0;
1014 
1015  /* Configure SAI_Block_x Frame
1016  Frame Length: 64
1017  Frame active Length: 32
1018  FS Definition: Start frame + Channel Side identification
1019  FS Polarity: FS active Low
1020  FS Offset: FS asserted one bit before the first bit of slot 0 */
1026 
1027  /* Configure SAI Block_x Slot
1028  Slot First Bit Offset: 0
1029  Slot Size : 16
1030  Slot Number: 4
1031  Slot Active: All slot actives */
1036 
1038 
1039  /* Initialize SAI1 block B in SLAVE RX synchronous from SAI1 block A */
1040  /* Initialize the haudio_in_sai Instance parameter */
1042 
1043  /* Disable SAI peripheral to allow access to SAI internal registers */
1045 
1046  /* Configure SAI_Block_x
1047  LSBFirst: Disabled
1048  DataSize: 16 */
1050  haudio_in_sai.Init.AudioFrequency = AudioFreq;
1064 
1065  /* Configure SAI_Block_x Frame
1066  Frame Length: 64
1067  Frame active Length: 32
1068  FS Definition: Start frame + Channel Side identification
1069  FS Polarity: FS active Low
1070  FS Offset: FS asserted one bit before the first bit of slot 0 */
1076 
1077  /* Configure SAI Block_x Slot
1078  Slot First Bit Offset: 0
1079  Slot Size : 16
1080  Slot Number: 4
1081  Slot Active: All slot active */
1086 
1088 
1089  /* Enable SAI peripheral */
1091 
1092  /* Enable SAI peripheral to generate MCLK */
1094 }
1095 
1100 static void SAIx_In_DeInit(void)
1101 {
1102  /* Initialize the haudio_in_sai Instance parameter */
1105  /* Disable SAI peripheral */
1107 
1110 }
1111 
1127 uint8_t BSP_AUDIO_IN_Init(uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr)
1128 {
1129  return BSP_AUDIO_IN_InitEx(INPUT_DEVICE_DIGITAL_MIC, AudioFreq, BitRes, ChnlNbr);
1130 }
1131 
1140 uint8_t BSP_AUDIO_IN_InitEx(uint16_t InputDevice, uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr)
1141 {
1142  uint8_t ret = AUDIO_ERROR;
1143  AudioIn_Device = InputDevice;
1144 
1145  if(InputDevice == INPUT_DEVICE_DIGITAL_MIC)
1146  {
1147  AudioIn_ChannelNumber = ChnlNbr;
1148  /* PLL clock is set depending by the AudioFreq (44.1khz vs 48khz groups) */
1150 
1151  /* Init the SAI MSP: this __weak function can be redefined by the application*/
1153 
1154  /* Initializes DFSDM peripheral */
1155  DFSDMx_Init(AudioFreq);
1156  ret = AUDIO_OK;
1157  }
1158  else
1159  {
1160  /* Disable SAI */
1161  SAIx_In_DeInit();
1162 
1163  /* PLL clock is set depending by the AudioFreq (44.1khz vs 48khz groups) */
1165 
1168  {
1171  }
1172 
1173  SAIx_In_Init(AudioFreq);
1174 
1176  {
1177  /* Reset the Codec Registers */
1179  /* Initialize the audio driver structure */
1180  audio_drv = &wm8994_drv;
1181  ret = AUDIO_OK;
1182  }
1183  else
1184  {
1185  ret = AUDIO_ERROR;
1186  }
1187 
1188  if(ret == AUDIO_OK)
1189  {
1190  /* Initialize the codec internal registers */
1191  audio_drv->Init(AUDIO_I2C_ADDRESS, InputDevice, 100, AudioFreq);
1192  }
1193  }
1194 
1195  /* Return AUDIO_OK when all operations are correctly done */
1196  return ret;
1197 }
1198 
1204 uint8_t BSP_AUDIO_IN_AllocScratch (int32_t *pScratch, uint32_t size)
1205 {
1206  uint32_t idx;
1207 
1209 
1210  /* copy scratch pointers */
1211  for (idx = 0; idx < AudioIn_ChannelNumber; idx++)
1212  {
1213  pScratchBuff[idx] = (int32_t *)(pScratch + (idx * ScratchSize));
1214  }
1215  /* Return AUDIO_OK */
1216  return AUDIO_OK;
1217 }
1218 
1224 {
1225  return AudioIn_ChannelNumber;
1226 }
1227 
1234 uint8_t BSP_AUDIO_IN_Record(uint16_t* pbuf, uint32_t size)
1235 {
1237  {
1238  hAudioIn.pRecBuf = pbuf;
1239  hAudioIn.RecSize = size;
1240  /* Reset Application Buffer Trigger */
1241  AppBuffTrigger = 0;
1242  AppBuffHalf = 0;
1243 
1244  if(AudioIn_ChannelNumber > 2)
1245  {
1246  /* Call the Media layer start function for buttom right channel */
1248  {
1249  return AUDIO_ERROR;
1250  }
1251 
1252  /* Call the Media layer start function for buttom left channel */
1254  {
1255  return AUDIO_ERROR;
1256  }
1257  }
1258 
1259  /* Call the Media layer start function for top right channel */
1261  {
1262  return AUDIO_ERROR;
1263  }
1264 
1265  /* Call the Media layer start function for top left channel */
1267  {
1268  return AUDIO_ERROR;
1269  }
1270  }
1271  else
1272  {
1273  /* Start the process receive DMA */
1274  if(HAL_OK !=HAL_SAI_Receive_DMA(&haudio_in_sai, (uint8_t*)pbuf, size))
1275  {
1276  return AUDIO_ERROR;
1277  }
1278  }
1279  /* Return AUDIO_OK when all operations are correctly done */
1280  return AUDIO_OK;
1281 }
1282 
1287 uint8_t BSP_AUDIO_IN_Stop(void)
1288 {
1290  {
1291  AppBuffTrigger = 0;
1292  AppBuffHalf = 0;
1293 
1294  if(AudioIn_ChannelNumber > 2)
1295  {
1296  /* Call the Media layer stop function for buttom right channel */
1298  {
1299  return AUDIO_ERROR;
1300  }
1301 
1302  /* Call the Media layer stop function for buttom left channel */
1304  {
1305  return AUDIO_ERROR;
1306  }
1307  }
1308 
1309  /* Call the Media layer stop function for top right channel */
1311  {
1312  return AUDIO_ERROR;
1313  }
1314 
1315  /* Call the Media layer stop function for top left channel */
1317  {
1318  return AUDIO_ERROR;
1319  }
1320  }
1321  else
1322  {
1323  /* Call the Media layer stop function */
1325 
1326  /* Call Audio Codec Stop function */
1328  {
1329  return AUDIO_ERROR;
1330  }
1331  else
1332  {
1333  /* Wait at least 100us */
1334  HAL_Delay(1);
1335 
1336  /* Return AUDIO_OK when all operations are correctly done */
1337  return AUDIO_OK;
1338  }
1339  }
1340  /* Return AUDIO_OK when all operations are correctly done */
1341  return AUDIO_OK;
1342 }
1343 
1348 uint8_t BSP_AUDIO_IN_Pause(void)
1349 {
1350  if(AudioIn_ChannelNumber > 2)
1351  {
1352  /* Call the Media layer stop function */
1354  {
1355  return AUDIO_ERROR;
1356  }
1357 
1358  /* Call the Media layer stop function */
1360  {
1361  return AUDIO_ERROR;
1362  }
1363  }
1364  /* Call the Media layer stop function */
1366  {
1367  return AUDIO_ERROR;
1368  }
1369 
1370  /* Call the Media layer stop function */
1372  {
1373  return AUDIO_ERROR;
1374  }
1375 
1376  /* Return AUDIO_OK when all operations are correctly done */
1377  return AUDIO_OK;
1378 }
1379 
1384 uint8_t BSP_AUDIO_IN_Resume(void)
1385 {
1386  if(AudioIn_ChannelNumber > 2)
1387  {
1388  /* Call the Media layer start function for buttom right channel */
1390  {
1391  return AUDIO_ERROR;
1392  }
1393 
1394  /* Call the Media layer start function for buttom left channel */
1396  {
1397  return AUDIO_ERROR;
1398  }
1399  }
1400  /* Call the Media layer start function for top right channel */
1402  {
1403  return AUDIO_ERROR;
1404  }
1405 
1406  /* Call the Media layer start function for top left channel */
1408  {
1409  return AUDIO_ERROR;
1410  }
1411 
1412  /* Return AUDIO_OK when all operations are correctly done */
1413  return AUDIO_OK;
1414 }
1415 
1421 {
1423 
1425  {
1426  DFSDMx_DeInit();
1427  }
1428  else
1429  {
1430  SAIx_In_DeInit();
1431  }
1432 }
1433 
1442 {
1443  uint32_t index = 0;
1444 
1445  if(hdfsdm_filter == &hAudioInTopLeftFilter)
1446  {
1447  DmaTopLeftRecCplt = 1;
1448  }
1449  else if(hdfsdm_filter == &hAudioInTopRightFilter)
1450  {
1451  DmaTopRightRecCplt = 1;
1452  }
1453  else if(hdfsdm_filter == &hAudioInButtomLeftFilter)
1454  {
1456  }
1457  else
1458  {
1460  }
1461 
1462  if(AudioIn_ChannelNumber > 2)
1463  {
1464  if((DmaTopLeftRecCplt == 1) && (DmaTopRightRecCplt == 1) && (DmaButtomLeftRecCplt == 1) && (DmaButtomRightRecCplt == 1))
1465  {
1466  for(index = (ScratchSize/2) ; index < ScratchSize; index++)
1467  {
1468  hAudioIn.pRecBuf[AppBuffTrigger] = (uint16_t)(SaturaLH((pScratchBuff[1][index] >> 8), -32760, 32760));
1469  hAudioIn.pRecBuf[AppBuffTrigger + 1] = (uint16_t)(SaturaLH((pScratchBuff[0][index] >> 8), -32760, 32760));
1470  hAudioIn.pRecBuf[AppBuffTrigger + 2] = (uint16_t)(SaturaLH((pScratchBuff[3][index] >> 8), -32760, 32760));
1471  hAudioIn.pRecBuf[AppBuffTrigger + 3] = (uint16_t)(SaturaLH((pScratchBuff[2][index] >> 8), -32760, 32760));
1472  AppBuffTrigger +=4;
1473  }
1474  DmaTopLeftRecCplt = 0;
1475  DmaTopRightRecCplt = 0;
1477  DmaButtomRightRecCplt = 0;
1478  }
1479  }
1480  else
1481  {
1482  if((DmaTopLeftRecCplt == 1) && (DmaTopRightRecCplt == 1))
1483  {
1484  for(index = (ScratchSize/2) ; index < ScratchSize; index++)
1485  {
1486  hAudioIn.pRecBuf[AppBuffTrigger] = (uint16_t)(SaturaLH((pScratchBuff[1][index] >> 8), -32760, 32760));
1487  hAudioIn.pRecBuf[AppBuffTrigger + 1] = (uint16_t)(SaturaLH((pScratchBuff[0][index] >> 8), -32760, 32760));
1488  AppBuffTrigger +=2;
1489  }
1490  DmaTopLeftRecCplt = 0;
1491  DmaTopRightRecCplt = 0;
1492  }
1493  }
1494 
1495  /* Call Half Transfer Complete callback */
1496  if((AppBuffTrigger == hAudioIn.RecSize/2) && (AppBuffHalf == 0))
1497  {
1498  AppBuffHalf = 1;
1500  }
1501  /* Call Transfer Complete callback */
1503  {
1504  /* Reset Application Buffer Trigger */
1505  AppBuffTrigger = 0;
1506  AppBuffHalf = 0;
1507  /* Call the record update function to get the next buffer to fill and its size (size is ignored) */
1509  }
1510 }
1511 
1518 {
1519  uint32_t index = 0;
1520 
1521  if(hdfsdm_filter == &hAudioInTopLeftFilter)
1522  {
1524  }
1525  else if(hdfsdm_filter == &hAudioInTopRightFilter)
1526  {
1528  }
1529  else if(hdfsdm_filter == &hAudioInButtomLeftFilter)
1530  {
1532  }
1533  else
1534  {
1536  }
1537 
1538  if(AudioIn_ChannelNumber > 2)
1539  {
1541  {
1542  for(index = 0 ; index < ScratchSize/2; index++)
1543  {
1544  hAudioIn.pRecBuf[AppBuffTrigger] = (uint16_t)(SaturaLH((pScratchBuff[1][index] >> 8), -32760, 32760));
1545  hAudioIn.pRecBuf[AppBuffTrigger + 1] = (uint16_t)(SaturaLH((pScratchBuff[0][index] >> 8), -32760, 32760));
1546  hAudioIn.pRecBuf[AppBuffTrigger + 2] = (uint16_t)(SaturaLH((pScratchBuff[3][index] >> 8), -32760, 32760));
1547  hAudioIn.pRecBuf[AppBuffTrigger + 3] = (uint16_t)(SaturaLH((pScratchBuff[2][index] >> 8), -32760, 32760));
1548  AppBuffTrigger +=4;
1549  }
1554  }
1555  }
1556  else
1557  {
1558  if((DmaTopLeftRecHalfCplt == 1) && (DmaTopRightRecHalfCplt == 1))
1559  {
1560  for(index = 0 ; index < ScratchSize/2; index++)
1561  {
1562  hAudioIn.pRecBuf[AppBuffTrigger] = (uint16_t)(SaturaLH((pScratchBuff[1][index] >> 8), -32760, 32760));
1563  hAudioIn.pRecBuf[AppBuffTrigger + 1] = (uint16_t)(SaturaLH((pScratchBuff[0][index] >> 8), -32760, 32760));
1564  AppBuffTrigger +=2;
1565  }
1568  }
1569  }
1570 
1571  /* Call Half Transfer Complete callback */
1572  if((AppBuffTrigger == hAudioIn.RecSize/2) && (AppBuffHalf == 0))
1573  {
1574  AppBuffHalf = 1;
1576  }
1577  /* Call Transfer Complete callback */
1579  {
1580  /* Reset Application Buffer Trigger */
1581  AppBuffTrigger = 0;
1582  AppBuffHalf = 0;
1583  /* Call the record update function to get the next buffer to fill and its size (size is ignored) */
1585  }
1586 }
1587 
1594 {
1595  /* Manage the remaining file size and new address offset: This function
1596  should be coded by user (its prototype is already declared in stm32769i_discovery_audio.h) */
1598 }
1599 
1606 {
1607  /* Call the record update function to get the next buffer to fill and its size (size is ignored) */
1609 }
1610 
1616 {
1617  /* This function should be implemented by the user application.
1618  It is called into this driver when the current buffer is filled
1619  to prepare the next buffer pointer and its size. */
1620 }
1621 
1627 {
1628  /* This function should be implemented by the user application.
1629  It is called into this driver when the current buffer is filled
1630  to prepare the next buffer pointer and its size. */
1631 }
1632 
1638 {
1639  /* This function is called when an Interrupt due to transfer error on or peripheral
1640  error occurs. */
1641 }
1642 
1647 __weak void BSP_AUDIO_IN_MspInit(void)
1648 {
1650  {
1651  /* MSP channels initialization */
1653  /* MSP filters initialization */
1655  }
1656  else
1657  {
1659  }
1660 }
1661 
1666 __weak void BSP_AUDIO_IN_MspDeInit(void)
1667 {
1669  {
1670  /* MSP channels initialization */
1672  /* MSP filters initialization */
1674  }
1675  else
1676  {
1678  }
1679 }
1680 
1690 __weak void BSP_AUDIO_IN_ClockConfig(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, uint32_t AudioFreq, void *Params)
1691 {
1692  RCC_PeriphCLKInitTypeDef rcc_ex_clk_init_struct;
1693 
1694  HAL_RCCEx_GetPeriphCLKConfig(&rcc_ex_clk_init_struct);
1695 
1696  /* Set the PLL configuration according to the audio frequency */
1697  if((AudioFreq == AUDIO_FREQUENCY_11K) || (AudioFreq == AUDIO_FREQUENCY_22K) || (AudioFreq == AUDIO_FREQUENCY_44K))
1698  {
1699  /* Configure PLLSAI prescalers */
1700  /* PLLI2S_VCO: VCO_429M
1701  SAI_CLK(first level) = PLLI2S_VCO/PLLI2SQ = 429/2 = 214.5 Mhz
1702  SAI_CLK_x = SAI_CLK(first level)/PLLI2SDIVQ = 214.5/19 = 11.289 Mhz */
1703  rcc_ex_clk_init_struct.PeriphClockSelection = RCC_PERIPHCLK_SAI2;
1704  rcc_ex_clk_init_struct.Sai2ClockSelection = RCC_SAI2CLKSOURCE_PLLI2S;
1705  rcc_ex_clk_init_struct.PLLI2S.PLLI2SN = 429;
1706  rcc_ex_clk_init_struct.PLLI2S.PLLI2SQ = 2;
1707  rcc_ex_clk_init_struct.PLLI2SDivQ = 19;
1708 
1709  HAL_RCCEx_PeriphCLKConfig(&rcc_ex_clk_init_struct);
1710 
1711  }
1712  else /* AUDIO_FREQUENCY_8K, AUDIO_FREQUENCY_16K, AUDIO_FREQUENCY_32K, AUDIO_FREQUENCY_48K, AUDIO_FREQUENCY_96K */
1713  {
1714  /* SAI clock config
1715  PLLI2S_VCO: VCO_344M
1716  SAI_CLK(first level) = PLLI2S_VCO/PLLI2SQ = 344/7 = 49.142 Mhz
1717  SAI_CLK_x = SAI_CLK(first level)/PLLI2SDIVQ = 49.142/1 = 49.142 Mhz */
1718  rcc_ex_clk_init_struct.PeriphClockSelection = RCC_PERIPHCLK_SAI2;
1719  rcc_ex_clk_init_struct.Sai2ClockSelection = RCC_SAI2CLKSOURCE_PLLI2S;
1720  rcc_ex_clk_init_struct.PLLI2S.PLLI2SN = 344;
1721  rcc_ex_clk_init_struct.PLLI2S.PLLI2SQ = 7;
1722  rcc_ex_clk_init_struct.PLLI2SDivQ = 1;
1723  HAL_RCCEx_PeriphCLKConfig(&rcc_ex_clk_init_struct);
1724  }
1725 
1726  rcc_ex_clk_init_struct.PeriphClockSelection = RCC_PERIPHCLK_DFSDM1_AUDIO;
1727  rcc_ex_clk_init_struct.Dfsdm1AudioClockSelection = RCC_DFSDM1AUDIOCLKSOURCE_SAI2;
1728  HAL_RCCEx_PeriphCLKConfig(&rcc_ex_clk_init_struct);
1729 }
1730 
1731 /*******************************************************************************
1732  Static Functions
1733 *******************************************************************************/
1743 static uint8_t DFSDMx_Init(uint32_t AudioFreq)
1744 {
1745  /****************************************************************************/
1746  /********************** Channels configuration *****************************/
1747  /****************************************************************************/
1748  /* CHANNEL 1 configuration */
1753  /* Set the DFSDM clock OUT audio frequency configuration */
1758  /* Request to sample stable data for LEFT micro on Rising edge */
1766  {
1767  return AUDIO_ERROR;
1768  }
1769 
1770  /* CHANNEL 0 configuration */
1775  /* Set the DFSDM clock OUT audio frequency configuration */
1780  /* Request to sample stable data for RIGHT micro on Falling edge */
1788  {
1789  return AUDIO_ERROR;
1790  }
1791 
1792  if(AudioIn_ChannelNumber > 2)
1793  {
1794  /* CHANNEL 5 configuration */
1799  /* Set the DFSDM clock OUT audio frequency configuration */
1804  /* Request to sample stable data for LEFT micro on Rising edge */
1812  {
1813  return AUDIO_ERROR;
1814  }
1815 
1816  /* CHANNEL 4 configuration */
1821  /* Set the DFSDM clock OUT audio frequency configuration */
1826  /* Request to sample stable data for RIGHT micro on Falling edge */
1834  {
1835  return AUDIO_ERROR;
1836  }
1837  }
1838  /****************************************************************************/
1839  /********************** Filters configuration ******************************/
1840  /****************************************************************************/
1841 
1842  /* FILTER 0 configuration */
1854  /* Set the DFSDM Filters Oversampling to have correct sample rate */
1858  {
1859  return AUDIO_ERROR;
1860  }
1861 
1862  /* Configure injected channel */
1864  {
1865  return AUDIO_ERROR;
1866  }
1867 
1868  /* FILTER 1 configuration */
1880  /* Set the DFSDM Filters Oversampling to have correct sample rate */
1884  {
1885  return AUDIO_ERROR;
1886  }
1887  /* Configure injected channel */
1889  {
1890  return AUDIO_ERROR;
1891  }
1892 
1893  if(AudioIn_ChannelNumber > 2)
1894  {
1895  /* FILTER 2 configuration */
1907  /* Set the DFSDM Filters Oversampling to have correct sample rate */
1911  {
1912  return AUDIO_ERROR;
1913  }
1914 
1915  /* Configure injected channel */
1917  {
1918  return AUDIO_ERROR;
1919  }
1920 
1921  /* FILTER 3 configuration */
1933  /* Set the DFSDM Filters Oversampling to have correct sample rate */
1937  {
1938  return AUDIO_ERROR;
1939  }
1940  /* Configure injected channel */
1942  {
1943  return AUDIO_ERROR;
1944  }
1945  }
1946  return AUDIO_OK;
1947 }
1948 
1953 static uint8_t DFSDMx_DeInit(void)
1954 {
1955  /* De-initializes the DFSDM filters to allow access to DFSDM internal registers */
1957  {
1958  return AUDIO_ERROR;
1959  }
1960 
1962  {
1963  return AUDIO_ERROR;
1964  }
1965 
1966  /* De-initializes the DFSDM channels to allow access to DFSDM internal registers */
1968  {
1969  return AUDIO_ERROR;
1970  }
1971 
1973  {
1974  return AUDIO_ERROR;
1975  }
1976 
1977  if(AudioIn_ChannelNumber > 2)
1978  {
1979  /* De-initializes the DFSDM filters to allow access to DFSDM internal registers */
1981  {
1982  return AUDIO_ERROR;
1983  }
1984 
1986  {
1987  return AUDIO_ERROR;
1988  }
1989 
1990  /* De-initializes the DFSDM channels to allow access to DFSDM internal registers */
1992  {
1993  return AUDIO_ERROR;
1994  }
1995 
1997  {
1998  return AUDIO_ERROR;
1999  }
2000  }
2001 
2002  return AUDIO_OK;
2003 }
2004 
2009 static void DFSDMx_ChannelMspInit(void)
2010 {
2011  GPIO_InitTypeDef GPIO_InitStruct;
2012 
2013  /* Enable DFSDM clock */
2015 
2016  /* Enable GPIO clock */
2019 
2020  /* DFSDM pins configuration: DFSDM_CKOUT, DMIC_DATIN1 pins ------------------*/
2021  GPIO_InitStruct.Pin = AUDIO_DFSDMx_CKOUT_PIN;
2022  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
2023  GPIO_InitStruct.Pull = GPIO_NOPULL;
2024  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
2025  GPIO_InitStruct.Alternate = AUDIO_DFSDMx_CKOUT_AF;
2027 
2028  /* DFSDM pin configuration: DMIC_DATIN1 pin --------------------------------*/
2029  GPIO_InitStruct.Pin = AUDIO_DFSDMx_DMIC_DATIN1_PIN;
2030  GPIO_InitStruct.Alternate = AUDIO_DFSDMx_DMIC_DATIN_AF;
2032 
2033  if(AudioIn_ChannelNumber > 2)
2034  {
2035  /* DFSDM pin configuration: DMIC_DATIN5 pin --------------------------------*/
2036  GPIO_InitStruct.Pin = AUDIO_DFSDMx_DMIC_DATIN5_PIN;
2037  GPIO_InitStruct.Alternate = AUDIO_DFSDMx_DMIC_DATIN_AF;
2039  }
2040 }
2041 
2046 static void DFSDMx_ChannelMspDeInit(void)
2047 {
2048  GPIO_InitTypeDef GPIO_InitStruct;
2049 
2050  /* DFSDM pin configuration: DMIC_DATIN1 pin --------------------------------*/
2051  GPIO_InitStruct.Pin = AUDIO_DFSDMx_CKOUT_PIN;
2053  GPIO_InitStruct.Pin = AUDIO_DFSDMx_DMIC_DATIN1_PIN;
2055 
2056  if(AudioIn_ChannelNumber > 2)
2057  {
2058  /* DFSDM pin configuration: DMIC_DATIN5 pin ------------------------------*/
2059  GPIO_InitStruct.Pin = AUDIO_DFSDMx_CKOUT_PIN;
2061  GPIO_InitStruct.Pin = AUDIO_DFSDMx_DMIC_DATIN5_PIN;
2063  }
2064 }
2065 
2070 static void DFSDMx_FilterMspInit(void)
2071 {
2072  /* Enable DFSDM clock */
2074 
2075  /* Enable the DMA clock */
2077 
2078  /*********** Configure DMA stream for TOP LEFT microphone *******************/
2088 
2089  /* Associate the DMA handle */
2091 
2092  /* Reset DMA handle state */
2094 
2095  /* Configure the DMA Channel */
2097 
2098  /* DMA IRQ Channel configuration */
2101 
2102 
2103  /*********** Configure DMA stream for TOP RIGHT microphone ******************/
2113 
2114  /* Associate the DMA handle */
2116 
2117  /* Reset DMA handle state */
2119 
2120  /* Configure the DMA Channel */
2122 
2123  /* DMA IRQ Channel configuration */
2126 
2127  if(AudioIn_ChannelNumber > 2)
2128  {
2129  /*********** Configure DMA stream for BUTTOM LEFT microphone ****************/
2139 
2140  /* Associate the DMA handle */
2142 
2143  /* Reset DMA handle state */
2145 
2146  /* Configure the DMA Channel */
2148 
2149  /* DMA IRQ Channel configuration */
2152 
2153 
2154  /*********** Configure DMA stream for BUTTOM RIGHT microphone ***************/
2164 
2165  /* Associate the DMA handle */
2167 
2168  /* Reset DMA handle state */
2170 
2171  /* Configure the DMA Channel */
2173 
2174  /* DMA IRQ Channel configuration */
2177  }
2178 }
2179 
2184 static void DFSDMx_FilterMspDeInit(void)
2185 {
2186  /* Configure the DMA Channel */
2189  if(AudioIn_ChannelNumber > 2)
2190  {
2193  }
2194 }
2195 
2212 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
__HAL_DMA_RESET_HANDLE_STATE
#define __HAL_DMA_RESET_HANDLE_STATE(__HANDLE__)
Reset DMA handle state.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:397
DmaTopRightRecHalfCplt
static uint32_t DmaTopRightRecHalfCplt
Definition: stm32f769i_discovery_audio.c:258
SAI_InitTypeDef::MonoStereoMode
uint32_t MonoStereoMode
Definition: stm32f7xx_hal_sai.h:105
DMA_InitTypeDef::Channel
uint32_t Channel
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:51
RCC_PeriphCLKInitTypeDef::PLLI2SDivQ
uint32_t PLLI2SDivQ
Definition: stm32f7xx_hal_rcc_ex.h:137
AUDIO_IN_SAIx_DMAx_CHANNEL
#define AUDIO_IN_SAIx_DMAx_CHANNEL
Definition: stm32f769i_discovery_audio.h:151
DFSDMx_FilterMspDeInit
static void DFSDMx_FilterMspDeInit(void)
DeInitialize the DFSDM filter MSP.
Definition: stm32f769i_discovery_audio.c:2184
AUDIO_DFSDMx_DMIC_DATIN_GPIO_PORT
#define AUDIO_DFSDMx_DMIC_DATIN_GPIO_PORT
Definition: stm32f769i_discovery_audio.h:178
__HAL_LINKDMA
#define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:66
AUDIO_IN_INT_GPIO_PIN
#define AUDIO_IN_INT_GPIO_PIN
Definition: stm32f769i_discovery_audio.h:158
__IO
#define __IO
Definition: imxrt1050/imxrt1050-evkb/CMSIS/core_cm7.h:237
GPIO_MODE_AF_PP
#define GPIO_MODE_AF_PP
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:122
SAI_FREE_PROTOCOL
#define SAI_FREE_PROTOCOL
Definition: stm32f7xx_hal_sai.h:350
AUDIO_IN_SAIx_DMAx_IRQ
#define AUDIO_IN_SAIx_DMAx_IRQ
Definition: stm32f769i_discovery_audio.h:152
AUDIO_FREQUENCY_11K
#define AUDIO_FREQUENCY_11K
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/cs43l22/cs43l22.h:100
SAI_InitTypeDef::ClockStrobing
uint32_t ClockStrobing
Definition: stm32f7xx_hal_sai.h:126
SAI_FIFOTHRESHOLD_1QF
#define SAI_FIFOTHRESHOLD_1QF
Definition: stm32f7xx_hal_sai.h:501
SAI_OUTPUT_RELEASED
#define SAI_OUTPUT_RELEASED
Definition: stm32f7xx_hal_sai.h:492
DMA_PINC_DISABLE
#define DMA_PINC_DISABLE
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:240
HAL_SAI_ErrorCallback
void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai)
SAI error callbacks.
Definition: stm32f769i_discovery_audio.c:608
DFSDM_CHANNEL_EXTERNAL_INPUTS
#define DFSDM_CHANNEL_EXTERNAL_INPUTS
Definition: stm32h7xx_hal_dfsdm.h:314
DFSDM_CONTINUOUS_CONV_ON
#define DFSDM_CONTINUOUS_CONV_ON
Definition: stm32h7xx_hal_dfsdm.h:501
DFSDM_Channel_InitTypeDef::OutputClock
DFSDM_Channel_OutputClockTypeDef OutputClock
Definition: stm32h7xx_hal_dfsdm.h:106
HAL_NVIC_EnableIRQ
void HAL_NVIC_EnableIRQ(IRQn_Type IRQn)
SAI_InitTypeDef::Mckdiv
uint32_t Mckdiv
Definition: stm32f7xx_hal_sai.h:100
SAI_OUTPUTDRIVE_DISABLE
#define SAI_OUTPUTDRIVE_DISABLE
Definition: stm32f7xx_hal_sai.h:402
HAL_SAI_DMAStop
HAL_StatusTypeDef HAL_SAI_DMAStop(SAI_HandleTypeDef *hsai)
DISABLE
@ DISABLE
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:193
DFSDM_CHANNEL_STANDARD_MODE
#define DFSDM_CHANNEL_STANDARD_MODE
Definition: stm32h7xx_hal_dfsdm.h:324
SAI_CLOCKSTROBING_FALLINGEDGE
#define SAI_CLOCKSTROBING_FALLINGEDGE
Definition: stm32f7xx_hal_sai.h:382
AUDIO_DFSDMx_TOP_LEFT_FILTER
#define AUDIO_DFSDMx_TOP_LEFT_FILTER
Definition: stm32f769i_discovery_audio.h:167
SAI_InitTypeDef::CompandingMode
uint32_t CompandingMode
Definition: stm32f7xx_hal_sai.h:108
BSP_AUDIO_IN_MspInit
__weak void BSP_AUDIO_IN_MspInit(void)
Initialize BSP_AUDIO_IN MSP.
Definition: stm32f769i_discovery_audio.c:1647
BSP_AUDIO_OUT_ClockConfig
__weak void BSP_AUDIO_OUT_ClockConfig(SAI_HandleTypeDef *hsai, uint32_t AudioFreq, void *Params)
Clock Config.
Definition: stm32f769i_discovery_audio.c:861
AUDIO_OUT_SAIx_DMAx_MEM_DATA_SIZE
#define AUDIO_OUT_SAIx_DMAx_MEM_DATA_SIZE
Definition: stm32f769i_discovery_audio.h:128
DFSDM_Channel_InputTypeDef::DataPacking
uint32_t DataPacking
Definition: stm32h7xx_hal_dfsdm.h:73
SAI_FrameInitTypeDef::ActiveFrameLength
uint32_t ActiveFrameLength
Definition: stm32f7xx_hal_sai.h:146
__DMA_HandleTypeDef
DMA handle Structure definition.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:139
NULL
#define NULL
Definition: porcupine/demo/c/dr_libs/tests/external/miniaudio/extras/speex_resampler/thirdparty/resample.c:92
DEFAULT_AUDIO_IN_CHANNEL_NBR
#define DEFAULT_AUDIO_IN_CHANNEL_NBR
Definition: stm32f4_discovery_audio.h:156
HAL_DFSDM_FilterDeInit
HAL_StatusTypeDef HAL_DFSDM_FilterDeInit(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
AUDIO_DrvTypeDef::Play
uint32_t(* Play)(uint16_t, uint16_t *, uint16_t)
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/Common/audio.h:86
DFSDM_OVER_SAMPLING
#define DFSDM_OVER_SAMPLING(__FREQUENCY__)
Definition: stm32f769i_discovery_audio.c:180
GPIO_InitTypeDef
GPIO Init structure definition
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:47
CODEC_PDWN_HW
#define CODEC_PDWN_HW
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/cs43l22/cs43l22.h:85
HAL_DFSDM_FilterInit
HAL_StatusTypeDef HAL_DFSDM_FilterInit(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
__SAI_HandleTypeDef::hdmatx
DMA_HandleTypeDef * hdmatx
Definition: stm32f7xx_hal_sai.h:207
DFSDM1_Channel5
#define DFSDM1_Channel5
Definition: stm32f769xx.h:1668
HAL_SAI_DMAPause
HAL_StatusTypeDef HAL_SAI_DMAPause(SAI_HandleTypeDef *hsai)
AUDIO_IN_SAIx_CLK_DISABLE
#define AUDIO_IN_SAIx_CLK_DISABLE()
Definition: stm32f769i_discovery_audio.h:142
hAudioInButtomRightChannel
DFSDM_Channel_HandleTypeDef hAudioInButtomRightChannel
Definition: stm32f769i_discovery_audio.c:241
AUDIO_OUT_SAIx_CLK_ENABLE
#define AUDIO_OUT_SAIx_CLK_ENABLE()
Definition: stm32f769i_discovery_audio.h:109
AUDIO_IN_IRQ_PREPRIO
#define AUDIO_IN_IRQ_PREPRIO
Definition: stm32f4_discovery_audio.h:140
BSP_AUDIO_OUT_MspDeInit
__weak void BSP_AUDIO_OUT_MspDeInit(SAI_HandleTypeDef *hsai, void *Params)
Deinitializes SAI MSP.
Definition: stm32f769i_discovery_audio.c:822
__HAL_DFSDM_CHANNEL_RESET_HANDLE_STATE
#define __HAL_DFSDM_CHANNEL_RESET_HANDLE_STATE(__HANDLE__)
Reset DFSDM channel handle state.
Definition: stm32h7xx_hal_dfsdm.h:536
DMA_InitTypeDef::Priority
uint32_t Priority
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:75
AUDIO_DFSDMx_CLK_ENABLE
#define AUDIO_DFSDMx_CLK_ENABLE()
Definition: stm32f769i_discovery_audio.h:172
DFSDM_Filter_RegularParamTypeDef::DmaMode
FunctionalState DmaMode
Definition: stm32h7xx_hal_dfsdm.h:175
AUDIO_OUT_SAIx_DMAx_CHANNEL
#define AUDIO_OUT_SAIx_DMAx_CHANNEL
Definition: stm32f769i_discovery_audio.h:125
DMA_InitTypeDef::PeriphInc
uint32_t PeriphInc
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:58
DmaTopLeftRecHalfCplt
static uint32_t DmaTopLeftRecHalfCplt
Definition: stm32f769i_discovery_audio.c:256
SAI_InitTypeDef::AudioFrequency
uint32_t AudioFrequency
Definition: stm32f7xx_hal_sai.h:97
AUDIO_DFSDMx_DMAx_CLK_ENABLE
#define AUDIO_DFSDMx_DMAx_CLK_ENABLE()
Definition: stm32f769i_discovery_audio.h:184
SAI_FrameInitTypeDef::FSDefinition
uint32_t FSDefinition
Definition: stm32f7xx_hal_sai.h:151
SAI_SLOTSIZE_DATASIZE
#define SAI_SLOTSIZE_DATASIZE
Definition: stm32f7xx_hal_sai.h:447
BSP_AUDIO_OUT_Stop
uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option)
Stops audio playing and Power down the Audio Codec.
Definition: stm32f769i_discovery_audio.c:442
hAudioInButtomLeftChannel
DFSDM_Channel_HandleTypeDef hAudioInButtomLeftChannel
Definition: stm32f769i_discovery_audio.c:240
GPIO_InitTypeDef::Alternate
uint32_t Alternate
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:61
DFSDM_CHANNEL_SPI_RISING
#define DFSDM_CHANNEL_SPI_RISING
Definition: stm32h7xx_hal_dfsdm.h:343
AUDIO_ERROR
#define AUDIO_ERROR
Definition: stm32f4_discovery_audio.h:150
DFSDM_Channel_InitTypeDef::SerialInterface
DFSDM_Channel_SerialInterfaceTypeDef SerialInterface
Definition: stm32h7xx_hal_dfsdm.h:108
HAL_SAI_DeInit
HAL_StatusTypeDef HAL_SAI_DeInit(SAI_HandleTypeDef *hsai)
wm8994_drv
AUDIO_DrvTypeDef wm8994_drv
Definition: stm32f769/stm32f769i-disco/Drivers/BSP/Components/wm8994/wm8994.c:86
DFSDM_Channel_AwdTypeDef::FilterOrder
uint32_t FilterOrder
Definition: stm32h7xx_hal_dfsdm.h:95
AUDIO_OUT_SAIx_SCK_PIN
#define AUDIO_OUT_SAIx_SCK_PIN
Definition: stm32f769i_discovery_audio.h:119
BSP_AUDIO_OUT_SetAudioFrameSlot
void BSP_AUDIO_OUT_SetAudioFrameSlot(uint32_t AudioFrameSlot)
Updates the Audio frame slot configuration.
Definition: stm32f769i_discovery_audio.c:555
HAL_NVIC_DisableIRQ
void HAL_NVIC_DisableIRQ(IRQn_Type IRQn)
AUDIO_IN_SAIx
#define AUDIO_IN_SAIx
Definition: stm32f769i_discovery_audio.h:140
RCC_PeriphCLKInitTypeDef::PeriphClockSelection
uint32_t PeriphClockSelection
Definition: stm32f7xx_hal_rcc_ex.h:128
haudio_in_sai
SAI_HandleTypeDef haudio_in_sai
Definition: stm32f769i_discovery_audio.c:228
SAI_SYNCEXT_DISABLE
#define SAI_SYNCEXT_DISABLE
Definition: stm32f7xx_hal_sai.h:288
HAL_SAI_GetState
HAL_SAI_StateTypeDef HAL_SAI_GetState(SAI_HandleTypeDef *hsai)
SAI_FS_CHANNEL_IDENTIFICATION
#define SAI_FS_CHANNEL_IDENTIFICATION
Definition: stm32f7xx_hal_sai.h:421
DFSDM_Channel_InitTypeDef::Offset
int32_t Offset
Definition: stm32h7xx_hal_dfsdm.h:110
AUDIO_DFSDMx_TOP_LEFT_CHANNEL
#define AUDIO_DFSDMx_TOP_LEFT_CHANNEL
Definition: stm32f769i_discovery_audio.h:163
SAI_InitTypeDef::Protocol
uint32_t Protocol
Definition: stm32f7xx_hal_sai.h:117
AUDIO_OUT_SAIx_SD_PIN
#define AUDIO_OUT_SAIx_SD_PIN
Definition: stm32f769i_discovery_audio.h:120
AUDIO_I2C_ADDRESS
#define AUDIO_I2C_ADDRESS
AUDIO I2C Interface pins.
Definition: stm32f4_discovery.h:247
DFSDM_Channel_SerialInterfaceTypeDef::Type
uint32_t Type
Definition: stm32h7xx_hal_dfsdm.h:84
AUDIO_DFSDMx_DMAx_TOP_LEFT_IRQ
#define AUDIO_DFSDMx_DMAx_TOP_LEFT_IRQ
Definition: stm32f769i_discovery_audio.h:190
__DMA_HandleTypeDef::Init
DMA_InitTypeDef Init
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:143
AUDIOIN_TypeDef
Definition: stm32f769i_discovery_audio.c:159
DFSDM_Filter_InjectedParamTypeDef::DmaMode
FunctionalState DmaMode
Definition: stm32h7xx_hal_dfsdm.h:186
AUDIO_IN_SAIx_AF
#define AUDIO_IN_SAIx_AF
Definition: stm32f769i_discovery_audio.h:143
DFSDMx_FilterMspInit
static void DFSDMx_FilterMspInit(void)
Initialize the DFSDM filter MSP.
Definition: stm32f769i_discovery_audio.c:2070
DMA_InitTypeDef::FIFOThreshold
uint32_t FIFOThreshold
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:83
DFSDM1_Channel0
#define DFSDM1_Channel0
Definition: stm32f769xx.h:1663
DMA_CIRCULAR
#define DMA_CIRCULAR
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:282
BSP_AUDIO_OUT_SetOutputMode
uint8_t BSP_AUDIO_OUT_SetOutputMode(uint8_t Output)
Switch dynamically (while audio file is played) the output target (speaker or headphone).
Definition: stm32f769i_discovery_audio.c:511
DmaButtomLeftRecHalfCplt
static uint32_t DmaButtomLeftRecHalfCplt
Definition: stm32f769i_discovery_audio.c:260
DFSDM_CHANNEL_SAME_CHANNEL_PINS
#define DFSDM_CHANNEL_SAME_CHANNEL_PINS
Definition: stm32h7xx_hal_dfsdm.h:334
BSP_AUDIO_IN_Error_CallBack
__weak void BSP_AUDIO_IN_Error_CallBack(void)
Audio IN Error callback function.
Definition: stm32f769i_discovery_audio.c:1637
SAI_SlotInitTypeDef::SlotNumber
uint32_t SlotNumber
Definition: stm32f7xx_hal_sai.h:177
DMA_InitTypeDef::PeriphDataAlignment
uint32_t PeriphDataAlignment
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:64
AUDIO_OUT_SAIx_MCLK_ENABLE
#define AUDIO_OUT_SAIx_MCLK_ENABLE()
Definition: stm32f769i_discovery_audio.h:113
RCC_PeriphCLKInitTypeDef::PLLI2S
RCC_PLLI2SInitTypeDef PLLI2S
Definition: stm32f7xx_hal_rcc_ex.h:131
AudioIn_ChannelNumber
static uint8_t AudioIn_ChannelNumber
Definition: stm32f769i_discovery_audio.c:251
BSP_AUDIO_IN_DeInit
void BSP_AUDIO_IN_DeInit(void)
Deinit the audio IN peripherals.
Definition: stm32f769i_discovery_audio.c:1420
hDmaButtomLeft
DMA_HandleTypeDef hDmaButtomLeft
Definition: stm32f769i_discovery_audio.c:244
BSP_AUDIO_IN_Record
uint8_t BSP_AUDIO_IN_Record(uint16_t *pbuf, uint32_t size)
Start audio recording.
Definition: stm32f769i_discovery_audio.c:1234
AUDIODATA_SIZE
#define AUDIODATA_SIZE
Definition: stm32f4_discovery_audio.h:146
AppBuffHalf
static __IO uint32_t AppBuffHalf
Definition: stm32f769i_discovery_audio.c:267
AUDIO_OUT_IRQ_PREPRIO
#define AUDIO_OUT_IRQ_PREPRIO
Definition: stm32f4_discovery_audio.h:109
__SAI_HandleTypeDef::Instance
SAI_Block_TypeDef * Instance
Definition: stm32f7xx_hal_sai.h:193
HAL_Delay
void HAL_Delay(uint32_t Delay)
This function provides minimum delay (in milliseconds) based on variable incremented.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:389
SAI_InitTypeDef::FIFOThreshold
uint32_t FIFOThreshold
Definition: stm32f7xx_hal_sai.h:94
DFSDM_CHANNEL_SPI_FALLING
#define DFSDM_CHANNEL_SPI_FALLING
Definition: stm32h7xx_hal_dfsdm.h:344
DFSDM_CHANNEL_FASTSINC_ORDER
#define DFSDM_CHANNEL_FASTSINC_ORDER
Definition: stm32h7xx_hal_dfsdm.h:365
ENABLE
@ ENABLE
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:194
AUDIO_DFSDMx_DMAx_TOP_RIGHT_STREAM
#define AUDIO_DFSDMx_DMAx_TOP_RIGHT_STREAM
Definition: stm32f769i_discovery_audio.h:193
BSP_AUDIO_IN_TransferComplete_CallBack
__weak void BSP_AUDIO_IN_TransferComplete_CallBack(void)
User callback when record buffer is filled.
Definition: stm32f769i_discovery_audio.c:1615
DMA_MBURST_SINGLE
#define DMA_MBURST_SINGLE
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:326
AUDIOIN_TypeDef::pRecBuf
uint16_t * pRecBuf
Definition: stm32f769i_discovery_audio.c:161
BSP_AUDIO_IN_Stop
uint8_t BSP_AUDIO_IN_Stop(void)
Stop audio recording.
Definition: stm32f769i_discovery_audio.c:1287
SAI_MODEMASTER_RX
#define SAI_MODEMASTER_RX
Definition: stm32f7xx_hal_sai.h:339
SAI_InitTypeDef::SynchroExt
uint32_t SynchroExt
Definition: stm32f7xx_hal_sai.h:74
AUDIO_IN_SAIx_CLK_ENABLE
#define AUDIO_IN_SAIx_CLK_ENABLE()
Definition: stm32f769i_discovery_audio.h:141
SAI_MASTERDIVIDER_ENABLED
#define SAI_MASTERDIVIDER_ENABLED
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h:3708
BSP_AUDIO_OUT_Play
uint8_t BSP_AUDIO_OUT_Play(uint16_t *pBuffer, uint32_t Size)
Starts playing audio stream from a data buffer for a determined size.
Definition: stm32f769i_discovery_audio.c:357
DFSDM_RIGHT_BIT_SHIFT
#define DFSDM_RIGHT_BIT_SHIFT(__FREQUENCY__)
Definition: stm32f769i_discovery_audio.c:207
hAudioInTopLeftFilter
DFSDM_Filter_HandleTypeDef hAudioInTopLeftFilter
Definition: stm32f769i_discovery_audio.c:235
AUDIO_DFSDMx_TOP_RIGHT_CHANNEL
#define AUDIO_DFSDMx_TOP_RIGHT_CHANNEL
Definition: stm32f769i_discovery_audio.h:162
HAL_OK
@ HAL_OK
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:42
AUDIO_DFSDMx_DMAx_BUTTOM_LEFT_IRQ
#define AUDIO_DFSDMx_DMAx_BUTTOM_LEFT_IRQ
Definition: stm32f769i_discovery_audio.h:198
SaturaLH
#define SaturaLH(N, L, H)
Definition: stm32f769i_discovery_audio.c:217
BSP_AUDIO_OUT_HalfTransfer_CallBack
__weak void BSP_AUDIO_OUT_HalfTransfer_CallBack(void)
Manages the DMA Half Transfer complete event.
Definition: stm32f769i_discovery_audio.c:632
DMA_PERIPH_TO_MEMORY
#define DMA_PERIPH_TO_MEMORY
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:228
HAL_DFSDM_FilterRegularStop_DMA
HAL_StatusTypeDef HAL_DFSDM_FilterRegularStop_DMA(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
SAI_FrameInitTypeDef::FSOffset
uint32_t FSOffset
Definition: stm32f7xx_hal_sai.h:157
DFSDM_Filter_HandleTypeDef
DFSDM filter handle structure definition.
Definition: stm32h7xx_hal_dfsdm.h:222
BSP_AUDIO_IN_MspDeInit
__weak void BSP_AUDIO_IN_MspDeInit(void)
DeInitialize BSP_AUDIO_IN MSP.
Definition: stm32f769i_discovery_audio.c:1666
SAI_InitTypeDef::Synchro
uint32_t Synchro
Definition: stm32f7xx_hal_sai.h:71
BSP_AUDIO_IN_Resume
uint8_t BSP_AUDIO_IN_Resume(void)
Resume the audio file stream.
Definition: stm32f769i_discovery_audio.c:1384
SAI_SYNCHRONOUS
#define SAI_SYNCHRONOUS
Definition: stm32f7xx_hal_sai.h:392
BSP_AUDIO_OUT_TransferComplete_CallBack
__weak void BSP_AUDIO_OUT_TransferComplete_CallBack(void)
Manages the DMA full Transfer complete event.
Definition: stm32f769i_discovery_audio.c:624
HAL_SAI_TxCpltCallback
void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai)
Tx Transfer completed callbacks.
Definition: stm32f769i_discovery_audio.c:584
hAudioInTopRightFilter
DFSDM_Filter_HandleTypeDef hAudioInTopRightFilter
Definition: stm32f769i_discovery_audio.c:236
AUDIO_DFSDMx_DMAx_TOP_RIGHT_IRQ
#define AUDIO_DFSDMx_DMAx_TOP_RIGHT_IRQ
Definition: stm32f769i_discovery_audio.h:194
AUDIOIN_TypeDef::RecSize
uint32_t RecSize
Definition: stm32f769i_discovery_audio.c:162
HAL_GPIO_Init
void HAL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init)
BSP_AUDIO_IN_HalfTransfer_CallBack
__weak void BSP_AUDIO_IN_HalfTransfer_CallBack(void)
Manages the DMA Half Transfer complete event.
Definition: stm32f769i_discovery_audio.c:1626
DFSDM_Channel_HandleTypeDef::Instance
DFSDM_Channel_TypeDef * Instance
Definition: stm32h7xx_hal_dfsdm.h:125
AUDIO_DFSDMx_DMIC_DATIN5_PIN
#define AUDIO_DFSDMx_DMIC_DATIN5_PIN
Definition: stm32f769i_discovery_audio.h:177
DFSDM_CHANNEL_SPI_CLOCK_INTERNAL
#define DFSDM_CHANNEL_SPI_CLOCK_INTERNAL
Definition: stm32h7xx_hal_dfsdm.h:355
GPIO_InitTypeDef::Mode
uint32_t Mode
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:52
AUDIO_DrvTypeDef::Reset
uint32_t(* Reset)(uint16_t)
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/Common/audio.h:94
AUDIO_FREQUENCY_22K
#define AUDIO_FREQUENCY_22K
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/cs43l22/cs43l22.h:98
DMA_InitTypeDef::MemInc
uint32_t MemInc
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:61
AUDIO_DFSDMx_DMAx_CHANNEL
#define AUDIO_DFSDMx_DMAx_CHANNEL
Definition: stm32f769i_discovery_audio.h:185
AUDIO_IN_INT_IRQ
#define AUDIO_IN_INT_IRQ
Definition: stm32f769i_discovery_audio.h:159
AUDIO_OUT_SAIx_SD_FS_CLK_ENABLE
#define AUDIO_OUT_SAIx_SD_FS_CLK_ENABLE()
Definition: stm32f769i_discovery_audio.h:116
__SAI_HandleTypeDef::Init
SAI_InitTypeDef Init
Definition: stm32f7xx_hal_sai.h:195
AUDIO_DrvTypeDef::SetMute
uint32_t(* SetMute)(uint16_t, uint32_t)
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/Common/audio.h:92
GPIO_InitTypeDef::Pull
uint32_t Pull
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:55
GPIO_NOPULL
#define GPIO_NOPULL
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:154
__SAI_HandleTypeDef
Definition: stm32f7xx_hal_sai.h:191
DFSDM_Filter_HandleTypeDef::Instance
DFSDM_Filter_TypeDef * Instance
Definition: stm32h7xx_hal_dfsdm.h:225
RCC_SAI1CLKSOURCE_PLLI2S
#define RCC_SAI1CLKSOURCE_PLLI2S
Definition: stm32f7xx_hal_rcc_ex.h:326
HAL_DFSDM_FilterRegularStart_DMA
HAL_StatusTypeDef HAL_DFSDM_FilterRegularStart_DMA(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, int32_t *pData, uint32_t Length)
BSP_AUDIO_OUT_MspInit
__weak void BSP_AUDIO_OUT_MspInit(SAI_HandleTypeDef *hsai, void *Params)
Initializes BSP_AUDIO_OUT MSP.
Definition: stm32f769i_discovery_audio.c:650
__HAL_DFSDM_FILTER_RESET_HANDLE_STATE
#define __HAL_DFSDM_FILTER_RESET_HANDLE_STATE(__HANDLE__)
Reset DFSDM filter handle state.
Definition: stm32h7xx_hal_dfsdm.h:550
HAL_SAI_RxHalfCpltCallback
void HAL_SAI_RxHalfCpltCallback(SAI_HandleTypeDef *hsai)
Half reception complete callback.
Definition: stm32f769i_discovery_audio.c:1593
DmaTopLeftRecCplt
static uint32_t DmaTopLeftRecCplt
Definition: stm32f769i_discovery_audio.c:257
AUDIO_IN_INT_GPIO_ENABLE
#define AUDIO_IN_INT_GPIO_ENABLE()
Definition: stm32f769i_discovery_audio.h:156
SAIx_In_Init
static void SAIx_In_Init(uint32_t AudioFreq)
Initializes the Audio Codec audio interface (SAI).
Definition: stm32f769i_discovery_audio.c:987
AUDIO_OUT_SAIx_DMAx_IRQ
#define AUDIO_OUT_SAIx_DMAx_IRQ
Definition: stm32f769i_discovery_audio.h:126
INPUT_DEVICE_DIGITAL_MIC
#define INPUT_DEVICE_DIGITAL_MIC
Definition: stm32f769i_discovery_audio.h:237
SAI_InitTypeDef::OutputDrive
uint32_t OutputDrive
Definition: stm32f7xx_hal_sai.h:80
AUDIO_DrvTypeDef::Init
uint32_t(* Init)(uint16_t, uint16_t, uint8_t, uint32_t)
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/Common/audio.h:83
DmaButtomRightRecHalfCplt
static uint32_t DmaButtomRightRecHalfCplt
Definition: stm32f769i_discovery_audio.c:262
DMA_InitTypeDef::PeriphBurst
uint32_t PeriphBurst
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:92
AUDIO_DFSDMx_DMAx_MEM_DATA_SIZE
#define AUDIO_DFSDMx_DMAx_MEM_DATA_SIZE
Definition: stm32f769i_discovery_audio.h:187
__UART_HandleTypeDef::hdmatx
DMA_HandleTypeDef * hdmatx
Definition: stm32f4xx_hal_uart.h:159
DFSDM_Filter_FilterParamTypeDef::Oversampling
uint32_t Oversampling
Definition: stm32h7xx_hal_dfsdm.h:200
DmaButtomRightRecCplt
static uint32_t DmaButtomRightRecCplt
Definition: stm32f769i_discovery_audio.c:263
AUDIO_FREQUENCY_44K
#define AUDIO_FREQUENCY_44K
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/cs43l22/cs43l22.h:96
SAI_NOCOMPANDING
#define SAI_NOCOMPANDING
Definition: stm32f7xx_hal_sai.h:512
DFSDM_Channel_InitTypeDef::Awd
DFSDM_Channel_AwdTypeDef Awd
Definition: stm32h7xx_hal_dfsdm.h:109
SAI_InitTypeDef::NoDivider
uint32_t NoDivider
Definition: stm32f7xx_hal_sai.h:85
RCC_PeriphCLKInitTypeDef::Sai2ClockSelection
uint32_t Sai2ClockSelection
Definition: stm32f7xx_hal_rcc_ex.h:160
BSP_AUDIO_OUT_Init
uint8_t BSP_AUDIO_OUT_Init(uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq)
Configures the audio peripherals.
Definition: stm32f769i_discovery_audio.c:305
DMA_PRIORITY_HIGH
#define DMA_PRIORITY_HIGH
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:294
AUDIO_IN_INT_GPIO_PORT
#define AUDIO_IN_INT_GPIO_PORT
Definition: stm32f769i_discovery_audio.h:157
__DMA_HandleTypeDef::Instance
DMA_Stream_TypeDef * Instance
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:141
HAL_SAI_DMAResume
HAL_StatusTypeDef HAL_SAI_DMAResume(SAI_HandleTypeDef *hsai)
HAL_SAI_RxCpltCallback
void HAL_SAI_RxCpltCallback(SAI_HandleTypeDef *hsai)
Reception complete callback.
Definition: stm32f769i_discovery_audio.c:1605
RCC_PLLI2SInitTypeDef::PLLI2SN
uint32_t PLLI2SN
Definition: stm32f7xx_hal_rcc_ex.h:78
HAL_DFSDM_ChannelDeInit
HAL_StatusTypeDef HAL_DFSDM_ChannelDeInit(DFSDM_Channel_HandleTypeDef *hdfsdm_channel)
DFSDM_Filter_InjectedParamTypeDef::Trigger
uint32_t Trigger
Definition: stm32h7xx_hal_dfsdm.h:183
DMA_InitTypeDef::MemDataAlignment
uint32_t MemDataAlignment
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:67
GPIO_SPEED_FREQ_VERY_HIGH
#define GPIO_SPEED_FREQ_VERY_HIGH
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:145
DFSDM_Channel_AwdTypeDef::Oversampling
uint32_t Oversampling
Definition: stm32h7xx_hal_dfsdm.h:97
BSP_AUDIO_OUT_Pause
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.
Definition: stm32f769i_discovery_audio.c:392
HAL_GPIO_DeInit
void HAL_GPIO_DeInit(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin)
DFSDM1_Channel4
#define DFSDM1_Channel4
Definition: stm32f769xx.h:1667
AUDIO_DFSDMx_BUTTOM_RIGHT_FILTER
#define AUDIO_DFSDMx_BUTTOM_RIGHT_FILTER
Definition: stm32f769i_discovery_audio.h:170
DFSDMx_ChannelMspDeInit
static void DFSDMx_ChannelMspDeInit(void)
DeInitialize the DFSDM channel MSP.
Definition: stm32f769i_discovery_audio.c:2046
AUDIO_DrvTypeDef::Stop
uint32_t(* Stop)(uint16_t, uint32_t)
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/Common/audio.h:89
DFSDMx_Init
static uint8_t DFSDMx_Init(uint32_t AudioFreq)
Initialize the Digital Filter for Sigma-Delta Modulators interface (DFSDM).
Definition: stm32f769i_discovery_audio.c:1743
HAL_DFSDM_FilterRegConvCpltCallback
void HAL_DFSDM_FilterRegConvCpltCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
Regular conversion complete callback.
Definition: stm32f769i_discovery_audio.c:1441
SAI_MODESLAVE_RX
#define SAI_MODESLAVE_RX
Definition: stm32f7xx_hal_sai.h:341
AUDIO_OUT_SAIx_DMAx_CLK_ENABLE
#define AUDIO_OUT_SAIx_DMAx_CLK_ENABLE()
Definition: stm32f769i_discovery_audio.h:123
haudio_out_sai
SAI_HandleTypeDef haudio_out_sai
Definition: stm32f769i_discovery_audio.c:227
SAI_AUDIO_IN_MspDeInit
static void SAI_AUDIO_IN_MspDeInit(SAI_HandleTypeDef *hsai, void *Params)
De-Initializes SAI Audio IN MSP.
Definition: stm32f769i_discovery_audio.c:789
SAI_OUTPUTDRIVE_ENABLE
#define SAI_OUTPUTDRIVE_ENABLE
Definition: stm32f7xx_hal_sai.h:403
DFSDM_Filter_InjectedParamTypeDef::ExtTriggerEdge
uint32_t ExtTriggerEdge
Definition: stm32h7xx_hal_dfsdm.h:189
GPIO_InitTypeDef::Speed
uint32_t Speed
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:58
AUDIO_OUT_SAIx_MCLK_GPIO_PORT
#define AUDIO_OUT_SAIx_MCLK_GPIO_PORT
Definition: stm32f769i_discovery_audio.h:114
hDmaTopLeft
DMA_HandleTypeDef hDmaTopLeft
Definition: stm32f769i_discovery_audio.c:237
BSP_AUDIO_OUT_SetFrequency
void BSP_AUDIO_OUT_SetFrequency(uint32_t AudioFreq)
Updates the audio frequency.
Definition: stm32f769i_discovery_audio.c:532
pScratchBuff
static int32_t * pScratchBuff[2 *DEFAULT_AUDIO_IN_CHANNEL_NBR]
Definition: stm32f769i_discovery_audio.c:248
HAL_DFSDM_ChannelInit
HAL_StatusTypeDef HAL_DFSDM_ChannelInit(DFSDM_Channel_HandleTypeDef *hdfsdm_channel)
AUDIO_IN_SAIx_DMAx_MEM_DATA_SIZE
#define AUDIO_IN_SAIx_DMAx_MEM_DATA_SIZE
Definition: stm32f769i_discovery_audio.h:154
SAI_InitTypeDef::TriState
uint32_t TriState
Definition: stm32f7xx_hal_sai.h:111
BSP_AUDIO_OUT_ChangeBuffer
void BSP_AUDIO_OUT_ChangeBuffer(uint16_t *pData, uint16_t Size)
Sends n-Bytes on the SAI interface.
Definition: stm32f769i_discovery_audio.c:379
DFSDM_Filter_RegularParamTypeDef::Trigger
uint32_t Trigger
Definition: stm32h7xx_hal_dfsdm.h:172
RCC_PERIPHCLK_SAI2
#define RCC_PERIPHCLK_SAI2
Definition: stm32f7xx_hal_rcc_ex.h:257
DMA_PBURST_SINGLE
#define DMA_PBURST_SINGLE
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:338
DFSDM_Filter_FilterParamTypeDef::IntOversampling
uint32_t IntOversampling
Definition: stm32h7xx_hal_dfsdm.h:202
AUDIO_DFSDMx_BUTTOM_LEFT_FILTER
#define AUDIO_DFSDMx_BUTTOM_LEFT_FILTER
Definition: stm32f769i_discovery_audio.h:169
DFSDM_Channel_OutputClockTypeDef::Selection
uint32_t Selection
Definition: stm32h7xx_hal_dfsdm.h:60
AUDIO_OUT_SAIx_AF
#define AUDIO_OUT_SAIx_AF
Definition: stm32f769i_discovery_audio.h:111
DmaButtomLeftRecCplt
static uint32_t DmaButtomLeftRecCplt
Definition: stm32f769i_discovery_audio.c:261
HAL_DFSDM_FilterRegConvHalfCpltCallback
void HAL_DFSDM_FilterRegConvHalfCpltCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
Half regular conversion complete callback.
Definition: stm32f769i_discovery_audio.c:1517
AUDIO_DFSDMx_CKOUT_DMIC_GPIO_PORT
#define AUDIO_DFSDMx_CKOUT_DMIC_GPIO_PORT
Definition: stm32f769i_discovery_audio.h:174
__HAL_SAI_DISABLE
#define __HAL_SAI_DISABLE(__HANDLE__)
Definition: stm32f7xx_hal_sai.h:658
DFSDM_FILTER_ORDER
#define DFSDM_FILTER_ORDER(__FREQUENCY__)
Definition: stm32f769i_discovery_audio.c:198
hAudioIn
AUDIOIN_TypeDef hAudioIn
Definition: stm32f769i_discovery_audio.c:231
SAI_MODEMASTER_TX
#define SAI_MODEMASTER_TX
Definition: stm32f7xx_hal_sai.h:338
WM8994_ID
#define WM8994_ID
WM8994 ID
Definition: stm32f769/stm32f769i-disco/Drivers/BSP/Components/wm8994/wm8994.h:118
SAI_InitTypeDef::DataSize
uint32_t DataSize
Definition: stm32f7xx_hal_sai.h:120
AUDIO_IN_SAIx_DMAx_STREAM
#define AUDIO_IN_SAIx_DMAx_STREAM
Definition: stm32f769i_discovery_audio.h:150
DFSDM_Filter_RegularParamTypeDef::FastMode
FunctionalState FastMode
Definition: stm32h7xx_hal_dfsdm.h:174
DFSDM_Channel_InputTypeDef::Multiplexer
uint32_t Multiplexer
Definition: stm32h7xx_hal_dfsdm.h:71
DFSDM_FILTER_EXT_TRIG_RISING_EDGE
#define DFSDM_FILTER_EXT_TRIG_RISING_EDGE
Definition: stm32h7xx_hal_dfsdm.h:419
AUDIO_DrvTypeDef
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/Common/audio.h:81
DFSDM1_Channel1
#define DFSDM1_Channel1
Definition: stm32f769xx.h:1664
DFSDM_Channel_HandleTypeDef
DFSDM channel handle structure definition.
Definition: stm32h7xx_hal_dfsdm.h:122
SAI_SlotInitTypeDef::SlotSize
uint32_t SlotSize
Definition: stm32f7xx_hal_sai.h:174
SAIx_In_DeInit
static void SAIx_In_DeInit(void)
Deinitializes the output Audio Codec audio interface (SAI).
Definition: stm32f769i_discovery_audio.c:1100
DMA_MINC_ENABLE
#define DMA_MINC_ENABLE
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:249
DFSDM_Channel_SerialInterfaceTypeDef::SpiClock
uint32_t SpiClock
Definition: stm32h7xx_hal_dfsdm.h:86
AUDIO_IN_SAIx_DMAx_PERIPH_DATA_SIZE
#define AUDIO_IN_SAIx_DMAx_PERIPH_DATA_SIZE
Definition: stm32f769i_discovery_audio.h:153
DFSDM_Filter_HandleTypeDef::Init
DFSDM_Filter_InitTypeDef Init
Definition: stm32h7xx_hal_dfsdm.h:226
DFSDM_Channel_InputTypeDef::Pins
uint32_t Pins
Definition: stm32h7xx_hal_dfsdm.h:75
SAI_SlotInitTypeDef::SlotActive
uint32_t SlotActive
Definition: stm32f7xx_hal_sai.h:180
AUDIO_DrvTypeDef::Resume
uint32_t(* Resume)(uint16_t)
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/Common/audio.h:88
__UART_HandleTypeDef::hdmarx
DMA_HandleTypeDef * hdmarx
Definition: stm32f4xx_hal_uart.h:161
BSP_AUDIO_IN_Pause
uint8_t BSP_AUDIO_IN_Pause(void)
Pause the audio file stream.
Definition: stm32f769i_discovery_audio.c:1348
__HAL_SAI_ENABLE
#define __HAL_SAI_ENABLE(__HANDLE__)
Definition: stm32f7xx_hal_sai.h:657
BSP_AUDIO_OUT_DeInit
void BSP_AUDIO_OUT_DeInit(void)
De-initializes the audio out peripheral.
Definition: stm32f769i_discovery_audio.c:572
SAI_FIRSTBIT_MSB
#define SAI_FIRSTBIT_MSB
Definition: stm32f7xx_hal_sai.h:373
SAI_SlotInitTypeDef::FirstBitOffset
uint32_t FirstBitOffset
Definition: stm32f7xx_hal_sai.h:171
HAL_DFSDM_FilterConfigRegChannel
HAL_StatusTypeDef HAL_DFSDM_FilterConfigRegChannel(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, uint32_t Channel, uint32_t ContinuousMode)
AUDIO_DFSDMx_DMAx_BUTTOM_LEFT_STREAM
#define AUDIO_DFSDMx_DMAx_BUTTOM_LEFT_STREAM
Definition: stm32f769i_discovery_audio.h:197
SAI_AUDIO_IN_MspInit
static void SAI_AUDIO_IN_MspInit(SAI_HandleTypeDef *hsai, void *Params)
Initializes SAI Audio IN MSP.
Definition: stm32f769i_discovery_audio.c:716
DMA_InitTypeDef::MemBurst
uint32_t MemBurst
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:86
hDmaTopRight
DMA_HandleTypeDef hDmaTopRight
Definition: stm32f769i_discovery_audio.c:238
HAL_SAI_Receive_DMA
HAL_StatusTypeDef HAL_SAI_Receive_DMA(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size)
DFSDM_Channel_OutputClockTypeDef::Activation
FunctionalState Activation
Definition: stm32h7xx_hal_dfsdm.h:59
ScratchSize
static __IO int32_t ScratchSize
Definition: stm32f769i_discovery_audio.c:249
DMA_FIFOMODE_ENABLE
#define DMA_FIFOMODE_ENABLE
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:305
hDmaButtomRight
DMA_HandleTypeDef hDmaButtomRight
Definition: stm32f769i_discovery_audio.c:245
hAudioInButtomRightFilter
DFSDM_Filter_HandleTypeDef hAudioInButtomRightFilter
Definition: stm32f769i_discovery_audio.c:243
SAI_MASTERDIVIDER_ENABLE
#define SAI_MASTERDIVIDER_ENABLE
Definition: stm32f7xx_hal_sai.h:411
SAI_DATASIZE_16
#define SAI_DATASIZE_16
Definition: stm32f7xx_hal_sai.h:362
AUDIO_DFSDMx_DMAx_PERIPH_DATA_SIZE
#define AUDIO_DFSDMx_DMAx_PERIPH_DATA_SIZE
Definition: stm32f769i_discovery_audio.h:186
RCC_PERIPHCLK_SAI1
#define RCC_PERIPHCLK_SAI1
Definition: stm32f7xx_hal_rcc_ex.h:256
DMA_InitTypeDef::FIFOMode
uint32_t FIFOMode
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:78
DFSDM_Filter_InitTypeDef::FilterParam
DFSDM_Filter_FilterParamTypeDef FilterParam
Definition: stm32h7xx_hal_dfsdm.h:213
AUDIO_DFSDMx_CKOUT_DMIC_GPIO_CLK_ENABLE
#define AUDIO_DFSDMx_CKOUT_DMIC_GPIO_CLK_ENABLE()
Definition: stm32f769i_discovery_audio.h:175
AUDIO_OUT_SAIx
#define AUDIO_OUT_SAIx
Definition: stm32f769i_discovery_audio.h:108
DMA_FIFOMODE_DISABLE
#define DMA_FIFOMODE_DISABLE
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:304
AUDIO_DrvTypeDef::ReadID
uint32_t(* ReadID)(uint16_t)
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/Common/audio.h:85
SAIx_Out_Init
static void SAIx_Out_Init(uint32_t AudioFreq)
Initializes the Audio Codec audio interface (SAI).
Definition: stm32f769i_discovery_audio.c:910
HAL_SAI_TxHalfCpltCallback
void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai)
Tx Half Transfer completed callbacks.
Definition: stm32f769i_discovery_audio.c:596
BSP_AUDIO_IN_AllocScratch
uint8_t BSP_AUDIO_IN_AllocScratch(int32_t *pScratch, uint32_t size)
Allocate channel buffer scratch.
Definition: stm32f769i_discovery_audio.c:1204
SAI_FrameInitTypeDef::FSPolarity
uint32_t FSPolarity
Definition: stm32f7xx_hal_sai.h:154
DMA_MEMORY_TO_PERIPH
#define DMA_MEMORY_TO_PERIPH
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:229
HAL_RCCEx_PeriphCLKConfig
HAL_StatusTypeDef HAL_RCCEx_PeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit)
CODEC_AUDIOFRAME_SLOT_02
#define CODEC_AUDIOFRAME_SLOT_02
Definition: stm32469i_discovery_audio.h:107
HAL_DMA_Init
HAL_StatusTypeDef HAL_DMA_Init(DMA_HandleTypeDef *hdma)
AUDIO_IN_SAIx_SD_PIN
#define AUDIO_IN_SAIx_SD_PIN
Definition: stm32f769i_discovery_audio.h:146
AUDIO_OUT_SAIx_SD_FS_SCK_GPIO_PORT
#define AUDIO_OUT_SAIx_SD_FS_SCK_GPIO_PORT
Definition: stm32f769i_discovery_audio.h:117
SAI_OUTPUT_NOTRELEASED
#define SAI_OUTPUT_NOTRELEASED
Definition: stm32f7xx_hal_sai.h:491
DFSDM_Channel_InitTypeDef::Input
DFSDM_Channel_InputTypeDef Input
Definition: stm32h7xx_hal_dfsdm.h:107
BSP_AUDIO_OUT_SetVolume
uint8_t BSP_AUDIO_OUT_SetVolume(uint8_t Volume)
Controls the current audio volume level.
Definition: stm32f769i_discovery_audio.c:470
RCC_PeriphCLKInitTypeDef::Sai1ClockSelection
uint32_t Sai1ClockSelection
Definition: stm32f7xx_hal_rcc_ex.h:157
DFSDM_FILTER_EXT_TRIG_TIM1_TRGO
#define DFSDM_FILTER_EXT_TRIG_TIM1_TRGO
Definition: stm32h7xx_hal_dfsdm.h:386
DFSDM_Channel_InitTypeDef::RightBitShift
uint32_t RightBitShift
Definition: stm32h7xx_hal_dfsdm.h:112
AUDIO_DFSDMx_DMIC_DATIN1_PIN
#define AUDIO_DFSDMx_DMIC_DATIN1_PIN
Definition: stm32f769i_discovery_audio.h:176
BSP_AUDIO_OUT_Resume
uint8_t BSP_AUDIO_OUT_Resume(void)
Resumes the audio file stream.
Definition: stm32f769i_discovery_audio.c:416
DMA_InitTypeDef::Direction
uint32_t Direction
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:54
DFSDM_FILTER_SYNC_TRIGGER
#define DFSDM_FILTER_SYNC_TRIGGER
Definition: stm32h7xx_hal_dfsdm.h:377
hAudioInTopLeftChannel
DFSDM_Channel_HandleTypeDef hAudioInTopLeftChannel
Definition: stm32f769i_discovery_audio.c:233
HAL_DMA_DeInit
HAL_StatusTypeDef HAL_DMA_DeInit(DMA_HandleTypeDef *hdma)
DFSDMx_DeInit
static uint8_t DFSDMx_DeInit(void)
De-initialize the Digital Filter for Sigma-Delta Modulators interface (DFSDM).
Definition: stm32f769i_discovery_audio.c:1953
DFSDM_FILTER_SW_TRIGGER
#define DFSDM_FILTER_SW_TRIGGER
Definition: stm32h7xx_hal_dfsdm.h:376
DFSDMx_ChannelMspInit
static void DFSDMx_ChannelMspInit(void)
Initialize the DFSDM channel MSP.
Definition: stm32f769i_discovery_audio.c:2009
BSP_AUDIO_IN_GetChannelNumber
uint8_t BSP_AUDIO_IN_GetChannelNumber(void)
Return audio in channel number.
Definition: stm32f769i_discovery_audio.c:1223
SAI_FS_ACTIVE_LOW
#define SAI_FS_ACTIVE_LOW
Definition: stm32f7xx_hal_sai.h:429
CODEC_AUDIOFRAME_SLOT_0123
#define CODEC_AUDIOFRAME_SLOT_0123
Definition: stm32469i_discovery_audio.h:105
Output
Output
AUDIO_DFSDMx_CKOUT_AF
#define AUDIO_DFSDMx_CKOUT_AF
Definition: stm32f769i_discovery_audio.h:181
SAI_ASYNCHRONOUS
#define SAI_ASYNCHRONOUS
Definition: stm32f7xx_hal_sai.h:391
AUDIO_OUT_SAIx_DMAx_PERIPH_DATA_SIZE
#define AUDIO_OUT_SAIx_DMAx_PERIPH_DATA_SIZE
Definition: stm32f769i_discovery_audio.h:127
DFSDM_Channel_OutputClockTypeDef::Divider
uint32_t Divider
Definition: stm32h7xx_hal_dfsdm.h:62
HAL_SAI_Init
HAL_StatusTypeDef HAL_SAI_Init(SAI_HandleTypeDef *hsai)
AUDIO_DFSDMx_TOP_RIGHT_FILTER
#define AUDIO_DFSDMx_TOP_RIGHT_FILTER
Definition: stm32f769i_discovery_audio.h:168
SAIx_Out_DeInit
static void SAIx_Out_DeInit(void)
Deinitializes the Audio Codec audio interface (SAI).
Definition: stm32f769i_discovery_audio.c:969
AUDIO_DrvTypeDef::Pause
uint32_t(* Pause)(uint16_t)
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/Common/audio.h:87
BSP_AUDIO_IN_Init
uint8_t BSP_AUDIO_IN_Init(uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr)
Initialize wave recording.
Definition: stm32f769i_discovery_audio.c:1127
AUDIO_DrvTypeDef::SetOutputMode
uint32_t(* SetOutputMode)(uint16_t, uint8_t)
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/Common/audio.h:93
RCC_PLLI2SInitTypeDef::PLLI2SQ
uint32_t PLLI2SQ
Definition: stm32f7xx_hal_rcc_ex.h:86
AUDIO_DFSDMx_DMIC_DATIN_AF
#define AUDIO_DFSDMx_DMIC_DATIN_AF
Definition: stm32f769i_discovery_audio.h:180
DFSDM_Filter_InjectedParamTypeDef::ScanMode
FunctionalState ScanMode
Definition: stm32h7xx_hal_dfsdm.h:185
HAL_NVIC_SetPriority
void HAL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority)
AUDIO_OK
#define AUDIO_OK
Definition: stm32f4_discovery_audio.h:149
RCC_SAI2CLKSOURCE_PLLI2S
#define RCC_SAI2CLKSOURCE_PLLI2S
Definition: stm32f7xx_hal_rcc_ex.h:339
AUDIO_DFSDMx_CKOUT_PIN
#define AUDIO_DFSDMx_CKOUT_PIN
Definition: stm32f769i_discovery_audio.h:173
DFSDM_Filter_InitTypeDef::InjectedParam
DFSDM_Filter_InjectedParamTypeDef InjectedParam
Definition: stm32h7xx_hal_dfsdm.h:212
RCC_PeriphCLKInitTypeDef
RCC extended clocks structure definition.
Definition: stm32f7xx_hal_rcc_ex.h:126
BSP_AUDIO_OUT_SetMute
uint8_t BSP_AUDIO_OUT_SetMute(uint32_t Cmd)
Enables or disables the MUTE mode by software.
Definition: stm32f769i_discovery_audio.c:490
AUDIO_OUT_SAIx_MCLK_PIN
#define AUDIO_OUT_SAIx_MCLK_PIN
Definition: stm32f769i_discovery_audio.h:115
SAI_InitTypeDef::AudioMode
uint32_t AudioMode
Definition: stm32f7xx_hal_sai.h:68
AUDIO_IN_SAIx_SD_ENABLE
#define AUDIO_IN_SAIx_SD_ENABLE()
Definition: stm32f769i_discovery_audio.h:144
DMA_InitTypeDef::Mode
uint32_t Mode
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:70
DFSDM_Filter_InjectedParamTypeDef::ExtTrigger
uint32_t ExtTrigger
Definition: stm32h7xx_hal_dfsdm.h:187
SAI_OUTPUTDRIVE_ENABLED
#define SAI_OUTPUTDRIVE_ENABLED
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h:3707
DFSDM_CHANNEL_OUTPUT_CLOCK_AUDIO
#define DFSDM_CHANNEL_OUTPUT_CLOCK_AUDIO
Definition: stm32h7xx_hal_dfsdm.h:306
DFSDM_Filter_FilterParamTypeDef::SincOrder
uint32_t SincOrder
Definition: stm32h7xx_hal_dfsdm.h:198
SAI_STEREOMODE
#define SAI_STEREOMODE
Definition: stm32f7xx_hal_sai.h:482
DFSDM_Channel_HandleTypeDef::Init
DFSDM_Channel_InitTypeDef Init
Definition: stm32h7xx_hal_dfsdm.h:126
AUDIO_OUT_SAIx_CLK_DISABLE
#define AUDIO_OUT_SAIx_CLK_DISABLE()
Definition: stm32f769i_discovery_audio.h:110
AUDIO_DFSDMx_DMAx_TOP_LEFT_STREAM
#define AUDIO_DFSDMx_DMAx_TOP_LEFT_STREAM
Definition: stm32f769i_discovery_audio.h:189
AUDIO_DFSDMx_DMAx_BUTTOM_RIGHT_STREAM
#define AUDIO_DFSDMx_DMAx_BUTTOM_RIGHT_STREAM
Definition: stm32f769i_discovery_audio.h:201
SAI_CLOCKSTROBING_RISINGEDGE
#define SAI_CLOCKSTROBING_RISINGEDGE
Definition: stm32f7xx_hal_sai.h:383
AppBuffTrigger
static __IO uint32_t AppBuffTrigger
Definition: stm32f769i_discovery_audio.c:266
audio_drv
AUDIO_DrvTypeDef * audio_drv
Definition: stm32f769i_discovery_audio.c:226
SAI_FrameInitTypeDef::FrameLength
uint32_t FrameLength
Definition: stm32f7xx_hal_sai.h:140
HAL_SAI_STATE_RESET
@ HAL_SAI_STATE_RESET
Definition: stm32f7xx_hal_sai.h:50
DFSDM_CHANNEL_FOLLOWING_CHANNEL_PINS
#define DFSDM_CHANNEL_FOLLOWING_CHANNEL_PINS
Definition: stm32h7xx_hal_dfsdm.h:335
AUDIO_DrvTypeDef::SetVolume
uint32_t(* SetVolume)(uint16_t, uint8_t)
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/Common/audio.h:91
DMA_FIFO_THRESHOLD_FULL
#define DMA_FIFO_THRESHOLD_FULL
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:317
DmaTopRightRecCplt
static uint32_t DmaTopRightRecCplt
Definition: stm32f769i_discovery_audio.c:259
__SAI_HandleTypeDef::SlotInit
SAI_SlotInitTypeDef SlotInit
Definition: stm32f7xx_hal_sai.h:199
BSP_AUDIO_OUT_Error_CallBack
__weak void BSP_AUDIO_OUT_Error_CallBack(void)
Manages the DMA FIFO error event.
Definition: stm32f769i_discovery_audio.c:640
AUDIO_IN_SAIx_DMAx_CLK_ENABLE
#define AUDIO_IN_SAIx_DMAx_CLK_ENABLE()
Definition: stm32f769i_discovery_audio.h:149
__SAI_HandleTypeDef::FrameInit
SAI_FrameInitTypeDef FrameInit
Definition: stm32f7xx_hal_sai.h:197
AUDIO_DFSDMx_BUTTOM_RIGHT_CHANNEL
#define AUDIO_DFSDMx_BUTTOM_RIGHT_CHANNEL
Definition: stm32f769i_discovery_audio.h:164
AUDIO_OUT_SAIx_DMAx_STREAM
#define AUDIO_OUT_SAIx_DMAx_STREAM
Definition: stm32f769i_discovery_audio.h:124
GPIO_MODE_INPUT
#define GPIO_MODE_INPUT
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:119
AudioIn_Device
static uint16_t AudioIn_Device
Definition: stm32f769i_discovery_audio.c:253
BSP_AUDIO_IN_ClockConfig
__weak void BSP_AUDIO_IN_ClockConfig(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, uint32_t AudioFreq, void *Params)
Clock Config.
Definition: stm32f769i_discovery_audio.c:1690
DMA_MAX
#define DMA_MAX(_X_)
Definition: stm32f4_discovery_audio.h:184
SAI_FS_BEFOREFIRSTBIT
#define SAI_FS_BEFOREFIRSTBIT
Definition: stm32f7xx_hal_sai.h:439
AUDIO_DFSDMx_DMAx_BUTTOM_RIGHT_IRQ
#define AUDIO_DFSDMx_DMAx_BUTTOM_RIGHT_IRQ
Definition: stm32f769i_discovery_audio.h:202
AUDIO_DFSDMx_DMIC_DATIN_GPIO_CLK_ENABLE
#define AUDIO_DFSDMx_DMIC_DATIN_GPIO_CLK_ENABLE()
Definition: stm32f769i_discovery_audio.h:179
AUDIO_IN_SAIx_SD_GPIO_PORT
#define AUDIO_IN_SAIx_SD_GPIO_PORT
Definition: stm32f769i_discovery_audio.h:145
SAI_InitTypeDef::FirstBit
uint32_t FirstBit
Definition: stm32f7xx_hal_sai.h:123
hAudioInTopRightChannel
DFSDM_Channel_HandleTypeDef hAudioInTopRightChannel
Definition: stm32f769i_discovery_audio.c:234
DFSDM_Filter_InitTypeDef::RegularParam
DFSDM_Filter_RegularParamTypeDef RegularParam
Definition: stm32h7xx_hal_dfsdm.h:211
HAL_RCCEx_GetPeriphCLKConfig
void HAL_RCCEx_GetPeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit)
HAL_SAI_Transmit_DMA
HAL_StatusTypeDef HAL_SAI_Transmit_DMA(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size)
AUDIO_DFSDMx_BUTTOM_LEFT_CHANNEL
#define AUDIO_DFSDMx_BUTTOM_LEFT_CHANNEL
Definition: stm32f769i_discovery_audio.h:165
hAudioInButtomLeftFilter
DFSDM_Filter_HandleTypeDef hAudioInButtomLeftFilter
Definition: stm32f769i_discovery_audio.c:242
BSP_AUDIO_IN_InitEx
uint8_t BSP_AUDIO_IN_InitEx(uint16_t InputDevice, uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr)
Initialize wave recording.
Definition: stm32f769i_discovery_audio.c:1140
stm32f769i_discovery_audio.h
This file contains the common defines and functions prototypes for the stm32f769i_discovery_audio....
AUDIO_OUT_SAIx_FS_PIN
#define AUDIO_OUT_SAIx_FS_PIN
Definition: stm32f769i_discovery_audio.h:118
GPIO_InitTypeDef::Pin
uint32_t Pin
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:49
DFSDM_CLOCK_DIVIDER
#define DFSDM_CLOCK_DIVIDER(__FREQUENCY__)
Definition: stm32f769i_discovery_audio.c:189


picovoice_driver
Author(s):
autogenerated on Fri Apr 1 2022 02:14:53