stm32h747i_discovery_audio.c
Go to the documentation of this file.
1 
133 /* Includes ------------------------------------------------------------------*/
136 
155 
156 /* PDM filters params */
157 static PDM_Filter_Handler_t PDM_FilterHandler[2];
158 static PDM_Filter_Config_t PDM_FilterConfig[2];
159 
168 /* Play handle */
170 /*record handle*/
172 
173 /* Play context */
175 
176 /* Recording context */
178 
186 /* SAI Msp config */
187 static void SAI_MspInit(SAI_HandleTypeDef *hsai);
188 static void SAI_MspDeInit(SAI_HandleTypeDef *hsai);
189 
190 /* SAI callbacks */
191 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1U)
192 static void SAI_TxCpltCallback(SAI_HandleTypeDef *hsai);
193 static void SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai);
194 static void SAI_RxCpltCallback(SAI_HandleTypeDef *hsai);
195 static void SAI_RxHalfCpltCallback(SAI_HandleTypeDef *hsai);
196 static void SAI_ErrorCallback(SAI_HandleTypeDef *hsai);
197 #endif /* (USE_HAL_SAI_REGISTER_CALLBACKS == 1U) */
198 
199 #if (USE_AUDIO_CODEC_WM8994 == 1)
200 static int32_t WM8994_Probe(void);
201 #endif
202 
217 int32_t BSP_AUDIO_OUT_Init(uint32_t Instance, BSP_AUDIO_Init_t* AudioInit)
218 {
219  int32_t ret = BSP_ERROR_NONE;
220 
221  if(Instance >= AUDIO_OUT_INSTANCES_NBR)
222  {
223  ret = BSP_ERROR_WRONG_PARAM;
224  }
225  else
226  {
227  /* Fill Audio_Out_Ctx structure */
228  Audio_Out_Ctx[Instance].Device = AudioInit->Device;
229  Audio_Out_Ctx[Instance].Instance = Instance;
230  Audio_Out_Ctx[Instance].SampleRate = AudioInit->SampleRate;
231  Audio_Out_Ctx[Instance].BitsPerSample = AudioInit->BitsPerSample;
232  Audio_Out_Ctx[Instance].ChannelsNbr = AudioInit->ChannelsNbr;
233  Audio_Out_Ctx[Instance].Volume = AudioInit->Volume;
235 
236 #if (USE_AUDIO_CODEC_WM8994 == 1)
237  if(WM8994_Probe() != BSP_ERROR_NONE)
238  {
240  }
241 #endif
242 
243  if(ret == BSP_ERROR_NONE)
244  {
245  /* PLL clock is set depending by the AudioFreq (44.1khz vs 48khz groups) */
247  {
249  }
250  else
251  {
252  /* SAI data transfer preparation:
253  Prepare the Media to be used for the audio transfer from memory to SAI peripheral */
255 
256 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1U)
257  /* Register the SAI MSP Callbacks */
258  if(Audio_Out_Ctx[Instance].IsMspCallbacksValid == 0U)
259  {
260  if(BSP_AUDIO_OUT_RegisterDefaultMspCallbacks(Instance) != BSP_ERROR_NONE)
261  {
263  }
264  }
265 #else
267 #endif /* (USE_HAL_SAI_REGISTER_CALLBACKS == 1U) */
268  if(ret == BSP_ERROR_NONE)
269  {
270  MX_SAI_Config_t mx_sai_config;
271 
272  /* Prepare haudio_out_sai handle */
273  mx_sai_config.AudioFrequency = AudioInit->SampleRate;
274  mx_sai_config.AudioMode = SAI_MODEMASTER_TX;
276  mx_sai_config.MonoStereoMode = (AudioInit->ChannelsNbr == 1U) ? SAI_MONOMODE : SAI_STEREOMODE;
277  mx_sai_config.DataSize = (AudioInit->BitsPerSample == AUDIO_RESOLUTION_32B) ? SAI_DATASIZE_32 : SAI_DATASIZE_16;
278  mx_sai_config.FrameLength = 128;
279  mx_sai_config.ActiveFrameLength = 64;
280  mx_sai_config.OutputDrive = SAI_OUTPUTDRIVE_ENABLE;
281  mx_sai_config.Synchro = SAI_ASYNCHRONOUS;
282  mx_sai_config.SynchroExt = SAI_SYNCEXT_DISABLE;
283  mx_sai_config.SlotActive = CODEC_AUDIOFRAME_SLOT_02;
284 
285  /* SAI peripheral initialization: this __weak function can be redefined by the application */
286  if(MX_SAI1_Block_A_Init(&haudio_out_sai, &mx_sai_config) != HAL_OK)
287  {
289  }
290 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1U)
291  /* Register SAI TC, HT and Error callbacks */
292  else if(HAL_SAI_RegisterCallback(&haudio_out_sai, HAL_SAI_TX_COMPLETE_CB_ID, SAI_TxCpltCallback) != HAL_OK)
293  {
295  }
296  else if(HAL_SAI_RegisterCallback(&haudio_out_sai, HAL_SAI_TX_HALFCOMPLETE_CB_ID, SAI_TxHalfCpltCallback) != HAL_OK)
297  {
299  }
300  else if(HAL_SAI_RegisterCallback(&haudio_out_sai, HAL_SAI_ERROR_CB_ID, SAI_ErrorCallback) != HAL_OK)
301  {
303  }
304 #endif
305  else
306  {
307 #if (USE_AUDIO_CODEC_WM8994 == 1)
308  WM8994_Init_t codec_init;
309  codec_init.Resolution = (AudioInit->BitsPerSample == AUDIO_RESOLUTION_32B) ? 3 : 0;
310  /* Fill codec_init structure */
311  codec_init.Frequency = AudioInit->SampleRate;
312  codec_init.InputDevice = WM8994_IN_NONE;
313  codec_init.OutputDevice = AudioInit->Device;
314 
315  /* Convert volume before sending to the codec */
316  codec_init.Volume = VOLUME_OUT_CONVERT(AudioInit->Volume);
317 
318  /* Initialize the codec internal registers */
319  if(Audio_Drv->Init(Audio_CompObj, &codec_init) != 0)
320  {
322  }
323 #endif
324  if(ret == BSP_ERROR_NONE)
325  {
326  /* Update BSP AUDIO OUT state */
328  }
329  }
330  }
331  }
332  }
333  }
334 
335  return ret;
336 }
337 
343 int32_t BSP_AUDIO_OUT_DeInit(uint32_t Instance)
344 {
345  int32_t ret = BSP_ERROR_NONE;
346 
347  if(Instance >= AUDIO_OUT_INSTANCES_NBR)
348  {
349  ret = BSP_ERROR_WRONG_PARAM;
350  }
351  else
352  {
353 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 0U)
355 #endif /* (USE_HAL_SAI_REGISTER_CALLBACKS == 0U) */
356  /* Initialize the haudio_out_sai Instance parameter */
358  /* Call the Media layer stop function */
359  if(Audio_Drv->DeInit(Audio_CompObj) != 0)
360  {
362  }
363  else if(HAL_SAI_DeInit(&haudio_out_sai) != HAL_OK)
364  {
366  }
367  else
368  {
369  /* Update BSP AUDIO OUT state */
371  }
372  }
373  /* Return BSP status */
374  return ret;
375 }
376 
385 {
387 
388  /* Disable SAI peripheral to allow access to SAI internal registers */
389  __HAL_SAI_DISABLE(hsai);
390 
391  /* Configure SAI1_Block_A */
392  hsai->Init.MonoStereoMode = MXConfig->MonoStereoMode;
393  hsai->Init.AudioFrequency = MXConfig->AudioFrequency;
394  hsai->Init.AudioMode = MXConfig->AudioMode;
397  hsai->Init.DataSize = MXConfig->DataSize;
399  hsai->Init.ClockStrobing = MXConfig->ClockStrobing;
400  hsai->Init.Synchro = MXConfig->Synchro;
401  hsai->Init.OutputDrive = MXConfig->OutputDrive;
403  hsai->Init.SynchroExt = MXConfig->SynchroExt;
406  hsai->Init.Mckdiv = 0;
409  hsai->Init.PdmInit.Activation = DISABLE;
410  hsai->Init.PdmInit.ClockEnable = 0;
411  hsai->Init.PdmInit.MicPairsNbr = 0;
412 
413  /* Configure SAI_Block_x Frame */
414  hsai->FrameInit.FrameLength = MXConfig->FrameLength;
419 
420  /* Configure SAI Block_x Slot */
421  hsai->SlotInit.FirstBitOffset = 0;
423  hsai->SlotInit.SlotNumber = 4;
424  hsai->SlotInit.SlotActive = MXConfig->SlotActive;
425 
426  if(HAL_SAI_Init(hsai) != HAL_OK)
427  {
428  ret = HAL_ERROR;
429  }
430 
431  __HAL_SAI_ENABLE(hsai);
432 
433  return ret;
434 }
435 
444 __weak HAL_StatusTypeDef MX_SAI1_ClockConfig(SAI_HandleTypeDef *hsai, uint32_t SampleRate)
445 {
446  /* Prevent unused argument(s) compilation warning */
447  UNUSED(hsai);
448 
450  RCC_PeriphCLKInitTypeDef rcc_ex_clk_init_struct;
451  HAL_RCCEx_GetPeriphCLKConfig(&rcc_ex_clk_init_struct);
452 
453  /* Set the PLL configuration according to the audio frequency */
454  if((SampleRate == AUDIO_FREQUENCY_11K) || (SampleRate == AUDIO_FREQUENCY_22K) || (SampleRate == AUDIO_FREQUENCY_44K))
455  {
456  rcc_ex_clk_init_struct.PLL2.PLL2P = 38;
457  rcc_ex_clk_init_struct.PLL2.PLL2N = 429;
458  }
459  else /* AUDIO_FREQUENCY_8K, AUDIO_FREQUENCY_16K, AUDIO_FREQUENCY_32K, AUDIO_FREQUENCY_48K, AUDIO_FREQUENCY_96K */
460  {
461  rcc_ex_clk_init_struct.PLL2.PLL2P = 7;
462  rcc_ex_clk_init_struct.PLL2.PLL2N = 344;
463  }
464  rcc_ex_clk_init_struct.PeriphClockSelection = RCC_PERIPHCLK_SAI1;
465  rcc_ex_clk_init_struct.Sai1ClockSelection = RCC_SAI1CLKSOURCE_PLL2;
466  rcc_ex_clk_init_struct.PLL2.PLL2Q = 1;
467  rcc_ex_clk_init_struct.PLL2.PLL2R = 1;
468  rcc_ex_clk_init_struct.PLL2.PLL2M = 25;
469  if(HAL_RCCEx_PeriphCLKConfig(&rcc_ex_clk_init_struct) != HAL_OK)
470  {
471  ret = HAL_ERROR;
472  }
473 
474  return ret;
475 }
476 
485 __weak HAL_StatusTypeDef MX_SAI4_ClockConfig(SAI_HandleTypeDef *hsai, uint32_t SampleRate)
486 {
487  /* Prevent unused argument(s) compilation warning */
488  UNUSED(hsai);
489 
491  RCC_PeriphCLKInitTypeDef rcc_ex_clk_init_struct;
492  HAL_RCCEx_GetPeriphCLKConfig(&rcc_ex_clk_init_struct);
493 
494  /* Set the PLL configuration according to the audio frequency */
495  if((SampleRate == AUDIO_FREQUENCY_11K) || (SampleRate == AUDIO_FREQUENCY_22K) || (SampleRate == AUDIO_FREQUENCY_44K))
496  {
497  rcc_ex_clk_init_struct.PLL2.PLL2P = 38;
498  rcc_ex_clk_init_struct.PLL2.PLL2N = 429;
499  }
500  else /* AUDIO_FREQUENCY_8K, AUDIO_FREQUENCY_16K, AUDIO_FREQUENCY_32K, AUDIO_FREQUENCY_48K, AUDIO_FREQUENCY_96K */
501  {
502  rcc_ex_clk_init_struct.PLL2.PLL2P = 7;
503  rcc_ex_clk_init_struct.PLL2.PLL2N = 344;
504  }
505  /* SAI clock config */
506  rcc_ex_clk_init_struct.PeriphClockSelection = RCC_PERIPHCLK_SAI4A;
507  rcc_ex_clk_init_struct.Sai4AClockSelection = RCC_SAI4ACLKSOURCE_PLL2;
508  rcc_ex_clk_init_struct.PLL2.PLL2Q = 1;
509  rcc_ex_clk_init_struct.PLL2.PLL2R = 1;
510  rcc_ex_clk_init_struct.PLL2.PLL2M = 25;
511  if(HAL_RCCEx_PeriphCLKConfig(&rcc_ex_clk_init_struct) != HAL_OK)
512  {
513  ret = HAL_ERROR;
514  }
515 
516  return ret;
517 }
518 
524 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1U)
525 int32_t BSP_AUDIO_OUT_RegisterDefaultMspCallbacks (uint32_t Instance)
526 {
527  int32_t ret = BSP_ERROR_NONE;
528 
529  if(Instance >= AUDIO_OUT_INSTANCES_NBR)
530  {
531  ret = BSP_ERROR_WRONG_PARAM;
532  }
533  else
534  {
536 
537  /* Register MspInit/MspDeInit Callbacks */
538  if(HAL_SAI_RegisterCallback(&haudio_out_sai, HAL_SAI_MSPINIT_CB_ID,SAI_MspInit) != HAL_OK)
539  {
541  }
542  else if(HAL_SAI_RegisterCallback(&haudio_out_sai, HAL_SAI_MSPDEINIT_CB_ID,SAI_MspDeInit) != HAL_OK)
543  {
545  }
546  else
547  {
548  Audio_Out_Ctx[Instance].IsMspCallbacksValid = 1;
549  }
550  }
551 
552  /* Return BSP status */
553  return ret;
554 }
555 
562 int32_t BSP_AUDIO_OUT_RegisterMspCallbacks (uint32_t Instance, BSP_AUDIO_OUT_Cb_t *CallBacks)
563 {
564  int32_t ret = BSP_ERROR_NONE;
565 
566  if(Instance >= AUDIO_OUT_INSTANCES_NBR)
567  {
568  ret = BSP_ERROR_WRONG_PARAM;
569  }
570  else
571  {
573 
574  /* Register MspInit/MspDeInit Callbacks */
575  if(HAL_SAI_RegisterCallback(&haudio_out_sai, HAL_SAI_MSPINIT_CB_ID, CallBacks->pMspSaiInitCb) != HAL_OK)
576  {
578  }
579  else if(HAL_SAI_RegisterCallback(&haudio_out_sai, HAL_SAI_MSPDEINIT_CB_ID,CallBacks->pMspSaiDeInitCb) != HAL_OK)
580  {
582  }
583  else
584  {
585  Audio_Out_Ctx[Instance].IsMspCallbacksValid = 1;
586  }
587  }
588 
589  /* Return BSP status */
590  return ret;
591 }
592 #endif /*(USE_HAL_SAI_REGISTER_CALLBACKS == 1U)*/
593 
602 int32_t BSP_AUDIO_OUT_Play(uint32_t Instance, uint8_t* pData, uint32_t NbrOfBytes)
603 {
604  int32_t ret = BSP_ERROR_NONE;
605 
606  if((Instance >= AUDIO_OUT_INSTANCES_NBR) || (((NbrOfBytes / (Audio_Out_Ctx[Instance].BitsPerSample/8U)) > 0xFFFFU)))
607  {
608  ret = BSP_ERROR_WRONG_PARAM;
609  }
610  else if((Audio_Out_Ctx[Instance].State == AUDIO_OUT_STATE_STOP) || (Audio_Out_Ctx[Instance].State == AUDIO_OUT_STATE_RESET))
611  {
612  if(HAL_SAI_Transmit_DMA(&haudio_out_sai, pData, (uint16_t)(NbrOfBytes /(Audio_Out_Ctx[Instance].BitsPerSample/8U))) != HAL_OK)
613  {
615  }
616  if(ret == BSP_ERROR_NONE)
617  {
619  {
621  }
622  else
623  {
624  /* Update BSP AUDIO OUT state */
626  }
627  }
628  }
629  else
630  {
631  ret = BSP_ERROR_BUSY;
632  }
633 
634  /* Return BSP status */
635  return ret;
636 }
637 
647 int32_t BSP_AUDIO_OUT_Pause(uint32_t Instance)
648 {
649  int32_t ret = BSP_ERROR_NONE;
650 
651  if(Instance >= AUDIO_OUT_INSTANCES_NBR)
652  {
653  ret = BSP_ERROR_WRONG_PARAM;
654  }
655  else
656  {
657  /* Call the Media layer pause function */
659  {
661  }
662 
663  if(ret == BSP_ERROR_NONE)
664  {
665  /* Call the Audio Codec Pause/Resume function */
667  {
669  }
670  else
671  {
672  /* Update BSP AUDIO OUT state */
674  }
675  }
676  }
677 
678  /* Return BSP status */
679  return ret;
680 }
681 
690 int32_t BSP_AUDIO_OUT_Resume(uint32_t Instance)
691 {
692  int32_t ret = BSP_ERROR_NONE;
693 
694  if(Instance >= AUDIO_OUT_INSTANCES_NBR)
695  {
696  ret = BSP_ERROR_WRONG_PARAM;
697  }
698  else
699  {
700  /* Call the Media layer pause/resume function */
702  {
704  }
705 
706  if(ret == BSP_ERROR_NONE)
707  {
709  {
711  }
712  else
713  {
714  /* Update BSP AUDIO OUT state */
716  }
717  }
718  }
719 
720  /* Return BSP status */
721  return ret;
722 }
723 
729 int32_t BSP_AUDIO_OUT_Stop(uint32_t Instance)
730 {
731  int32_t ret = BSP_ERROR_NONE;
732 
733  if(Instance >= AUDIO_OUT_INSTANCES_NBR)
734  {
735  ret = BSP_ERROR_WRONG_PARAM;
736  }
737  else if (Audio_Out_Ctx[Instance].State == AUDIO_OUT_STATE_PLAYING)
738  {
739  /* Call the Media layer stop function */
741  {
743  }
744  else
745  {
747  {
749  }
750 
751  if( ret==BSP_ERROR_NONE)
752  {
753  /* Update BSP AUDIO OUT state */
755  }
756  }
757  }
758  else
759  {
760  ret = BSP_ERROR_BUSY;
761  }
762 
763  /* Return BSP status */
764  return ret;
765 }
766 
774 int32_t BSP_AUDIO_OUT_SetVolume(uint32_t Instance, uint32_t Volume)
775 {
776  int32_t ret = BSP_ERROR_NONE;
777 
778  if(Instance >= AUDIO_OUT_INSTANCES_NBR)
779  {
780  ret = BSP_ERROR_WRONG_PARAM;
781  }
782  else
783  {
784  /* Call the codec volume control function with converted volume value */
786  {
788  }
789  else if(Volume == 0U)
790  {
791  /* Update Mute State */
793  }
794  else
795  {
796  /* Update Mute State */
798  }
799  Audio_Out_Ctx[Instance].Volume = Volume;
800  }
801 
802  /* Return BSP status */
803  return ret;
804 }
805 
812 int32_t BSP_AUDIO_OUT_GetVolume(uint32_t Instance, uint32_t *Volume)
813 {
814  int32_t ret = BSP_ERROR_NONE;
815 
816  if(Instance >= AUDIO_OUT_INSTANCES_NBR)
817  {
818  ret = BSP_ERROR_WRONG_PARAM;
819  }
820  else
821  {
822  *Volume = Audio_Out_Ctx[Instance].Volume;
823  }
824  /* Return BSP status */
825  return ret;
826 }
827 
833 int32_t BSP_AUDIO_OUT_Mute(uint32_t Instance)
834 {
835  int32_t ret = BSP_ERROR_NONE;
836 
837  if(Instance >= AUDIO_OUT_INSTANCES_NBR)
838  {
839  ret = BSP_ERROR_WRONG_PARAM;
840  }
841  else
842  {
843  /* Call the Codec Mute function */
845  {
847  }
848  else
849  {
850  /* Update Mute State */
852  }
853  }
854  /* Return BSP status */
855  return ret;
856 }
857 
863 int32_t BSP_AUDIO_OUT_UnMute(uint32_t Instance)
864 {
865  int32_t ret = BSP_ERROR_NONE;
866 
867  if(Instance >= AUDIO_OUT_INSTANCES_NBR)
868  {
869  ret = BSP_ERROR_WRONG_PARAM;
870  }
871  else
872  {
873  /* Call the Codec Mute function */
875  {
877  }
878  else
879  {
880  /* Update Mute State */
882  }
883  }
884  /* Return BSP status */
885  return ret;
886 }
887 
894 int32_t BSP_AUDIO_OUT_IsMute(uint32_t Instance, uint32_t *IsMute)
895 {
896  int32_t ret = BSP_ERROR_NONE;
897 
898  if(Instance >= AUDIO_OUT_INSTANCES_NBR)
899  {
900  ret = BSP_ERROR_WRONG_PARAM;
901  }
902  else
903  {
904  *IsMute = Audio_Out_Ctx[Instance].IsMute;
905  }
906  /* Return BSP status */
907  return ret;
908 }
909 
917 int32_t BSP_AUDIO_OUT_SetDevice(uint32_t Instance, uint32_t Device)
918 {
919  int32_t ret = BSP_ERROR_NONE;
920 
921  UNUSED(Device);
922 
923  if (Instance >= AUDIO_OUT_INSTANCES_NBR)
924  {
925  ret = BSP_ERROR_WRONG_PARAM;
926  }
927  /* Check audio out state */
928  else if (Audio_Out_Ctx[Instance].State != AUDIO_OUT_STATE_STOP)
929  {
930  ret = BSP_ERROR_BUSY;
931  }
932  else
933  {
934  /* Nothing to do because there is only one device (AUDIO_OUT_DEVICE_HEADPHONE) */
935  }
936 
937  /* Return BSP status */
938  return ret;
939 }
940 
947 int32_t BSP_AUDIO_OUT_GetDevice(uint32_t Instance, uint32_t *Device)
948 {
949  int32_t ret = BSP_ERROR_NONE;
950 
951  if(Instance >= AUDIO_OUT_INSTANCES_NBR)
952  {
953  ret = BSP_ERROR_WRONG_PARAM;
954  }
955  else
956  {
957  /* Get Audio_Out_Ctx Device */
958  *Device = Audio_Out_Ctx[Instance].Device;
959  }
960  /* Return BSP status */
961  return ret;
962 }
963 
972 int32_t BSP_AUDIO_OUT_SetSampleRate(uint32_t Instance, uint32_t SampleRate)
973 {
974  int32_t ret = BSP_ERROR_NONE;
975 
976  if (Instance >= AUDIO_OUT_INSTANCES_NBR)
977  {
978  ret = BSP_ERROR_WRONG_PARAM;
979  }
980  /* Check audio out state */
981  else if (Audio_Out_Ctx[Instance].State != AUDIO_OUT_STATE_STOP)
982  {
983  ret = BSP_ERROR_BUSY;
984  }
985  /* Check if record on instance 0 is on going and corresponding sample rate */
986  else if ((Audio_In_Ctx[0].State != AUDIO_IN_STATE_RESET) &&
987  (Audio_In_Ctx[0].SampleRate != SampleRate))
988  {
990  }/* Check if sample rate is modified */
991  else if (Audio_Out_Ctx[Instance].SampleRate == SampleRate)
992  {
993  /* Nothing to do */
994  }
995  else
996  {
997  /* Update the SAI audio frequency configuration */
998  haudio_out_sai.Init.AudioFrequency = SampleRate;
999  /* PLL clock is set depending by the AudioFreq (44.1khz vs 48khz groups) */
1000  if(MX_SAI1_ClockConfig(&haudio_out_sai, SampleRate) != HAL_OK)
1001  {
1003  }
1004  else if(HAL_SAI_Init(&haudio_out_sai) != HAL_OK)
1005  {
1007  }
1008  else
1009  {
1010 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
1011  /* Register SAI TC, HT and Error callbacks */
1012  if(HAL_SAI_RegisterCallback(&haudio_out_sai, HAL_SAI_TX_COMPLETE_CB_ID, SAI_TxCpltCallback) != HAL_OK)
1013  {
1014  return BSP_ERROR_PERIPH_FAILURE;
1015  }
1016  if(HAL_SAI_RegisterCallback(&haudio_out_sai, HAL_SAI_TX_HALFCOMPLETE_CB_ID, SAI_TxHalfCpltCallback) != HAL_OK)
1017  {
1018  return BSP_ERROR_PERIPH_FAILURE;
1019  }
1020  if(HAL_SAI_RegisterCallback(&haudio_out_sai, HAL_SAI_ERROR_CB_ID, SAI_ErrorCallback) != HAL_OK)
1021  {
1022  return BSP_ERROR_PERIPH_FAILURE;
1023  }
1024 #endif /* (USE_HAL_SAI_REGISTER_CALLBACKS == 1) */
1025 
1026  /* Store new sample rate */
1027  Audio_Out_Ctx[Instance].SampleRate = SampleRate;
1028  }
1029  }
1030 
1031  /* Return BSP status */
1032  return ret;
1033 }
1034 
1041 int32_t BSP_AUDIO_OUT_GetSampleRate(uint32_t Instance, uint32_t *SampleRate)
1042 {
1043  int32_t ret = BSP_ERROR_NONE;
1044 
1045  if(Instance >= AUDIO_OUT_INSTANCES_NBR)
1046  {
1047  ret = BSP_ERROR_WRONG_PARAM;
1048  }
1049  else
1050  {
1051  *SampleRate = Audio_Out_Ctx[Instance].SampleRate;
1052  }
1053  /* Return BSP status */
1054  return ret;
1055 }
1056 
1064 int32_t BSP_AUDIO_OUT_SetBitsPerSample(uint32_t Instance, uint32_t BitsPerSample)
1065 {
1066  int32_t ret = BSP_ERROR_NONE;
1067 
1068  if (Instance >= AUDIO_OUT_INSTANCES_NBR)
1069  {
1070  ret = BSP_ERROR_WRONG_PARAM;
1071  }
1072  else if ((Instance == 0U) && ((BitsPerSample == AUDIO_RESOLUTION_32B) || (BitsPerSample == AUDIO_RESOLUTION_16B)))
1073  {
1075  }
1076  else if ((Instance == 0U) && (Audio_In_Ctx[0].State != AUDIO_IN_STATE_RESET) &&
1077  (Audio_In_Ctx[0].BitsPerSample != BitsPerSample))
1078  {
1080  }
1081  /* Check audio out state */
1082  else if (Audio_Out_Ctx[Instance].State != AUDIO_OUT_STATE_STOP)
1083  {
1084  ret = BSP_ERROR_BUSY;
1085  }
1086  else
1087  {
1088  /* Store new bits per sample on audio out context */
1089  Audio_Out_Ctx[Instance].BitsPerSample = BitsPerSample;
1090 
1091  /* Update data size, frame length and active frame length parameters of SAI handle */
1092  if (BitsPerSample == AUDIO_RESOLUTION_32B)
1093  {
1097  }
1098  else
1099  {
1103  }
1104 
1105 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
1106  /* Update SAI state only to keep current MSP functions */
1108 #else
1110 #endif /* (USE_HAL_SAI_REGISTER_CALLBACKS == 1) */
1111 
1112  /* Re-initialize SAI1 with new parameters */
1114  {
1116  }
1117 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
1118  /* Register SAI TC, HT and Error callbacks */
1119  else if (HAL_SAI_RegisterCallback(&haudio_out_sai, HAL_SAI_TX_COMPLETE_CB_ID, SAI_TxCpltCallback) != HAL_OK)
1120  {
1122  }
1123  else if (HAL_SAI_RegisterCallback(&haudio_out_sai, HAL_SAI_TX_HALFCOMPLETE_CB_ID, SAI_TxHalfCpltCallback) != HAL_OK)
1124  {
1126  }
1127  else
1128  {
1129  if (HAL_SAI_RegisterCallback(&haudio_out_sai, HAL_SAI_ERROR_CB_ID, SAI_ErrorCallback) != HAL_OK)
1130  {
1132  }
1133  }
1134 #endif /* (USE_HAL_SAI_REGISTER_CALLBACKS == 1) */
1135  }
1136 
1137  return ret;
1138 }
1139 
1146 int32_t BSP_AUDIO_OUT_GetBitsPerSample(uint32_t Instance, uint32_t *BitsPerSample)
1147 {
1148  int32_t ret = BSP_ERROR_NONE;
1149 
1150  if(Instance >= AUDIO_OUT_INSTANCES_NBR)
1151  {
1152  ret = BSP_ERROR_WRONG_PARAM;
1153  }
1154  else
1155  {
1156  /* Get audio Out resolution */
1157  *BitsPerSample = Audio_Out_Ctx[Instance].BitsPerSample;
1158  }
1159 
1160  /* Return BSP status */
1161  return ret;
1162 }
1163 
1170 int32_t BSP_AUDIO_OUT_SetChannelsNbr(uint32_t Instance, uint32_t ChannelNbr)
1171 {
1172  int32_t ret = BSP_ERROR_NONE;
1173 
1174  if (Instance >= AUDIO_OUT_INSTANCES_NBR)
1175  {
1176  ret = BSP_ERROR_WRONG_PARAM;
1177  }
1178  /* Check audio out state */
1179  else if (Audio_Out_Ctx[Instance].State != AUDIO_OUT_STATE_STOP)
1180  {
1181  ret = BSP_ERROR_BUSY;
1182  }
1183  else
1184  {
1185  /* Update mono or stereo mode of SAI handle */
1187 
1188  /* Re-initialize SAI1 with new parameter */
1190  {
1192  }
1193 
1194 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
1195  /* Register SAI TC, HT and Error callbacks */
1196  else if(HAL_SAI_RegisterCallback(&haudio_out_sai, HAL_SAI_TX_COMPLETE_CB_ID, SAI_TxCpltCallback) != HAL_OK)
1197  {
1199  }
1200  else if(HAL_SAI_RegisterCallback(&haudio_out_sai, HAL_SAI_TX_HALFCOMPLETE_CB_ID, SAI_TxHalfCpltCallback) != HAL_OK)
1201  {
1203  }
1204  else if(HAL_SAI_RegisterCallback(&haudio_out_sai, HAL_SAI_ERROR_CB_ID, SAI_ErrorCallback) != HAL_OK)
1205  {
1207  }
1208 #endif /* (USE_HAL_SAI_REGISTER_CALLBACKS == 1) */
1209  else
1210  {
1211  /* Store new Channel number */
1212  Audio_Out_Ctx[Instance].ChannelsNbr = ChannelNbr;
1213  }
1214  }
1215 
1216  /* Return BSP status */
1217  return ret;
1218 }
1219 
1226 int32_t BSP_AUDIO_OUT_GetChannelsNbr(uint32_t Instance, uint32_t *ChannelNbr)
1227 {
1228  int32_t ret = BSP_ERROR_NONE;
1229 
1230  if(Instance >= AUDIO_OUT_INSTANCES_NBR)
1231  {
1232  ret = BSP_ERROR_WRONG_PARAM;
1233  }
1234  else
1235  {
1236  /* Get the audio Channels number */
1237  *ChannelNbr = Audio_Out_Ctx[Instance].ChannelsNbr;
1238  }
1239 
1240  /* Return BSP status */
1241  return ret;
1242 }
1243 
1250 int32_t BSP_AUDIO_OUT_GetState(uint32_t Instance, uint32_t *State)
1251 {
1252  int32_t ret = BSP_ERROR_NONE;
1253 
1254  if(Instance >= AUDIO_OUT_INSTANCES_NBR)
1255  {
1256  ret = BSP_ERROR_WRONG_PARAM;
1257  }
1258  else
1259  {
1260  /* Return audio Output State */
1261  *State = Audio_Out_Ctx[Instance].State;
1262  }
1263 
1264  /* Return BSP status */
1265  return ret;
1266 }
1267 
1268 void BSP_AUDIO_OUT_IRQHandler(uint32_t Instance)
1269 {
1270  if (Instance == 0U)
1271  {
1273  }
1274 }
1275 
1276 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 0U)
1277 
1283 {
1284  /* Prevent unused argument(s) compilation warning */
1285  UNUSED(hsai);
1286 
1287  /* Manage the remaining file size and new address offset: This function
1288  should be coded by user (its prototype is already declared in stm32h747i_discovery_audio.h) */
1290 }
1291 
1298 {
1299  /* Prevent unused argument(s) compilation warning */
1300  UNUSED(hsai);
1301 
1302  /* Manage the remaining file size and new address offset: This function
1303  should be coded by user (its prototype is already declared in stm32h747i_discovery_audio.h) */
1305 }
1306 
1313 {
1314  if(hsai->Instance == AUDIO_OUT_SAIx)
1315  {
1317  }
1318  else
1319  {
1321  }
1322 }
1323 #endif /* USE_HAL_SAI_REGISTER_CALLBACKS == 0U) */
1324 
1325 
1331 __weak void BSP_AUDIO_OUT_TransferComplete_CallBack(uint32_t Instance)
1332 {
1333  /* Prevent unused argument(s) compilation warning */
1334  UNUSED(Instance);
1335 }
1336 
1342 __weak void BSP_AUDIO_OUT_HalfTransfer_CallBack(uint32_t Instance)
1343 {
1344  /* Prevent unused argument(s) compilation warning */
1345  UNUSED(Instance);
1346 }
1347 
1353 __weak void BSP_AUDIO_OUT_Error_CallBack(uint32_t Instance)
1354 {
1355  /* Prevent unused argument(s) compilation warning */
1356  UNUSED(Instance);
1357 }
1374 int32_t BSP_AUDIO_IN_Init(uint32_t Instance, BSP_AUDIO_Init_t* AudioInit)
1375 {
1376 
1377 
1378  if(Instance >= AUDIO_IN_INSTANCES_NBR)
1379  {
1380  return BSP_ERROR_WRONG_PARAM;
1381  }
1382  else
1383  {
1384  /* Store the audio record context */
1385  Audio_In_Ctx[Instance].Device = AudioInit->Device;
1386  Audio_In_Ctx[Instance].ChannelsNbr = AudioInit->ChannelsNbr;
1387  Audio_In_Ctx[Instance].SampleRate = AudioInit->SampleRate;
1388  Audio_In_Ctx[Instance].BitsPerSample = AudioInit->BitsPerSample;
1389  Audio_In_Ctx[Instance].Volume = AudioInit->Volume;
1391 
1392  if(Instance == 0U)
1393  {
1394  /* PLL clock is set depending by the AudioFreq (44.1khz vs 48khz groups) */
1395  if(MX_SAI1_ClockConfig(&haudio_in_sai, AudioInit->SampleRate) != HAL_OK)
1396  {
1397  return BSP_ERROR_CLOCK_FAILURE;
1398  }
1400 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1U)
1401  /* Register the default SAI MSP callbacks */
1402  if(Audio_In_Ctx[Instance].IsMspCallbacksValid == 0U)
1403  {
1404  if(BSP_AUDIO_IN_RegisterDefaultMspCallbacks(Instance) != BSP_ERROR_NONE)
1405  {
1406  return BSP_ERROR_PERIPH_FAILURE;
1407  }
1408  }
1409 #else
1411 #endif /* (USE_HAL_SAI_REGISTER_CALLBACKS == 1U) */
1412  MX_SAI_Config_t mx_config;
1413 
1414  mx_config.MonoStereoMode = (AudioInit->ChannelsNbr == 1U) ? SAI_MONOMODE : SAI_STEREOMODE;
1415  mx_config.FrameLength = 64;
1416  mx_config.ActiveFrameLength = 32;
1418  mx_config.FrameLength=(AudioInit->BitsPerSample == AUDIO_RESOLUTION_32B)?128: 64;
1419  mx_config.ActiveFrameLength=(AudioInit->BitsPerSample == AUDIO_RESOLUTION_32B)?64: 32;
1422  /* Prepare haudio_in_sai handle */
1424  mx_config.AudioFrequency = Audio_In_Ctx[Instance].SampleRate;
1425  mx_config.AudioMode = SAI_MODESLAVE_RX;
1427  mx_config.Synchro = SAI_SYNCHRONOUS;
1428  mx_config.SynchroExt = SAI_SYNCEXT_DISABLE;
1429  /* Disable SAI peripheral to allow access to SAI internal registers */
1430 
1431  if(MX_SAI1_Block_B_Init(&haudio_in_sai, &mx_config) != HAL_OK)
1432  {
1433  /* Return BSP_ERROR_PERIPH_FAILURE when operations are not correctly done */
1434  return BSP_ERROR_PERIPH_FAILURE;
1435  }
1436 
1437  /* Prepare haudio_out_sai handle */
1439  mx_config.AudioMode = SAI_MODEMASTER_RX;
1441  mx_config.OutputDrive = SAI_OUTPUTDRIVE_ENABLE;
1442  mx_config.Synchro = SAI_ASYNCHRONOUS;
1443  mx_config.SynchroExt = SAI_SYNCEXT_DISABLE;
1445  if(MX_SAI1_Block_A_Init(&haudio_out_sai, &mx_config) != HAL_OK)
1446  {
1447  /* Return BSP_ERROR_PERIPH_FAILURE when operations are not correctly done */
1448  return BSP_ERROR_PERIPH_FAILURE;
1449  }
1450 
1451 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1U)
1452  /* Register SAI TC, HT and Error callbacks */
1453  if(HAL_SAI_RegisterCallback(&haudio_in_sai, HAL_SAI_RX_COMPLETE_CB_ID, SAI_RxCpltCallback) != HAL_OK)
1454  {
1455  return BSP_ERROR_PERIPH_FAILURE;
1456  }
1457  if(HAL_SAI_RegisterCallback(&haudio_in_sai, HAL_SAI_RX_HALFCOMPLETE_CB_ID, SAI_RxHalfCpltCallback) != HAL_OK)
1458  {
1459  return BSP_ERROR_PERIPH_FAILURE;
1460  }
1461  if(HAL_SAI_RegisterCallback(&haudio_in_sai, HAL_SAI_ERROR_CB_ID, SAI_ErrorCallback) != HAL_OK)
1462  {
1463  return BSP_ERROR_PERIPH_FAILURE;
1464  }
1465 #endif /* (USE_HAL_SAI_REGISTER_CALLBACKS == 1U) */
1466 #if (USE_AUDIO_CODEC_WM8994 == 1U)
1467  /* Initialize the codec internal registers */
1468  if(WM8994_Probe() == BSP_ERROR_NONE)
1469  {
1470  WM8994_Init_t codec_init;
1471 
1472  /* Fill codec_init structure */
1473  codec_init.Frequency = AudioInit->SampleRate;
1474  codec_init.OutputDevice = WM8994_OUT_NONE;
1475  if(AudioInit->Device == AUDIO_IN_DEVICE_ANALOG_MIC)
1476  {
1477  codec_init.InputDevice = WM8994_IN_LINE1;
1479  }
1480  else /* (AudioInit->Device == AUDIO_IN_DEVICE_DIGITAL_MIC) */
1481  {
1482  codec_init.InputDevice = WM8994_IN_MIC2;
1483  }
1484  codec_init.Resolution=(AudioInit->BitsPerSample==AUDIO_RESOLUTION_32B)? 3:0;
1485  /* Convert volume before sending to the codec */
1486  codec_init.Volume = VOLUME_IN_CONVERT(AudioInit->Volume);
1487 
1488  /* Initialize the codec internal registers */
1489  if(Audio_Drv->Init(Audio_CompObj, &codec_init) != 0)
1490  {
1492  }
1493  }
1494 #endif /*USE_AUDIO_CODEC_WM8994 == 1)*/
1495  }
1496  else if(Instance == 1U)
1497  {
1498  /* PLL clock is set depending by the AudioFreq (44.1khz vs 48khz groups) */
1499  if(MX_SAI4_ClockConfig(&haudio_in_sai, AudioInit->SampleRate) != HAL_OK)
1500  {
1501  return BSP_ERROR_CLOCK_FAILURE;
1502  }
1504 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1U)
1505  /* Register the default SAI MSP callbacks */
1506  if(Audio_In_Ctx[Instance].IsMspCallbacksValid == 0U)
1507  {
1508  if(BSP_AUDIO_IN_RegisterDefaultMspCallbacks(Instance) != BSP_ERROR_NONE)
1509  {
1510  return BSP_ERROR_PERIPH_FAILURE;
1511  }
1512  }
1513 #else
1515 #endif /* (USE_HAL_SAI_REGISTER_CALLBACKS == 1U) */
1516  MX_SAI_Config_t mx_config;
1517 
1518  /* Prepare haudio_in_sai handle */
1519  mx_config.MonoStereoMode = SAI_STEREOMODE;
1520  mx_config.DataSize = SAI_DATASIZE_16;
1521  mx_config.FrameLength = 16;
1522  mx_config.ActiveFrameLength = 1;
1524  mx_config.SlotActive = SAI_SLOTACTIVE_0;
1525  mx_config.AudioFrequency = Audio_In_Ctx[Instance].SampleRate*8;
1526  mx_config.AudioMode = SAI_MODEMASTER_RX;
1528  mx_config.Synchro = SAI_ASYNCHRONOUS;
1529  mx_config.SynchroExt = SAI_SYNCEXT_DISABLE;
1530 
1531  if(MX_SAI4_Block_A_Init(&haudio_in_sai, &mx_config) != HAL_OK)
1532  {
1533  /* Return BSP_ERROR_PERIPH_FAILURE when operations are not correctly done */
1534  return BSP_ERROR_PERIPH_FAILURE;
1535  }
1536 
1537 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1U)
1538  /* Register SAI TC, HT and Error callbacks */
1539  if(HAL_SAI_RegisterCallback(&haudio_in_sai, HAL_SAI_RX_COMPLETE_CB_ID, SAI_RxCpltCallback) != HAL_OK)
1540  {
1541  return BSP_ERROR_PERIPH_FAILURE;
1542  }
1543  if(HAL_SAI_RegisterCallback(&haudio_in_sai, HAL_SAI_RX_HALFCOMPLETE_CB_ID, SAI_RxHalfCpltCallback) != HAL_OK)
1544  {
1545  return BSP_ERROR_PERIPH_FAILURE;
1546  }
1547  if(HAL_SAI_RegisterCallback(&haudio_in_sai, HAL_SAI_ERROR_CB_ID, SAI_ErrorCallback) != HAL_OK)
1548  {
1549  return BSP_ERROR_PERIPH_FAILURE;
1550  }
1551 #endif /* (USE_HAL_SAI_REGISTER_CALLBACKS == 1U) */
1552 
1553  if(BSP_AUDIO_IN_PDMToPCM_Init(Instance, AudioInit->SampleRate, Audio_In_Ctx[Instance].ChannelsNbr, Audio_In_Ctx[Instance].ChannelsNbr) != BSP_ERROR_NONE)
1554  {
1555  return BSP_ERROR_NO_INIT;
1556  }
1557  }
1558  else
1559  {}
1560 
1561  /* Update BSP AUDIO IN state */
1563  /* Return BSP status */
1564  return BSP_ERROR_NONE;
1565  }
1566 }
1567 
1574 int32_t BSP_AUDIO_IN_DeInit(uint32_t Instance)
1575 {
1576  int32_t ret = BSP_ERROR_NONE;
1577 
1578  if(Instance >= AUDIO_IN_INSTANCES_NBR)
1579  {
1580  ret = BSP_ERROR_WRONG_PARAM;
1581  }
1582  else
1583  {
1584  if(Instance == 0U)
1585  {
1586 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 0U)
1588 #endif /* (USE_HAL_SAI_REGISTER_CALLBACKS == 0U) */
1589 
1590  /* Initialize the haudio_in_sai Instance parameter */
1592  /* Initialize the haudio_out_sai Instance parameter */
1594 
1596  {
1598  }/* De-Initializes SAI handles */
1599  else if(HAL_SAI_DeInit(&haudio_in_sai) != HAL_OK)
1600  {
1602  }
1603  else
1604  {
1606  {
1608  }
1609  }
1610  }
1611  else if (Instance == 1U)
1612  {
1613 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 0U)
1615 #endif /* (USE_HAL_SAI_REGISTER_CALLBACKS == 0U) */
1616 
1617  /* Initialize the haudio_in_sai Instance parameter */
1619  /* Initialize the haudio_out_sai Instance parameter */
1621 
1623  {
1625  }
1626  else
1627  {
1629  {
1631  }
1632  }
1633  }
1634  else
1635  {}
1636  /* Update BSP AUDIO IN state */
1638  }
1639 
1640 
1641  /* Return BSP status */
1642  return ret;
1643 }
1644 
1653 {
1654  HAL_StatusTypeDef ret = HAL_OK;
1655 
1656  /* Disable SAI peripheral to allow access to SAI internal registers */
1657  __HAL_SAI_DISABLE(hsai);
1658 
1659  /* Configure SAI1_Block_B */
1660  hsai->Init.AudioFrequency = MXConfig->AudioFrequency;
1661  hsai->Init.MonoStereoMode = MXConfig->MonoStereoMode;
1662  hsai->Init.AudioMode = MXConfig->AudioMode;
1665  hsai->Init.DataSize = MXConfig->DataSize;
1666  hsai->Init.FirstBit = SAI_FIRSTBIT_MSB;
1667  hsai->Init.ClockStrobing = MXConfig->ClockStrobing;
1668  hsai->Init.Synchro = MXConfig->Synchro;
1669  hsai->Init.OutputDrive = MXConfig->OutputDrive;
1671  hsai->Init.SynchroExt = MXConfig->SynchroExt;
1674  hsai->Init.Mckdiv = 0;
1675  hsai->Init.PdmInit.Activation = DISABLE;
1676 
1677  /* Configure SAI_Block_x Frame */
1678  hsai->FrameInit.FrameLength = MXConfig->FrameLength;
1679  hsai->FrameInit.ActiveFrameLength = MXConfig->ActiveFrameLength;
1683 
1684  /* Configure SAI Block_x Slot */
1685  hsai->SlotInit.FirstBitOffset = 0;
1687  hsai->SlotInit.SlotNumber = 4;
1688  hsai->SlotInit.SlotActive = MXConfig->SlotActive;
1689 
1690  if(HAL_SAI_Init(hsai) != HAL_OK)
1691  {
1692  ret = HAL_ERROR;
1693  }
1694 
1695  /* Enable SAI peripheral */
1696  __HAL_SAI_ENABLE(hsai);
1697 
1698  return ret;
1699 }
1700 
1709 {
1710  HAL_StatusTypeDef ret = HAL_OK;
1711 
1712  /* Disable SAI peripheral to allow access to SAI internal registers */
1713  __HAL_SAI_DISABLE(hsai);
1714 
1715  /* Configure SAI4_Block_A */
1716  hsai->Init.AudioFrequency = MXConfig->AudioFrequency;
1717  hsai->Init.MonoStereoMode = MXConfig->MonoStereoMode;
1718  hsai->Init.AudioMode = MXConfig->AudioMode;
1721  hsai->Init.DataSize = MXConfig->DataSize;
1722  hsai->Init.FirstBit = SAI_FIRSTBIT_LSB;
1723  hsai->Init.ClockStrobing = MXConfig->ClockStrobing;
1724  hsai->Init.Synchro = MXConfig->Synchro;
1725  hsai->Init.OutputDrive = MXConfig->OutputDrive;
1727  hsai->Init.SynchroExt = MXConfig->SynchroExt;
1730  hsai->Init.Mckdiv = 0;
1731  hsai->Init.PdmInit.Activation = ENABLE;
1732  hsai->Init.PdmInit.MicPairsNbr = 1;
1734 
1735 
1736  /* Configure SAI_Block_x Frame */
1737  hsai->FrameInit.FrameLength = MXConfig->FrameLength;
1738  hsai->FrameInit.ActiveFrameLength = MXConfig->ActiveFrameLength;
1742 
1743  /* Configure SAI Block_x Slot */
1744  hsai->SlotInit.FirstBitOffset = 0;
1746  hsai->SlotInit.SlotNumber = 1;
1747  hsai->SlotInit.SlotActive = MXConfig->SlotActive;
1748 
1749  if(HAL_SAI_Init(hsai) != HAL_OK)
1750  {
1751  ret = HAL_ERROR;
1752  }
1753 
1754  /* Enable SAI peripheral */
1755  __HAL_SAI_ENABLE(hsai);
1756 
1757  return ret;
1758 }
1759 
1760 
1761 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1U)
1762 
1767 int32_t BSP_AUDIO_IN_RegisterDefaultMspCallbacks (uint32_t Instance)
1768 {
1769  int32_t ret = BSP_ERROR_NONE;
1770 
1771  if(Instance == 0U)
1772 
1773  {
1776 
1777 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1U)
1778  /* Register MspInit/MspDeInit Callbacks */
1779  if(HAL_SAI_RegisterCallback(&haudio_in_sai, HAL_SAI_MSPINIT_CB_ID, SAI_MspInit) != HAL_OK)
1780  {
1782  }
1783  else if(HAL_SAI_RegisterCallback(&haudio_out_sai, HAL_SAI_MSPINIT_CB_ID, SAI_MspInit) != HAL_OK)
1784  {
1786  }
1787  else if(HAL_SAI_RegisterCallback(&haudio_in_sai, HAL_SAI_MSPDEINIT_CB_ID, SAI_MspDeInit) != HAL_OK)
1788  {
1790  }
1791  else if(HAL_SAI_RegisterCallback(&haudio_out_sai, HAL_SAI_MSPDEINIT_CB_ID, SAI_MspDeInit) != HAL_OK)
1792  {
1794  }
1795  else
1796  {
1797  }
1798 #endif /* (USE_HAL_SAI_REGISTER_CALLBACKS == 1U) */
1799  }
1800  else
1801  {
1802  ret = BSP_ERROR_WRONG_PARAM;
1803  }
1804 
1805  if(ret == BSP_ERROR_NONE)
1806  {
1807  Audio_In_Ctx[Instance].IsMspCallbacksValid = 1;
1808  }
1809 
1810  /* Return BSP status */
1811  return ret;
1812 }
1813 
1820 int32_t BSP_AUDIO_IN_RegisterMspCallbacks (uint32_t Instance, BSP_AUDIO_IN_Cb_t *CallBacks)
1821 {
1822  int32_t ret = BSP_ERROR_NONE;
1823 
1824  if(Instance >= AUDIO_IN_INSTANCES_NBR)
1825  {
1826  ret = BSP_ERROR_WRONG_PARAM;
1827  }
1828  else
1829  {
1830  if(Instance == 0U)
1831  {
1832 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1U)
1833  if(HAL_SAI_RegisterCallback(&haudio_in_sai, HAL_SAI_MSPINIT_CB_ID, CallBacks->pMspSaiInitCb) != HAL_OK)
1834  {
1836  }
1837  else if(HAL_SAI_RegisterCallback(&haudio_in_sai, HAL_SAI_MSPDEINIT_CB_ID, CallBacks->pMspSaiDeInitCb) != HAL_OK)
1838  {
1840  }
1841  else
1842  {
1843  }
1844 #endif /* (USE_HAL_SAI_REGISTER_CALLBACKS == 1U) */
1845  }
1846 
1847  if(ret == BSP_ERROR_NONE)
1848  {
1849  Audio_In_Ctx[Instance].IsMspCallbacksValid = 1;
1850  }
1851  }
1852 
1853  /* Return BSP status */
1854  return ret;
1855 }
1856 #endif /* (USE_HAL_SAI_REGISTER_CALLBACKS == 1U)) */
1857 
1866 int32_t BSP_AUDIO_IN_PDMToPCM_Init(uint32_t Instance, uint32_t AudioFreq, uint32_t ChnlNbrIn, uint32_t ChnlNbrOut)
1867 {
1868  uint32_t index = 0;
1869 
1870  if(Instance != 1U)
1871  {
1872  return BSP_ERROR_WRONG_PARAM;
1873  }
1874  else
1875  {
1876  /* Enable CRC peripheral to unlock the PDM library */
1878 
1879  for(index = 0; index < ChnlNbrIn; index++)
1880  {
1881  /* Init PDM filters */
1882  PDM_FilterHandler[index].bit_order = PDM_FILTER_BIT_ORDER_MSB;
1883  PDM_FilterHandler[index].endianness = PDM_FILTER_ENDIANNESS_LE;
1884  PDM_FilterHandler[index].high_pass_tap = 2122358088;
1885  PDM_FilterHandler[index].out_ptr_channels = ChnlNbrOut;
1886  PDM_FilterHandler[index].in_ptr_channels = ChnlNbrIn;
1887  PDM_Filter_Init((PDM_Filter_Handler_t *)(&PDM_FilterHandler[index]));
1888 
1889  /* PDM lib config phase */
1890  PDM_FilterConfig[index].output_samples_number = AudioFreq/1000;
1891  PDM_FilterConfig[index].mic_gain = 24;
1892  PDM_FilterConfig[index].decimation_factor = PDM_FILTER_DEC_FACTOR_64;
1893  PDM_Filter_setConfig((PDM_Filter_Handler_t *)&PDM_FilterHandler[index], &PDM_FilterConfig[index]);
1894  }
1895  }
1896 
1897  return BSP_ERROR_NONE;
1898 }
1899 
1900 
1908 int32_t BSP_AUDIO_IN_PDMToPCM(uint32_t Instance, uint16_t *PDMBuf, uint16_t *PCMBuf)
1909 {
1910  uint32_t index = 0;
1911 
1912  if(Instance != 1U)
1913  {
1914  return BSP_ERROR_WRONG_PARAM;
1915  }
1916  else
1917  {
1918  for(index = 0; index < Audio_In_Ctx[Instance].ChannelsNbr; index++)
1919  {
1920  PDM_Filter(&((uint8_t*)(PDMBuf))[index], (uint16_t*)&(PCMBuf[index]), &PDM_FilterHandler[index]);
1921  }
1922  }
1923 
1924  return BSP_ERROR_NONE;
1925 }
1926 
1934 int32_t BSP_AUDIO_IN_Record(uint32_t Instance, uint8_t* pBuf, uint32_t NbrOfBytes)
1935 {
1936  int32_t ret= BSP_ERROR_NONE;
1937 
1938  if(Instance > 0U)
1939  {
1940  ret = BSP_ERROR_WRONG_PARAM;
1941  }
1942  else
1943  {
1944  /* Start the process receive DMA */
1945  if(HAL_SAI_Receive_DMA(&haudio_in_sai, (uint8_t*)pBuf, (uint16_t)(NbrOfBytes/(Audio_In_Ctx[Instance].BitsPerSample/8U))) != HAL_OK)
1946  {
1948  }
1949  }
1950  /* Return BSP status */
1951  return ret;
1952 }
1953 
1959 int32_t BSP_AUDIO_IN_Stop(uint32_t Instance)
1960 {
1961  int32_t ret = BSP_ERROR_NONE;
1962 
1963  if(Instance >= AUDIO_IN_INSTANCES_NBR)
1964  {
1965  ret = BSP_ERROR_WRONG_PARAM;
1966  }
1967  else
1968  {
1969 
1970  if(Instance == 0U)
1971  {
1972  /* Call the Media layer stop function */
1974  {
1976  }
1977  }
1978 
1979  if(ret == BSP_ERROR_NONE)
1980  {
1982  {
1984  }
1985  }
1986  }
1987 
1988 
1989  /* Update BSP AUDIO IN state */
1991 
1992  /* Return BSP status */
1993  return ret;
1994 }
1995 
2001 int32_t BSP_AUDIO_IN_Pause(uint32_t Instance)
2002 {
2003  int32_t ret = BSP_ERROR_NONE;
2004  if(Instance >= AUDIO_IN_INSTANCES_NBR)
2005  {
2006  ret = BSP_ERROR_WRONG_PARAM;
2007  }
2008  else
2009  {
2010  if(Instance == 0U)
2011  {
2012  /* Call Audio Codec Pause function */
2014  {
2016  }
2017  }
2018  if(ret == BSP_ERROR_NONE)
2019  {
2021  {
2023  }
2024  else
2025  {
2026  /* Update BSP AUDIO IN state */
2028  }
2029  }
2030  }
2031  /* Return BSP status */
2032  return ret;
2033 }
2034 
2040 int32_t BSP_AUDIO_IN_Resume(uint32_t Instance)
2041 {
2042  int32_t ret = BSP_ERROR_NONE;
2043  if(Instance >= AUDIO_IN_INSTANCES_NBR)
2044  {
2045  ret = BSP_ERROR_WRONG_PARAM;
2046  }
2047  else
2048  {
2049  /* Call Audio Codec Pause function */
2051  {
2053  }
2054  else
2055  {
2056  if(Instance == 0U)
2057  {
2058  if(Audio_Drv->Resume(Audio_CompObj) != 0)
2059  {
2061  }
2062  }
2063  }
2064 
2065  if(ret == BSP_ERROR_NONE)
2066  {
2067  /* Update BSP AUDIO IN state */
2069  }
2070  }
2071  /* Return BSP status */
2072  return ret;
2073 }
2074 
2082 int32_t BSP_AUDIO_IN_RecordPDM(uint32_t Instance, uint8_t* pBuf, uint32_t NbrOfBytes)
2083 {
2084  int32_t ret = BSP_ERROR_NONE;
2085 
2086  if(Instance != 1U)
2087  {
2088  ret = BSP_ERROR_WRONG_PARAM;
2089  }
2090  else
2091  {
2092  /* Start the process receive DMA */
2093  if(HAL_SAI_Receive_DMA(&haudio_in_sai, (uint8_t*)pBuf, (uint16_t)(NbrOfBytes/(Audio_In_Ctx[Instance].BitsPerSample/8U))) != HAL_OK)
2094  {
2096  }
2097  }
2098 
2099  /* Return BSP status */
2100  return ret;
2101 }
2102 
2103 
2110 int32_t BSP_AUDIO_IN_SetDevice(uint32_t Instance, uint32_t Device)
2111 {
2112  int32_t ret = BSP_ERROR_NONE;
2113  BSP_AUDIO_Init_t audio_init;
2114 
2115  if(Instance >= AUDIO_IN_INSTANCES_NBR)
2116  {
2117  ret = BSP_ERROR_WRONG_PARAM;
2118  }
2119  else if(Audio_In_Ctx[Instance].State == AUDIO_IN_STATE_STOP)
2120  {
2121 
2122  audio_init.Device = Device;
2123  audio_init.ChannelsNbr = Audio_In_Ctx[Instance].ChannelsNbr;
2124  audio_init.SampleRate = Audio_In_Ctx[Instance].SampleRate;
2125  audio_init.BitsPerSample = Audio_In_Ctx[Instance].BitsPerSample;
2126  audio_init.Volume = Audio_In_Ctx[Instance].Volume;
2127 
2128  if(BSP_AUDIO_IN_Init(Instance, &audio_init) != BSP_ERROR_NONE)
2129  {
2130  ret = BSP_ERROR_NO_INIT;
2131  }
2132  }
2133  else
2134  {
2135  ret = BSP_ERROR_BUSY;
2136  }
2137 
2138  /* Return BSP status */
2139  return ret;
2140 }
2141 
2148 int32_t BSP_AUDIO_IN_GetDevice(uint32_t Instance, uint32_t *Device)
2149 {
2150  int32_t ret = BSP_ERROR_NONE;
2151 
2152  if(Instance >= AUDIO_IN_INSTANCES_NBR)
2153  {
2154  ret = BSP_ERROR_WRONG_PARAM;
2155  }
2156  else
2157  {
2158  /* Return audio Input Device */
2159  *Device = Audio_In_Ctx[Instance].Device;
2160  }
2161  return ret;
2162 }
2163 
2170 int32_t BSP_AUDIO_IN_SetSampleRate(uint32_t Instance, uint32_t SampleRate)
2171 {
2172  int32_t ret = BSP_ERROR_NONE;
2173 
2174  BSP_AUDIO_Init_t audio_init;
2175 
2176  if(Instance >= AUDIO_IN_INSTANCES_NBR)
2177  {
2178  ret = BSP_ERROR_WRONG_PARAM;
2179  }
2180  else if(Audio_In_Ctx[Instance].State == AUDIO_IN_STATE_STOP)
2181  {
2182  audio_init.Device = Audio_In_Ctx[Instance].Device;
2183  audio_init.ChannelsNbr = Audio_In_Ctx[Instance].ChannelsNbr;
2184  audio_init.SampleRate = SampleRate;
2185  audio_init.BitsPerSample = Audio_In_Ctx[Instance].BitsPerSample;
2186  audio_init.Volume = Audio_In_Ctx[Instance].Volume;
2187  if(BSP_AUDIO_IN_Init(Instance, &audio_init) != BSP_ERROR_NONE)
2188  {
2189  ret = BSP_ERROR_NO_INIT;
2190  }
2191  }
2192  else
2193  {
2194  ret = BSP_ERROR_BUSY;
2195  }
2196 
2197  /* Return BSP status */
2198  return ret;
2199 }
2200 
2207 int32_t BSP_AUDIO_IN_GetSampleRate(uint32_t Instance, uint32_t *SampleRate)
2208 {
2209  int32_t ret = BSP_ERROR_NONE;
2210 
2211  if(Instance >= AUDIO_IN_INSTANCES_NBR)
2212  {
2213  ret = BSP_ERROR_WRONG_PARAM;
2214  }
2215  else
2216  {
2217  /* Return audio in frequency */
2218  *SampleRate = Audio_In_Ctx[Instance].SampleRate;
2219  }
2220 
2221  /* Return BSP status */
2222  return ret;
2223 }
2224 
2231 int32_t BSP_AUDIO_IN_SetBitsPerSample(uint32_t Instance, uint32_t BitsPerSample)
2232 {
2233  int32_t ret = BSP_ERROR_NONE;
2234 
2235  BSP_AUDIO_Init_t audio_init;
2236 
2237  if(Instance >= AUDIO_IN_INSTANCES_NBR)
2238  {
2239  ret = BSP_ERROR_WRONG_PARAM;
2240  }
2241  else if(Audio_In_Ctx[Instance].State == AUDIO_IN_STATE_STOP)
2242  {
2243 
2244  audio_init.Device = Audio_In_Ctx[Instance].Device;
2245  audio_init.ChannelsNbr = Audio_In_Ctx[Instance].ChannelsNbr;
2246  audio_init.SampleRate = Audio_In_Ctx[Instance].SampleRate;
2247  audio_init.BitsPerSample = BitsPerSample;
2248  audio_init.Volume = Audio_In_Ctx[Instance].Volume;
2249  if(BSP_AUDIO_IN_Init(Instance, &audio_init) != BSP_ERROR_NONE)
2250  {
2251  ret = BSP_ERROR_NO_INIT;
2252  }
2253  }
2254  else
2255  {
2256  ret = BSP_ERROR_BUSY;
2257  }
2258 
2259  /* Return BSP status */
2260  return ret;
2261 }
2262 
2269 int32_t BSP_AUDIO_IN_GetBitsPerSample(uint32_t Instance, uint32_t *BitsPerSample)
2270 {
2271  int32_t ret = BSP_ERROR_NONE;
2272 
2273  if(Instance >= AUDIO_IN_INSTANCES_NBR)
2274  {
2275  ret = BSP_ERROR_WRONG_PARAM;
2276  }
2277  else
2278  {
2279  /* Return audio in resolution */
2280  *BitsPerSample = Audio_In_Ctx[Instance].BitsPerSample;
2281  }
2282  return ret;
2283 }
2284 
2291 int32_t BSP_AUDIO_IN_SetChannelsNbr(uint32_t Instance, uint32_t ChannelNbr)
2292 {
2293  int32_t ret = BSP_ERROR_NONE;
2294 
2295  if((Instance >= AUDIO_IN_INSTANCES_NBR) || (ChannelNbr > 2U))
2296  {
2297  ret = BSP_ERROR_WRONG_PARAM;
2298  }
2299  else
2300  {
2301  /* Update AudioIn Context */
2302  Audio_In_Ctx[Instance].ChannelsNbr = ChannelNbr;
2303  }
2304  /* Return BSP status */
2305  return ret;
2306 }
2307 
2314 int32_t BSP_AUDIO_IN_GetChannelsNbr(uint32_t Instance, uint32_t *ChannelNbr)
2315 {
2316  int32_t ret = BSP_ERROR_NONE;
2317 
2318  if(Instance >= AUDIO_IN_INSTANCES_NBR)
2319  {
2320  ret = BSP_ERROR_WRONG_PARAM;
2321  }
2322  else
2323  {
2324  /* Channel number to be returned */
2325  *ChannelNbr = Audio_In_Ctx[Instance].ChannelsNbr;
2326  }
2327  return ret;
2328 }
2329 
2336 int32_t BSP_AUDIO_IN_SetVolume(uint32_t Instance, uint32_t Volume)
2337 {
2338  int32_t ret = BSP_ERROR_NONE;
2339 
2340  if(Instance >= AUDIO_IN_INSTANCES_NBR)
2341  {
2342  ret = BSP_ERROR_WRONG_PARAM;
2343  }
2345  {
2347  }
2348  else
2349  {
2350  /* Update AudioIn Context */
2351  Audio_In_Ctx[Instance].Volume = Volume;
2352  }
2353  /* Return BSP status */
2354  return ret;
2355 }
2356 
2363 int32_t BSP_AUDIO_IN_GetVolume(uint32_t Instance, uint32_t *Volume)
2364 {
2365  int32_t ret = BSP_ERROR_NONE;
2366 
2367  if(Instance >= AUDIO_IN_INSTANCES_NBR)
2368  {
2369  ret = BSP_ERROR_WRONG_PARAM;
2370  }
2371  else
2372  {
2373  /* Input Volume to be returned */
2374  *Volume = Audio_In_Ctx[Instance].Volume;
2375  }
2376  /* Return BSP status */
2377  return ret;
2378 }
2385 int32_t BSP_AUDIO_IN_GetState(uint32_t Instance, uint32_t *State)
2386 {
2387  int32_t ret = BSP_ERROR_NONE;
2388 
2389  if(Instance >= AUDIO_IN_INSTANCES_NBR)
2390  {
2391  ret = BSP_ERROR_WRONG_PARAM;
2392  }
2393  else
2394  {
2395  /* Input State to be returned */
2396  *State = Audio_In_Ctx[Instance].State;
2397  }
2398  return ret;
2399 }
2400 
2409 void BSP_AUDIO_IN_IRQHandler(uint32_t Instance, uint32_t InputDevice)
2410 {
2411  if ((InputDevice == AUDIO_IN_DEVICE_DIGITAL_MIC) || (InputDevice == AUDIO_IN_DEVICE_ANALOG_MIC))
2412  {
2414  }
2415 }
2416 
2417 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 0U)
2418 
2424 {
2425  /* Call the record update function to get the first half */
2426  if(hsai->Instance == AUDIO_IN_SAIx)
2427  {
2429  }
2430  else
2431  {
2433  }
2434 }
2435 
2442 {
2443  /* Call the record update function to get the second half */
2444  if(hsai->Instance == AUDIO_IN_SAIx)
2445  {
2447  }
2448  else
2449  {
2451  }
2452 }
2453 #endif /* (USE_HAL_SAI_REGISTER_CALLBACKS == 0U) */
2454 
2459 __weak void BSP_AUDIO_IN_TransferComplete_CallBack(uint32_t Instance)
2460 {
2461  /* Prevent unused argument(s) compilation warning */
2462  UNUSED(Instance);
2463 
2464  /* This function should be implemented by the user application.
2465  It is called into this driver when the current buffer is filled
2466  to prepare the next buffer pointer and its size. */
2467 }
2468 
2473 __weak void BSP_AUDIO_IN_HalfTransfer_CallBack(uint32_t Instance)
2474 {
2475  /* Prevent unused argument(s) compilation warning */
2476  UNUSED(Instance);
2477 
2478  /* This function should be implemented by the user application.
2479  It is called into this driver when the current buffer is filled
2480  to prepare the next buffer pointer and its size. */
2481 }
2482 
2487 __weak void BSP_AUDIO_IN_Error_CallBack(uint32_t Instance)
2488 {
2489  /* Prevent unused argument(s) compilation warning */
2490  UNUSED(Instance);
2491 
2492  /* This function is called when an Interrupt due to transfer error on or peripheral
2493  error occurs. */
2494 }
2502 /*******************************************************************************
2503  Static Functions
2504 *******************************************************************************/
2505 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1U)
2506 
2511 static void SAI_RxHalfCpltCallback(SAI_HandleTypeDef *hsai)
2512 {
2513  /* Call the record update function to get the first half */
2514  if(hsai->Instance == AUDIO_IN_SAIx)
2515  {
2517  }
2518  else
2519  {
2521  }
2522 }
2523 
2529 static void SAI_RxCpltCallback(SAI_HandleTypeDef *hsai)
2530 {
2531  /* Call the record update function to get the second half */
2532  if(hsai->Instance == AUDIO_IN_SAIx)
2533  {
2535  }
2536  else
2537  {
2539  }
2540 }
2541 #endif /* (USE_HAL_SAI_REGISTER_CALLBACKS == 1U) */
2542 
2543 #if (USE_AUDIO_CODEC_WM8994 == 1)
2544 
2548 static int32_t WM8994_Probe(void)
2549 {
2550  int32_t ret = BSP_ERROR_NONE;
2551  WM8994_IO_t IOCtx;
2552  static WM8994_Object_t WM8994Obj;
2553  uint32_t id;
2554 
2555  /* Configure the audio driver */
2556  IOCtx.Address = AUDIO_I2C_ADDRESS;
2557  IOCtx.Init = BSP_I2C4_Init;
2558  IOCtx.DeInit = BSP_I2C4_DeInit;
2559  IOCtx.ReadReg = BSP_I2C4_ReadReg16;
2560  IOCtx.WriteReg = BSP_I2C4_WriteReg16;
2561  IOCtx.GetTick = BSP_GetTick;
2562 
2563  if(WM8994_RegisterBusIO (&WM8994Obj, &IOCtx) != WM8994_OK)
2564  {
2565  ret = BSP_ERROR_BUS_FAILURE;
2566  }
2567  else
2568  {
2569  /* Reset the codec */
2570  if(WM8994_Reset(&WM8994Obj) != WM8994_OK)
2571  {
2573  }
2574  else if(WM8994_ReadID(&WM8994Obj, &id) != WM8994_OK)
2575  {
2577  }
2578  else if(id != WM8994_ID)
2579  {
2581  }
2582  else
2583  {
2585  Audio_CompObj = &WM8994Obj;
2586  }
2587  }
2588  return ret;
2589 }
2590 #endif
2591 
2597 static void SAI_MspInit(SAI_HandleTypeDef *hsai)
2598 {
2599  GPIO_InitTypeDef gpio_init_structure;
2600  static DMA_HandleTypeDef hdma_sai_tx, hdma_sai_rx;
2601 
2602  /* Enable SAI clock */
2604 
2605  /* Enable GPIO clock */
2609  /* CODEC_SAI pins configuration: FS, SCK, MCK and SD pins ------------------*/
2610  gpio_init_structure.Pin = AUDIO_OUT_SAIx_FS_PIN;
2611  gpio_init_structure.Mode = GPIO_MODE_AF_PP;
2612  gpio_init_structure.Pull = GPIO_NOPULL;
2613  gpio_init_structure.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
2614  gpio_init_structure.Alternate = AUDIO_OUT_SAIx_FS_AF;
2615  HAL_GPIO_Init(AUDIO_OUT_SAIx_FS_GPIO_PORT, &gpio_init_structure);
2616 
2617  gpio_init_structure.Pin = AUDIO_OUT_SAIx_SCK_PIN;
2618  gpio_init_structure.Alternate = AUDIO_OUT_SAIx_SCK_AF;
2619  HAL_GPIO_Init(AUDIO_OUT_SAIx_SCK_GPIO_PORT, &gpio_init_structure);
2620 
2621  gpio_init_structure.Pin = AUDIO_OUT_SAIx_SD_PIN;
2622  gpio_init_structure.Alternate = AUDIO_OUT_SAIx_SD_AF;
2623  HAL_GPIO_Init(AUDIO_OUT_SAIx_SD_GPIO_PORT, &gpio_init_structure);
2624 
2625  if(hsai->Instance != AUDIO_IN_SAI_PDMx)
2626  {
2628  {
2630  gpio_init_structure.Pin = AUDIO_OUT_SAIx_MCLK_PIN;
2631  gpio_init_structure.Alternate = AUDIO_OUT_SAIx_MCLK_AF;
2632  HAL_GPIO_Init(AUDIO_OUT_SAIx_MCLK_GPIO_PORT, &gpio_init_structure);
2633  }
2634  }
2635 
2636  if(hsai->Instance == AUDIO_OUT_SAIx)
2637  {
2638 
2639  /* Enable SAI clock */
2641 
2642  /* CODEC_SAI pins configuration: FS, SCK and SD pins */
2643  /* Enable FS, SCK and SD clocks */
2645  /* Enable FS, SCK and SD pins */
2646  gpio_init_structure.Pin = GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6;
2647  gpio_init_structure.Mode = GPIO_MODE_AF_PP;
2648  gpio_init_structure.Pull = GPIO_NOPULL;
2649  gpio_init_structure.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
2650  gpio_init_structure.Alternate = GPIO_AF6_SAI1;
2651  HAL_GPIO_Init(GPIOE, &gpio_init_structure);
2652 
2653  /* Enable MCLK clock */
2655  /* Enable MCLK pin */
2656  gpio_init_structure.Pin = GPIO_PIN_7;
2657  HAL_GPIO_Init(GPIOG, &gpio_init_structure);
2658 
2659 
2660  /* Enable the DMA clock */
2662 
2663  /* Configure the hdma_saiTx handle parameters */
2664  if(Audio_Out_Ctx[0].BitsPerSample == AUDIO_RESOLUTION_16B)
2665  {
2668  }
2669  else
2670  {
2673  }
2674 
2676  hdma_sai_tx.Init.PeriphInc = DMA_PINC_DISABLE;
2677  hdma_sai_tx.Init.MemInc = DMA_MINC_ENABLE;
2678  hdma_sai_tx.Init.Mode = DMA_CIRCULAR;
2679  hdma_sai_tx.Init.Priority = DMA_PRIORITY_HIGH;
2680  hdma_sai_tx.Init.FIFOMode = DMA_FIFOMODE_ENABLE;
2682  hdma_sai_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
2683  hdma_sai_tx.Instance = AUDIO_OUT_SAIx_DMAx_STREAM;
2684  hdma_sai_tx.Init.MemBurst = DMA_MBURST_SINGLE;
2685  hdma_sai_tx.Init.PeriphBurst = DMA_PBURST_SINGLE;
2686 
2687  /* Associate the DMA handle */
2688  __HAL_LINKDMA(hsai, hdmatx, hdma_sai_tx);
2689 
2690  /* Deinitialize the Stream for new transfer */
2691  (void)HAL_DMA_DeInit(&hdma_sai_tx);
2692 
2693  /* Configure the DMA Stream */
2694  (void)HAL_DMA_Init(&hdma_sai_tx);
2695 
2696  /* SAI DMA IRQ Channel configuration */
2699  }
2700 
2701  /* Audio In Msp initialization */
2702  if(hsai->Instance == AUDIO_IN_SAI_PDMx)
2703  {
2704  /* Enable SAI clock */
2706 
2709 
2710  gpio_init_structure.Pin = AUDIO_IN_SAI_PDMx_CLK_IN_PIN;
2711  gpio_init_structure.Mode = GPIO_MODE_AF_PP;
2712  gpio_init_structure.Pull = GPIO_NOPULL;
2713  gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
2714  gpio_init_structure.Alternate = GPIO_AF10_SAI4;
2715  HAL_GPIO_Init(AUDIO_IN_SAI_PDMx_CLK_IN_PORT, &gpio_init_structure);
2716 
2717  gpio_init_structure.Pull = GPIO_PULLUP;
2718  gpio_init_structure.Speed = GPIO_SPEED_FREQ_MEDIUM;
2719  gpio_init_structure.Pin = AUDIO_IN_SAI_PDMx_DATA_IN_PIN;
2720  HAL_GPIO_Init(AUDIO_IN_SAI_PDMx_DATA_IN_PORT, &gpio_init_structure);
2721 
2723 
2724  /* CODEC_SAI pins configuration: FS, SCK, MCK and SD pins ------------------*/
2725  gpio_init_structure.Pin = AUDIO_IN_SAI_PDMx_FS_PIN | AUDIO_IN_SAI_PDMx_SCK_PIN;
2726  gpio_init_structure.Mode = GPIO_MODE_AF_PP;
2727  gpio_init_structure.Pull = GPIO_NOPULL;
2728  gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
2729  gpio_init_structure.Alternate = AUDIO_IN_SAI_PDMx_FS_SCK_AF;
2730  HAL_GPIO_Init(AUDIO_IN_SAI_PDMx_FS_SCK_GPIO_PORT, &gpio_init_structure);
2731 
2732  /* Enable the DMA clock */
2734  /* Configure the hdma_sai_rx handle parameters */
2736  hdma_sai_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
2737  hdma_sai_rx.Init.PeriphInc = DMA_PINC_DISABLE;
2738  hdma_sai_rx.Init.MemInc = DMA_MINC_ENABLE;
2741  hdma_sai_rx.Init.Mode = DMA_CIRCULAR;
2742  hdma_sai_rx.Init.Priority = DMA_PRIORITY_HIGH;
2743  hdma_sai_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
2745  hdma_sai_rx.Init.MemBurst = DMA_MBURST_SINGLE;
2746  hdma_sai_rx.Init.PeriphBurst = DMA_MBURST_SINGLE;
2747 
2749 
2750  /* Associate the DMA handle */
2751  __HAL_LINKDMA(hsai, hdmarx, hdma_sai_rx);
2752 
2753  /* Deinitialize the Stream for new transfer */
2754  HAL_DMA_DeInit(&hdma_sai_rx);
2755 
2756  /* Configure the DMA Stream */
2757  HAL_DMA_Init(&hdma_sai_rx);
2758 
2759  /* SAI DMA IRQ Channel configuration */
2762  }
2763  /* Audio In Msp initialization */
2764  if(hsai->Instance == AUDIO_IN_SAIx)
2765  {
2766  /* Enable SAI clock */
2768 
2769  /* Enable SD GPIO clock */
2771  /* CODEC_SAI pin configuration: SD pin */
2772  gpio_init_structure.Pin = AUDIO_IN_SAIx_SD_PIN;
2773  gpio_init_structure.Mode = GPIO_MODE_AF_PP;
2774  gpio_init_structure.Pull = GPIO_NOPULL;
2775  gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
2776  gpio_init_structure.Alternate = AUDIO_IN_SAIx_AF;
2777  HAL_GPIO_Init(AUDIO_IN_SAIx_SD_GPIO_PORT, &gpio_init_structure);
2778 
2779  /* Enable the DMA clock */
2781 
2782  /* Configure the hdma_sai_rx handle parameters */
2783  hdma_sai_rx.Init.Request = AUDIO_IN_SAIx_DMAx_REQUEST;
2784  hdma_sai_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
2785  hdma_sai_rx.Init.PeriphInc = DMA_PINC_DISABLE;
2786  hdma_sai_rx.Init.MemInc = DMA_MINC_ENABLE;
2789  hdma_sai_rx.Init.Mode = DMA_CIRCULAR;
2790  hdma_sai_rx.Init.Priority = DMA_PRIORITY_HIGH;
2791  hdma_sai_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
2793  hdma_sai_rx.Init.MemBurst = DMA_MBURST_SINGLE;
2794  hdma_sai_rx.Init.PeriphBurst = DMA_MBURST_SINGLE;
2795 
2796  hdma_sai_rx.Instance = AUDIO_IN_SAIx_DMAx_STREAM;
2797 
2798  /* Associate the DMA handle */
2799  __HAL_LINKDMA(hsai, hdmarx, hdma_sai_rx);
2800 
2801  /* Deinitialize the Stream for new transfer */
2802  HAL_DMA_DeInit(&hdma_sai_rx);
2803 
2804  /* Configure the DMA Stream */
2805  HAL_DMA_Init(&hdma_sai_rx);
2806 
2807  /* SAI DMA IRQ Channel configuration */
2810 
2811  }
2812 }
2813 
2820 {
2821  GPIO_InitTypeDef gpio_init_structure;
2822  if(hsai->Instance == AUDIO_OUT_SAIx)
2823  {
2824  /* SAI DMA IRQ Channel deactivation */
2826 
2827  /* Deinitialize the DMA stream */
2828  (void)HAL_DMA_DeInit(hsai->hdmatx);
2829 
2830  /* Disable SAI peripheral */
2831  __HAL_SAI_DISABLE(hsai);
2832 
2833  /* Deactivates CODEC_SAI pins FS, SCK, MCK and SD by putting them in input mode */
2834  gpio_init_structure.Pin = AUDIO_OUT_SAIx_FS_PIN;
2835  HAL_GPIO_DeInit(AUDIO_OUT_SAIx_FS_GPIO_PORT, gpio_init_structure.Pin);
2836 
2837  gpio_init_structure.Pin = AUDIO_OUT_SAIx_SCK_PIN;
2838  HAL_GPIO_DeInit(AUDIO_OUT_SAIx_SCK_GPIO_PORT, gpio_init_structure.Pin);
2839 
2840  gpio_init_structure.Pin = AUDIO_OUT_SAIx_SD_PIN;
2841  HAL_GPIO_DeInit(AUDIO_OUT_SAIx_SD_GPIO_PORT, gpio_init_structure.Pin);
2842 
2843  gpio_init_structure.Pin = AUDIO_OUT_SAIx_MCLK_PIN;
2844  HAL_GPIO_DeInit(AUDIO_OUT_SAIx_MCLK_GPIO_PORT, gpio_init_structure.Pin);
2845 
2846  /* Disable SAI clock */
2848  }
2849  if(hsai->Instance == AUDIO_IN_SAIx)
2850  {
2851  /* SAI DMA IRQ Channel deactivation */
2853 
2854  /* Deinitialize the DMA stream */
2855  (void)HAL_DMA_DeInit(hsai->hdmarx);
2856 
2857  /* Disable SAI peripheral */
2858  __HAL_SAI_DISABLE(hsai);
2859 
2860  /* Deactivates CODEC_SAI pin SD by putting them in input mode */
2861  gpio_init_structure.Pin = AUDIO_IN_SAIx_SD_PIN;
2862  HAL_GPIO_DeInit(AUDIO_IN_SAIx_SD_GPIO_PORT, gpio_init_structure.Pin);
2863 
2864  /* Disable SAI clock */
2866  }
2867 }
2868 
2869 
2870 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1U)
2871 
2876 static void SAI_TxCpltCallback(SAI_HandleTypeDef *hsai)
2877 {
2878  /* Prevent unused argument(s) compilation warning */
2879  UNUSED(hsai);
2880 
2881  /* Manage the remaining file size and new address offset: This function
2882  should be coded by user (its prototype is already declared in stm32h747i_discovery_audio.h) */
2884 }
2890 static void SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai)
2891 {
2892  /* Prevent unused argument(s) compilation warning */
2893  UNUSED(hsai);
2894 
2895  /* Manage the remaining file size and new address offset: This function
2896  should be coded by user (its prototype is already declared in stm32h747i_discovery_audio.h) */
2898 }
2899 
2905 static void SAI_ErrorCallback(SAI_HandleTypeDef *hsai)
2906 {
2907  if(hsai->Instance == AUDIO_OUT_SAIx)
2908  {
2910  }
2911  else
2912  {
2914  }
2915 }
2916 #endif /* (USE_HAL_SAI_REGISTER_CALLBACKS == 1U) */
2917 
2934 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
WM8994_Init_t::InputDevice
uint32_t InputDevice
Definition: stm32h747/stm32h747i-disco/CM7/Drivers/BSP/Components/wm8994/wm8994.h:71
SAI_FS_STARTFRAME
#define SAI_FS_STARTFRAME
Definition: stm32f7xx_hal_sai.h:420
BSP_AUDIO_OUT_TransferComplete_CallBack
__weak void BSP_AUDIO_OUT_TransferComplete_CallBack(uint32_t Instance)
Manages the DMA full Transfer complete event.
Definition: stm32h747i_discovery_audio.c:1331
AUDIO_OUT_Ctx_t
Definition: stm32h747i_discovery_audio.h:81
HAL_SAI_TxHalfCpltCallback
void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai)
Tx Half Transfer completed callbacks.
Definition: stm32h747i_discovery_audio.c:1297
SAI_InitTypeDef::MonoStereoMode
uint32_t MonoStereoMode
Definition: stm32f7xx_hal_sai.h:105
BSP_AUDIO_Init_t::SampleRate
uint32_t SampleRate
Definition: stm32h747i_discovery_audio.h:59
BSP_AUDIO_Init_t
Definition: stm32h747i_discovery_audio.h:56
__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
GPIO_MODE_AF_PP
#define GPIO_MODE_AF_PP
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:122
HAL_StatusTypeDef
HAL_StatusTypeDef
HAL Status structures definition
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:40
WM8994_IN_MIC2
#define WM8994_IN_MIC2
Definition: stm32h747/stm32h747i-disco/CM7/Drivers/BSP/Components/wm8994/wm8994.h:115
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
WM8994_Reset
int32_t WM8994_Reset(WM8994_Object_t *pObj)
Resets wm8994 registers.
Definition: stm32h747/stm32h747i-disco/CM7/Drivers/BSP/Components/wm8994/wm8994.c:1308
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
MX_SAI_Config_t::ClockStrobing
uint32_t ClockStrobing
Definition: stm32h747i_discovery_audio.h:100
BSP_AUDIO_IN_SetDevice
int32_t BSP_AUDIO_IN_SetDevice(uint32_t Instance, uint32_t Device)
Set Audio In device.
Definition: stm32h747i_discovery_audio.c:2110
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
SAI_CLOCKSTROBING_FALLINGEDGE
#define SAI_CLOCKSTROBING_FALLINGEDGE
Definition: stm32f7xx_hal_sai.h:382
BSP_AUDIO_OUT_GetSampleRate
int32_t BSP_AUDIO_OUT_GetSampleRate(uint32_t Instance, uint32_t *SampleRate)
Get the audio frequency.
Definition: stm32h747i_discovery_audio.c:1041
SAI_InitTypeDef::CompandingMode
uint32_t CompandingMode
Definition: stm32f7xx_hal_sai.h:108
BSP_AUDIO_OUT_Init
int32_t BSP_AUDIO_OUT_Init(uint32_t Instance, BSP_AUDIO_Init_t *AudioInit)
Configures the audio peripherals.
Definition: stm32h747i_discovery_audio.c:217
WM8994_IO_t::Address
uint16_t Address
Definition: stm32h747/stm32h747i-disco/CM7/Drivers/BSP/Components/wm8994/wm8994.h:55
BSP_AUDIO_OUT_Mute
int32_t BSP_AUDIO_OUT_Mute(uint32_t Instance)
Enables the MUTE.
Definition: stm32h747i_discovery_audio.c:833
SAI_FrameInitTypeDef::ActiveFrameLength
uint32_t ActiveFrameLength
Definition: stm32f7xx_hal_sai.h:146
MX_SAI_Config_t::FrameLength
uint32_t FrameLength
Definition: stm32h747i_discovery_audio.h:104
AUDIO_IN_STATE_RECORDING
#define AUDIO_IN_STATE_RECORDING
Definition: stm32h747i_discovery_audio.h:301
__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
CODEC_MUTE_OFF
#define CODEC_MUTE_OFF
Definition: stm32h747i_discovery_audio.h:184
WM8994_IO_t
Definition: stm32h747/stm32h747i-disco/CM7/Drivers/BSP/Components/wm8994/wm8994.h:51
GPIO_SPEED_FREQ_HIGH
#define GPIO_SPEED_FREQ_HIGH
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:144
GPIO_InitTypeDef
GPIO Init structure definition
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:47
BSP_AUDIO_IN_SetChannelsNbr
int32_t BSP_AUDIO_IN_SetChannelsNbr(uint32_t Instance, uint32_t ChannelNbr)
Set Audio In Channel number.
Definition: stm32h747i_discovery_audio.c:2291
__SAI_HandleTypeDef::hdmatx
DMA_HandleTypeDef * hdmatx
Definition: stm32f7xx_hal_sai.h:207
DMA_PDATAALIGN_WORD
#define DMA_PDATAALIGN_WORD
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:261
AUDIO_IN_SAI_PDMx_CLK_IN_PORT
#define AUDIO_IN_SAI_PDMx_CLK_IN_PORT
Definition: stm32h747i_discovery_audio.h:275
HAL_SAI_DMAPause
HAL_StatusTypeDef HAL_SAI_DMAPause(SAI_HandleTypeDef *hsai)
SAI_MspDeInit
static void SAI_MspDeInit(SAI_HandleTypeDef *hsai)
Deinitializes SAI MSP.
Definition: stm32h747i_discovery_audio.c:2819
AUDIO_IN_SAIx_CLK_DISABLE
#define AUDIO_IN_SAIx_CLK_DISABLE()
Definition: stm32f769i_discovery_audio.h:142
AUDIO_Drv_t::Play
int32_t(* Play)(void *)
Definition: stm32h747/stm32h747i-disco/CM7/Drivers/BSP/Components/Common/audio.h:66
BSP_AUDIO_OUT_Play
int32_t BSP_AUDIO_OUT_Play(uint32_t Instance, uint8_t *pData, uint32_t NbrOfBytes)
Default BSP AUDIO OUT Msp Callbacks.
Definition: stm32h747i_discovery_audio.c:602
AUDIO_OUT_SAIx_CLK_ENABLE
#define AUDIO_OUT_SAIx_CLK_ENABLE()
Definition: stm32f769i_discovery_audio.h:109
WM8994_Object_t
Definition: stm32h747/stm32h747i-disco/CM7/Drivers/BSP/Components/wm8994/wm8994.h:62
BSP_AUDIO_Init_t::ChannelsNbr
uint32_t ChannelsNbr
Definition: stm32h747i_discovery_audio.h:61
AUDIO_OUT_Ctx_t::Device
uint32_t Device
Definition: stm32h747i_discovery_audio.h:84
GPIO_AF6_SAI1
#define GPIO_AF6_SAI1
Definition: stm32h735/stm32h735g-dk/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_gpio_ex.h:169
DMA_InitTypeDef::Priority
uint32_t Priority
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:75
DMA_InitTypeDef::PeriphInc
uint32_t PeriphInc
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:58
SAI_InitTypeDef::AudioFrequency
uint32_t AudioFrequency
Definition: stm32f7xx_hal_sai.h:97
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
CODEC_MUTE_ON
#define CODEC_MUTE_ON
Definition: stm32h747i_discovery_audio.h:183
AUDIO_Drv_t::SetMute
int32_t(* SetMute)(void *, uint32_t)
Definition: stm32h747/stm32h747i-disco/CM7/Drivers/BSP/Components/Common/audio.h:74
BSP_ERROR_COMPONENT_FAILURE
#define BSP_ERROR_COMPONENT_FAILURE
Definition: stm32h747i_discovery_errno.h:35
BSP_AUDIO_OUT_DeInit
int32_t BSP_AUDIO_OUT_DeInit(uint32_t Instance)
De-initializes the audio out peripheral.
Definition: stm32h747i_discovery_audio.c:343
DMA_PDATAALIGN_HALFWORD
#define DMA_PDATAALIGN_HALFWORD
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:260
AUDIO_OUT_Ctx_t::Volume
uint32_t Volume
Definition: stm32h747i_discovery_audio.h:87
GPIO_InitTypeDef::Alternate
uint32_t Alternate
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:61
stm32h747i_discovery_bus.h
This file is the header of stm32h747i_discovery_bus.c file.
AUDIO_OUT_Ctx_t::IsMspCallbacksValid
uint32_t IsMspCallbacksValid
Definition: stm32h747i_discovery_audio.h:91
AUDIO_RESOLUTION_16B
#define AUDIO_RESOLUTION_16B
Definition: stm32h747i_discovery_audio.h:155
haudio_out_sai
SAI_HandleTypeDef haudio_out_sai
Definition: stm32h747i_discovery_audio.c:169
AUDIO_IN_DEVICE_ANALOG_MIC
#define AUDIO_IN_DEVICE_ANALOG_MIC
Definition: stm32h747i_discovery_audio.h:295
VOLUME_OUT_CONVERT
#define VOLUME_OUT_CONVERT(Volume)
Definition: stm32h747i_discovery_audio.h:318
HAL_SAI_DeInit
HAL_StatusTypeDef HAL_SAI_DeInit(SAI_HandleTypeDef *hsai)
AUDIO_OUT_SAIx_SCK_PIN
#define AUDIO_OUT_SAIx_SCK_PIN
Definition: stm32f769i_discovery_audio.h:119
BSP_AUDIO_OUT_IT_PRIORITY
#define BSP_AUDIO_OUT_IT_PRIORITY
Definition: stm32h747i_discovery_conf.h:62
__HAL_RCC_CRC_CLK_ENABLE
#define __HAL_RCC_CRC_CLK_ENABLE()
Definition: stm32f7xx_hal_rcc.h:409
GPIOE
#define GPIOE
Definition: stm32f407xx.h:1107
WM8994_IO_t::ReadReg
WM8994_ReadReg_Func ReadReg
Definition: stm32h747/stm32h747i-disco/CM7/Drivers/BSP/Components/wm8994/wm8994.h:57
BSP_AUDIO_IN_GetVolume
int32_t BSP_AUDIO_IN_GetVolume(uint32_t Instance, uint32_t *Volume)
Get the current audio in volume level.
Definition: stm32h747i_discovery_audio.c:2363
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
WM8994_IO_t::GetTick
WM8994_GetTick_Func GetTick
Definition: stm32h747/stm32h747i-disco/CM7/Drivers/BSP/Components/wm8994/wm8994.h:58
MX_SAI1_Block_B_Init
__weak HAL_StatusTypeDef MX_SAI1_Block_B_Init(SAI_HandleTypeDef *hsai, MX_SAI_Config_t *MXConfig)
Initializes the Audio Codec audio in instance (SAI).
Definition: stm32h747i_discovery_audio.c:1652
SAI_SYNCEXT_DISABLE
#define SAI_SYNCEXT_DISABLE
Definition: stm32f7xx_hal_sai.h:288
AUDIO_IN_INSTANCES_NBR
#define AUDIO_IN_INSTANCES_NBR
Definition: stm32h747i_discovery_audio.h:309
BSP_AUDIO_OUT_GetChannelsNbr
int32_t BSP_AUDIO_OUT_GetChannelsNbr(uint32_t Instance, uint32_t *ChannelNbr)
Get the audio Channels number.
Definition: stm32h747i_discovery_audio.c:1226
AUDIO_OUT_SAIx_DMAx_REQUEST
#define AUDIO_OUT_SAIx_DMAx_REQUEST
Definition: stm32h747i_discovery_audio.h:230
__HAL_RCC_GPIOE_CLK_ENABLE
#define __HAL_RCC_GPIOE_CLK_ENABLE()
Definition: stm32f7xx_hal_rcc_ex.h:661
BSP_AUDIO_IN_Pause
int32_t BSP_AUDIO_IN_Pause(uint32_t Instance)
Pause the audio file stream.
Definition: stm32h747i_discovery_audio.c:2001
RCC_PeriphCLKInitTypeDef::PLL2
RCC_PLL2InitTypeDef PLL2
Definition: stm32h735/stm32h735g-dk/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_rcc_ex.h:147
SAI_FS_CHANNEL_IDENTIFICATION
#define SAI_FS_CHANNEL_IDENTIFICATION
Definition: stm32f7xx_hal_sai.h:421
BSP_ERROR_NONE
#define BSP_ERROR_NONE
Definition: stm32h747i_discovery_errno.h:30
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
AUDIO_OUT_SAIx_SD_GPIO_PORT
#define AUDIO_OUT_SAIx_SD_GPIO_PORT
Definition: stm32h747i_discovery_audio.h:218
BSP_ERROR_UNKNOWN_COMPONENT
#define BSP_ERROR_UNKNOWN_COMPONENT
Definition: stm32h747i_discovery_errno.h:37
BSP_AUDIO_IN_Record
int32_t BSP_AUDIO_IN_Record(uint32_t Instance, uint8_t *pBuf, uint32_t NbrOfBytes)
Start audio recording.
Definition: stm32h747i_discovery_audio.c:1934
WM8994_OUT_NONE
#define WM8994_OUT_NONE
Definition: stm32h747/stm32h747i-disco/CM7/Drivers/BSP/Components/wm8994/wm8994.h:121
__DMA_HandleTypeDef::Init
DMA_InitTypeDef Init
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:143
AUDIO_IN_SAIx_AF
#define AUDIO_IN_SAIx_AF
Definition: stm32f769i_discovery_audio.h:143
BSP_AUDIO_OUT_SetVolume
int32_t BSP_AUDIO_OUT_SetVolume(uint32_t Instance, uint32_t Volume)
Controls the current audio volume level.
Definition: stm32h747i_discovery_audio.c:774
HAL_ERROR
@ HAL_ERROR
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:43
BSP_ERROR_BUSY
#define BSP_ERROR_BUSY
Definition: stm32h747i_discovery_errno.h:33
AUDIO_OUT_SAIx_MCLK_AF
#define AUDIO_OUT_SAIx_MCLK_AF
Definition: stm32h747i_discovery_audio.h:210
__SAI_HandleTypeDef::State
__IO HAL_SAI_StateTypeDef State
Definition: stm32f7xx_hal_sai.h:217
DMA_InitTypeDef::FIFOThreshold
uint32_t FIFOThreshold
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:83
HAL_SAI_STATE_READY
@ HAL_SAI_STATE_READY
Definition: stm32f7xx_hal_sai.h:51
AUDIO_OUT_STATE_RESET
#define AUDIO_OUT_STATE_RESET
Definition: stm32h747i_discovery_audio.h:171
RCC_PLL2InitTypeDef::PLL2M
uint32_t PLL2M
Definition: stm32h735/stm32h735g-dk/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_rcc_ex.h:50
DMA_CIRCULAR
#define DMA_CIRCULAR
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:282
AUDIO_IN_SAI_PDMx_DATA_IN_PORT
#define AUDIO_IN_SAI_PDMx_DATA_IN_PORT
Definition: stm32h747i_discovery_audio.h:278
SAI_SlotInitTypeDef::SlotNumber
uint32_t SlotNumber
Definition: stm32f7xx_hal_sai.h:177
BSP_AUDIO_IN_PDMToPCM_Init
int32_t BSP_AUDIO_IN_PDMToPCM_Init(uint32_t Instance, uint32_t AudioFreq, uint32_t ChnlNbrIn, uint32_t ChnlNbrOut)
Initialize the PDM library.
Definition: stm32h747i_discovery_audio.c:1866
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
AUDIO_IN_SAI_PDMx_DMAx_MEM_DATA_SIZE
#define AUDIO_IN_SAI_PDMx_DMAx_MEM_DATA_SIZE
Definition: stm32h747i_discovery_audio.h:289
SAI_InitTypeDef::MckOutput
uint32_t MckOutput
Definition: stm32h735/stm32h735g-dk/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_sai.h:95
BSP_AUDIO_IN_Error_CallBack
__weak void BSP_AUDIO_IN_Error_CallBack(uint32_t Instance)
Audio IN Error callback function.
Definition: stm32h747i_discovery_audio.c:2487
BSP_AUDIO_OUT_GetState
int32_t BSP_AUDIO_OUT_GetState(uint32_t Instance, uint32_t *State)
Get Audio Out state.
Definition: stm32h747i_discovery_audio.c:1250
__SAI_HandleTypeDef::hdmarx
DMA_HandleTypeDef * hdmarx
Definition: stm32f7xx_hal_sai.h:209
AUDIO_IN_Ctx_t::Volume
uint32_t Volume
Definition: stm32h747i_discovery_audio.h:75
SAI_SLOTACTIVE_0
#define SAI_SLOTACTIVE_0
Definition: stm32f7xx_hal_sai.h:458
BSP_AUDIO_IN_GetBitsPerSample
int32_t BSP_AUDIO_IN_GetBitsPerSample(uint32_t Instance, uint32_t *BitsPerSample)
Get Audio In Resolution.
Definition: stm32h747i_discovery_audio.c:2269
__SAI_HandleTypeDef::Instance
SAI_Block_TypeDef * Instance
Definition: stm32f7xx_hal_sai.h:193
AUDIO_IN_SAI_PDMx_CLK_IN_ENABLE
#define AUDIO_IN_SAI_PDMx_CLK_IN_ENABLE()
Definition: stm32h747i_discovery_audio.h:273
SAI_InitTypeDef::FIFOThreshold
uint32_t FIFOThreshold
Definition: stm32f7xx_hal_sai.h:94
MX_SAI_Config_t::DataSize
uint32_t DataSize
Definition: stm32h747i_discovery_audio.h:98
BSP_GetTick
int32_t BSP_GetTick(void)
Delay function.
Definition: stm32h747i_discovery_bus.c:483
AUDIO_OUT_STATE_STOP
#define AUDIO_OUT_STATE_STOP
Definition: stm32h747i_discovery_audio.h:173
ENABLE
@ ENABLE
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:194
__HAL_SAI_RESET_HANDLE_STATE
#define __HAL_SAI_RESET_HANDLE_STATE(__HANDLE__)
Reset SAI handle state.
Definition: stm32f7xx_hal_sai.h:592
AUDIO_OUT_DEVICE_HEADPHONE
#define AUDIO_OUT_DEVICE_HEADPHONE
Definition: stm32h747i_discovery_audio.h:161
DMA_MBURST_SINGLE
#define DMA_MBURST_SINGLE
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:326
BSP_AUDIO_OUT_IRQHandler
void BSP_AUDIO_OUT_IRQHandler(uint32_t Instance)
Definition: stm32h747i_discovery_audio.c:1268
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_CompObj
void * Audio_CompObj
Definition: stm32h747i_discovery_audio.c:167
SAI1_Block_A
#define SAI1_Block_A
Definition: stm32f469xx.h:1334
AUDIO_IN_SAIx_CLK_ENABLE
#define AUDIO_IN_SAIx_CLK_ENABLE()
Definition: stm32f769i_discovery_audio.h:141
BSP_AUDIO_IN_GetChannelsNbr
int32_t BSP_AUDIO_IN_GetChannelsNbr(uint32_t Instance, uint32_t *ChannelNbr)
Get Audio In Channel number.
Definition: stm32h747i_discovery_audio.c:2314
HAL_OK
@ HAL_OK
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:42
MX_SAI_Config_t
Definition: stm32h747i_discovery_audio.h:94
AUDIO_IN_SAI_PDMx_FS_SCK_AF
#define AUDIO_IN_SAI_PDMx_FS_SCK_AF
Definition: stm32h747i_discovery_audio.h:267
MX_SAI_Config_t::Synchro
uint32_t Synchro
Definition: stm32h747i_discovery_audio.h:101
DMA_PERIPH_TO_MEMORY
#define DMA_PERIPH_TO_MEMORY
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:228
RCC_SAI1CLKSOURCE_PLL2
#define RCC_SAI1CLKSOURCE_PLL2
Definition: stm32h735/stm32h735g-dk/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_rcc_ex.h:970
SAI_FrameInitTypeDef::FSOffset
uint32_t FSOffset
Definition: stm32f7xx_hal_sai.h:157
SAI_InitTypeDef::Synchro
uint32_t Synchro
Definition: stm32f7xx_hal_sai.h:71
SAI_SYNCHRONOUS
#define SAI_SYNCHRONOUS
Definition: stm32f7xx_hal_sai.h:392
haudio_in_sai
SAI_HandleTypeDef haudio_in_sai
Definition: stm32h747i_discovery_audio.c:171
AUDIO_IN_Ctx_t::IsMspCallbacksValid
uint32_t IsMspCallbacksValid
Definition: stm32h747i_discovery_audio.h:78
HAL_GPIO_Init
void HAL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init)
RCC_PLL2InitTypeDef::PLL2N
uint32_t PLL2N
Definition: stm32h735/stm32h735g-dk/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_rcc_ex.h:53
MX_SAI_Config_t::MonoStereoMode
uint32_t MonoStereoMode
Definition: stm32h747i_discovery_audio.h:99
UNUSED
#define UNUSED(x)
Definition: porcupine/demo/c/dr_libs/old/dr.h:92
BSP_AUDIO_OUT_SetDevice
int32_t BSP_AUDIO_OUT_SetDevice(uint32_t Instance, uint32_t Device)
Switch dynamically (while audio file is played) the output target (speaker or headphone).
Definition: stm32h747i_discovery_audio.c:917
SAI_DATASIZE_32
#define SAI_DATASIZE_32
Definition: stm32f7xx_hal_sai.h:365
GPIO_InitTypeDef::Mode
uint32_t Mode
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:52
BSP_I2C4_ReadReg16
int32_t BSP_I2C4_ReadReg16(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length)
Read a 16bit register of the device through BUS.
Definition: stm32h747i_discovery_bus.c:425
AUDIO_FREQUENCY_22K
#define AUDIO_FREQUENCY_22K
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/cs43l22/cs43l22.h:98
RCC_PLL2InitTypeDef::PLL2Q
uint32_t PLL2Q
Definition: stm32h735/stm32h735g-dk/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_rcc_ex.h:62
DMA_InitTypeDef::MemInc
uint32_t MemInc
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:61
BSP_AUDIO_IN_RecordPDM
int32_t BSP_AUDIO_IN_RecordPDM(uint32_t Instance, uint8_t *pBuf, uint32_t NbrOfBytes)
Start audio recording.
Definition: stm32h747i_discovery_audio.c:2082
AUDIO_IN_SAI_PDMx_SCK_PIN
#define AUDIO_IN_SAI_PDMx_SCK_PIN
Definition: stm32h747i_discovery_audio.h:271
AUDIO_IN_SAI_PDMx_DATA_IN_PIN
#define AUDIO_IN_SAI_PDMx_DATA_IN_PIN
Definition: stm32h747i_discovery_audio.h:277
BSP_AUDIO_IN_Resume
int32_t BSP_AUDIO_IN_Resume(uint32_t Instance)
Resume the audio file stream.
Definition: stm32h747i_discovery_audio.c:2040
MX_SAI_Config_t::ActiveFrameLength
uint32_t ActiveFrameLength
Definition: stm32h747i_discovery_audio.h:105
MX_SAI4_Block_A_Init
__weak HAL_StatusTypeDef MX_SAI4_Block_A_Init(SAI_HandleTypeDef *hsai, MX_SAI_Config_t *MXConfig)
Initializes the Audio Codec audio in instance (SAI).
Definition: stm32h747i_discovery_audio.c:1708
BSP_ERROR_BUS_FAILURE
#define BSP_ERROR_BUS_FAILURE
Definition: stm32h747i_discovery_errno.h:38
__SAI_HandleTypeDef::Init
SAI_InitTypeDef Init
Definition: stm32f7xx_hal_sai.h:195
SAI_MspInit
static void SAI_MspInit(SAI_HandleTypeDef *hsai)
Initialize BSP_AUDIO_OUT MSP.
Definition: stm32h747i_discovery_audio.c:2597
GPIO_InitTypeDef::Pull
uint32_t Pull
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:55
SAI_MONOMODE
#define SAI_MONOMODE
Definition: stm32f7xx_hal_sai.h:483
GPIO_PIN_6
#define GPIO_PIN_6
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:92
BSP_AUDIO_IN_Stop
int32_t BSP_AUDIO_IN_Stop(uint32_t Instance)
Stop audio recording.
Definition: stm32h747i_discovery_audio.c:1959
AUDIO_OUT_SAIx_FS_ENABLE
#define AUDIO_OUT_SAIx_FS_ENABLE()
Definition: stm32h747i_discovery_audio.h:222
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
GPIO_SPEED_FREQ_MEDIUM
#define GPIO_SPEED_FREQ_MEDIUM
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:143
BSP_AUDIO_MUTE_ENABLED
#define BSP_AUDIO_MUTE_ENABLED
Definition: stm32h747i_discovery_audio.h:168
AUDIO_Drv_t::Pause
int32_t(* Pause)(void *)
Definition: stm32h747/stm32h747i-disco/CM7/Drivers/BSP/Components/Common/audio.h:67
AUDIO_OUT_SAIx_DMAx_IRQ
#define AUDIO_OUT_SAIx_DMAx_IRQ
Definition: stm32f769i_discovery_audio.h:126
AUDIO_IN_STATE_PAUSE
#define AUDIO_IN_STATE_PAUSE
Definition: stm32h747i_discovery_audio.h:303
SAI_InitTypeDef::OutputDrive
uint32_t OutputDrive
Definition: stm32f7xx_hal_sai.h:80
DMA_InitTypeDef::PeriphBurst
uint32_t PeriphBurst
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:92
AUDIO_OUT_Ctx_t::ChannelsNbr
uint32_t ChannelsNbr
Definition: stm32h747i_discovery_audio.h:88
MX_SAI1_ClockConfig
__weak HAL_StatusTypeDef MX_SAI1_ClockConfig(SAI_HandleTypeDef *hsai, uint32_t SampleRate)
SAI clock Config.
Definition: stm32h747i_discovery_audio.c:444
Audio_Out_Ctx
AUDIO_OUT_Ctx_t Audio_Out_Ctx[AUDIO_OUT_INSTANCES_NBR]
Definition: stm32h747i_discovery_audio.c:174
AUDIO_FREQUENCY_44K
#define AUDIO_FREQUENCY_44K
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/cs43l22/cs43l22.h:96
AUDIO_OUT_SAIx_FS_GPIO_PORT
#define AUDIO_OUT_SAIx_FS_GPIO_PORT
Definition: stm32h747i_discovery_audio.h:223
MX_SAI_Config_t::AudioMode
uint32_t AudioMode
Definition: stm32h747i_discovery_audio.h:97
DMA_MDATAALIGN_HALFWORD
#define DMA_MDATAALIGN_HALFWORD
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:271
SAI_NOCOMPANDING
#define SAI_NOCOMPANDING
Definition: stm32f7xx_hal_sai.h:512
SAI_InitTypeDef::NoDivider
uint32_t NoDivider
Definition: stm32f7xx_hal_sai.h:85
PDM_FilterHandler
static PDM_Filter_Handler_t PDM_FilterHandler[2]
Definition: stm32h747i_discovery_audio.c:157
DMA_PRIORITY_HIGH
#define DMA_PRIORITY_HIGH
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:294
AUDIO_Drv_t::Resume
int32_t(* Resume)(void *)
Definition: stm32h747/stm32h747i-disco/CM7/Drivers/BSP/Components/Common/audio.h:68
__DMA_HandleTypeDef::Instance
DMA_Stream_TypeDef * Instance
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:141
AUDIO_OUT_STATE_PLAYING
#define AUDIO_OUT_STATE_PLAYING
Definition: stm32h747i_discovery_audio.h:172
AUDIO_OUT_SAIx_FS_AF
#define AUDIO_OUT_SAIx_FS_AF
Definition: stm32h747i_discovery_audio.h:225
RCC_PLL2InitTypeDef::PLL2P
uint32_t PLL2P
Definition: stm32h735/stm32h735g-dk/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_rcc_ex.h:58
WM8994_OK
#define WM8994_OK
Definition: stm32h747/stm32h747i-disco/CM7/Drivers/BSP/Components/wm8994/wm8994.h:106
HAL_SAI_DMAResume
HAL_StatusTypeDef HAL_SAI_DMAResume(SAI_HandleTypeDef *hsai)
MX_SAI_Config_t::SlotActive
uint32_t SlotActive
Definition: stm32h747i_discovery_audio.h:106
BSP_AUDIO_IN_SetVolume
int32_t BSP_AUDIO_IN_SetVolume(uint32_t Instance, uint32_t Volume)
Set the current audio in volume level.
Definition: stm32h747i_discovery_audio.c:2336
Audio_In_Ctx
AUDIO_IN_Ctx_t Audio_In_Ctx[AUDIO_IN_INSTANCES_NBR]
Definition: stm32h747i_discovery_audio.c:177
WM8994_IO_t::WriteReg
WM8994_WriteReg_Func WriteReg
Definition: stm32h747/stm32h747i-disco/CM7/Drivers/BSP/Components/wm8994/wm8994.h:56
HAL_SAI_RxHalfCpltCallback
void HAL_SAI_RxHalfCpltCallback(SAI_HandleTypeDef *hsai)
Half reception complete callback.
Definition: stm32h747i_discovery_audio.c:2423
VOLUME_IN_CONVERT
#define VOLUME_IN_CONVERT(Volume)
Definition: stm32f769/stm32f769i-disco/Drivers/BSP/Components/wm8994/wm8994.h:110
WM8994_IO_t::DeInit
WM8994_DeInit_Func DeInit
Definition: stm32h747/stm32h747i-disco/CM7/Drivers/BSP/Components/wm8994/wm8994.h:54
DMA_InitTypeDef::MemDataAlignment
uint32_t MemDataAlignment
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:67
SAI_PDM_CLOCK1_ENABLE
#define SAI_PDM_CLOCK1_ENABLE
Definition: stm32h735/stm32h735g-dk/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_sai.h:381
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
AUDIO_Drv_t::SetVolume
int32_t(* SetVolume)(void *, uint32_t, uint8_t)
Definition: stm32h747/stm32h747i-disco/CM7/Drivers/BSP/Components/Common/audio.h:72
AUDIO_IN_SAI_PDMx_CLK_IN_PIN
#define AUDIO_IN_SAI_PDMx_CLK_IN_PIN
Definition: stm32h747i_discovery_audio.h:274
HAL_GPIO_DeInit
void HAL_GPIO_DeInit(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin)
SAI_MASTERDIVIDER_DISABLE
#define SAI_MASTERDIVIDER_DISABLE
Definition: stm32f7xx_hal_sai.h:412
BSP_AUDIO_OUT_SetSampleRate
int32_t BSP_AUDIO_OUT_SetSampleRate(uint32_t Instance, uint32_t SampleRate)
Updates the audio frequency.
Definition: stm32h747i_discovery_audio.c:972
BSP_AUDIO_OUT_GetVolume
int32_t BSP_AUDIO_OUT_GetVolume(uint32_t Instance, uint32_t *Volume)
Get the current audio volume level.
Definition: stm32h747i_discovery_audio.c:812
WM8994_ReadID
int32_t WM8994_ReadID(WM8994_Object_t *pObj, uint32_t *Id)
Get the WM8994 ID.
Definition: stm32h747/stm32h747i-disco/CM7/Drivers/BSP/Components/wm8994/wm8994.c:623
WM8994_Init_t::OutputDevice
uint32_t OutputDevice
Definition: stm32h747/stm32h747i-disco/CM7/Drivers/BSP/Components/wm8994/wm8994.h:72
BSP_AUDIO_IN_DeInit
int32_t BSP_AUDIO_IN_DeInit(uint32_t Instance)
Deinit the audio IN peripherals.
Definition: stm32h747i_discovery_audio.c:1574
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
AUDIO_VOLUME_OUTPUT
#define AUDIO_VOLUME_OUTPUT
Definition: stm32h747i_discovery_audio.h:179
SAI_OUTPUTDRIVE_ENABLE
#define SAI_OUTPUTDRIVE_ENABLE
Definition: stm32f7xx_hal_sai.h:403
SAI_FS_FIRSTBIT
#define SAI_FS_FIRSTBIT
Definition: stm32f7xx_hal_sai.h:438
BSP_ERROR_CLOCK_FAILURE
#define BSP_ERROR_CLOCK_FAILURE
Definition: stm32h747i_discovery_errno.h:39
AUDIO_IN_Ctx_t::State
uint32_t State
Definition: stm32h747i_discovery_audio.h:76
GPIO_InitTypeDef::Speed
uint32_t Speed
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:58
WM8994_Init_t::Resolution
uint32_t Resolution
Definition: stm32h747/stm32h747i-disco/CM7/Drivers/BSP/Components/wm8994/wm8994.h:74
WM8994_IN_LINE1
#define WM8994_IN_LINE1
Definition: stm32h747/stm32h747i-disco/CM7/Drivers/BSP/Components/wm8994/wm8994.h:116
AUDIO_OUT_SAIx_MCLK_GPIO_PORT
#define AUDIO_OUT_SAIx_MCLK_GPIO_PORT
Definition: stm32f769i_discovery_audio.h:114
AUDIO_OUT_SAIx_SCK_ENABLE
#define AUDIO_OUT_SAIx_SCK_ENABLE()
Definition: stm32h747i_discovery_audio.h:212
PDM_FilterConfig
static PDM_Filter_Config_t PDM_FilterConfig[2]
Definition: stm32h747i_discovery_audio.c:158
MX_SAI_Config_t::AudioFrequency
uint32_t AudioFrequency
Definition: stm32h747i_discovery_audio.h:96
AUDIO_IN_SAIx_DMAx_MEM_DATA_SIZE
#define AUDIO_IN_SAIx_DMAx_MEM_DATA_SIZE
Definition: stm32f769i_discovery_audio.h:154
BSP_AUDIO_OUT_SetBitsPerSample
int32_t BSP_AUDIO_OUT_SetBitsPerSample(uint32_t Instance, uint32_t BitsPerSample)
Set the audio Resolution.
Definition: stm32h747i_discovery_audio.c:1064
SAI_InitTypeDef::TriState
uint32_t TriState
Definition: stm32f7xx_hal_sai.h:111
SAI_InitTypeDef::MckOverSampling
uint32_t MckOverSampling
Definition: stm32h735/stm32h735g-dk/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_sai.h:123
DMA_PBURST_SINGLE
#define DMA_PBURST_SINGLE
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:338
GPIO_PULLUP
#define GPIO_PULLUP
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:155
AUDIO_Drv_t::DeInit
int32_t(* DeInit)(void *)
Definition: stm32h747/stm32h747i-disco/CM7/Drivers/BSP/Components/Common/audio.h:64
BSP_AUDIO_IN_SetSampleRate
int32_t BSP_AUDIO_IN_SetSampleRate(uint32_t Instance, uint32_t SampleRate)
Set Audio In frequency.
Definition: stm32h747i_discovery_audio.c:2170
__HAL_SAI_DISABLE
#define __HAL_SAI_DISABLE(__HANDLE__)
Definition: stm32f7xx_hal_sai.h:658
MX_SAI_Config_t::OutputDrive
uint32_t OutputDrive
Definition: stm32h747i_discovery_audio.h:102
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
RCC_PLL2InitTypeDef::PLL2R
uint32_t PLL2R
Definition: stm32h735/stm32h735g-dk/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_rcc_ex.h:65
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
CODEC_AUDIOFRAME_SLOT_13
#define CODEC_AUDIOFRAME_SLOT_13
Definition: stm32469i_discovery_audio.h:109
AUDIO_OUT_Ctx_t::IsMute
uint32_t IsMute
Definition: stm32h747i_discovery_audio.h:89
BSP_AUDIO_OUT_UnMute
int32_t BSP_AUDIO_OUT_UnMute(uint32_t Instance)
Disables the MUTE mode.
Definition: stm32h747i_discovery_audio.c:863
WM8994_IN_NONE
#define WM8994_IN_NONE
Definition: stm32h747/stm32h747i-disco/CM7/Drivers/BSP/Components/wm8994/wm8994.h:113
BSP_AUDIO_IN_Init
int32_t BSP_AUDIO_IN_Init(uint32_t Instance, BSP_AUDIO_Init_t *AudioInit)
Initialize wave recording.
Definition: stm32h747i_discovery_audio.c:1374
BSP_I2C4_WriteReg16
int32_t BSP_I2C4_WriteReg16(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length)
Write a 16bit value in a register of the device through BUS.
Definition: stm32h747i_discovery_bus.c:388
AUDIO_IN_SAI_PDMx_DMAx_STREAM
#define AUDIO_IN_SAI_PDMx_DMAx_STREAM
Definition: stm32h747i_discovery_audio.h:285
SAI_SlotInitTypeDef::SlotSize
uint32_t SlotSize
Definition: stm32f7xx_hal_sai.h:174
DMA_MINC_ENABLE
#define DMA_MINC_ENABLE
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:249
AUDIO_Drv_t::Stop
int32_t(* Stop)(void *, uint32_t)
Definition: stm32h747/stm32h747i-disco/CM7/Drivers/BSP/Components/Common/audio.h:69
AUDIO_OUT_SAIx_SD_ENABLE
#define AUDIO_OUT_SAIx_SD_ENABLE()
Definition: stm32h747i_discovery_audio.h:217
BSP_AUDIO_IN_IT_PRIORITY
#define BSP_AUDIO_IN_IT_PRIORITY
Definition: stm32h747i_discovery_conf.h:63
WM8994_Driver
WM8994_Drv_t WM8994_Driver
Definition: stm32h747/stm32h747i-disco/CM7/Drivers/BSP/Components/wm8994/wm8994.c:41
MX_SAI_Config_t::SynchroExt
uint32_t SynchroExt
Definition: stm32h747i_discovery_audio.h:103
AUDIO_IN_SAIx_DMAx_PERIPH_DATA_SIZE
#define AUDIO_IN_SAIx_DMAx_PERIPH_DATA_SIZE
Definition: stm32f769i_discovery_audio.h:153
SAI_SlotInitTypeDef::SlotActive
uint32_t SlotActive
Definition: stm32f7xx_hal_sai.h:180
SAI_PdmInitTypeDef::Activation
FunctionalState Activation
Definition: stm32h735/stm32h735g-dk/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_sai.h:67
BSP_AUDIO_OUT_GetDevice
int32_t BSP_AUDIO_OUT_GetDevice(uint32_t Instance, uint32_t *Device)
Get the Output Device.
Definition: stm32h747i_discovery_audio.c:947
__HAL_SAI_ENABLE
#define __HAL_SAI_ENABLE(__HANDLE__)
Definition: stm32f7xx_hal_sai.h:657
SAI_FIRSTBIT_MSB
#define SAI_FIRSTBIT_MSB
Definition: stm32f7xx_hal_sai.h:373
HAL_SAI_TxCpltCallback
void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai)
Tx Transfer completed callbacks.
Definition: stm32h747i_discovery_audio.c:1282
WM8994_IO_t::Init
WM8994_Init_Func Init
Definition: stm32h747/stm32h747i-disco/CM7/Drivers/BSP/Components/wm8994/wm8994.h:53
SAI_SlotInitTypeDef::FirstBitOffset
uint32_t FirstBitOffset
Definition: stm32f7xx_hal_sai.h:171
BSP_AUDIO_OUT_HalfTransfer_CallBack
__weak void BSP_AUDIO_OUT_HalfTransfer_CallBack(uint32_t Instance)
Manages the DMA Half Transfer complete event.
Definition: stm32h747i_discovery_audio.c:1342
BSP_AUDIO_OUT_Resume
int32_t BSP_AUDIO_OUT_Resume(uint32_t Instance)
Resumes the audio file stream.
Definition: stm32h747i_discovery_audio.c:690
DMA_InitTypeDef::MemBurst
uint32_t MemBurst
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:86
AUDIO_Drv_t::Init
int32_t(* Init)(void *, void *)
Definition: stm32h747/stm32h747i-disco/CM7/Drivers/BSP/Components/Common/audio.h:63
HAL_SAI_Receive_DMA
HAL_StatusTypeDef HAL_SAI_Receive_DMA(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size)
BSP_AUDIO_OUT_SetChannelsNbr
int32_t BSP_AUDIO_OUT_SetChannelsNbr(uint32_t Instance, uint32_t ChannelNbr)
Set the audio Channels number.
Definition: stm32h747i_discovery_audio.c:1170
AUDIO_OUT_Ctx_t::Instance
uint32_t Instance
Definition: stm32h747i_discovery_audio.h:83
BSP_I2C4_DeInit
int32_t BSP_I2C4_DeInit(void)
DeInitializes I2C HAL.
Definition: stm32h747i_discovery_bus.c:241
BSP_AUDIO_IN_TransferComplete_CallBack
__weak void BSP_AUDIO_IN_TransferComplete_CallBack(uint32_t Instance)
User callback when record buffer is filled.
Definition: stm32h747i_discovery_audio.c:2459
DMA_FIFOMODE_ENABLE
#define DMA_FIFOMODE_ENABLE
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:305
AUDIO_OUT_STATE_PAUSE
#define AUDIO_OUT_STATE_PAUSE
Definition: stm32h747i_discovery_audio.h:174
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
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
BSP_AUDIO_Init_t::Volume
uint32_t Volume
Definition: stm32h747i_discovery_audio.h:62
SAI_MCK_OVERSAMPLING_DISABLE
#define SAI_MCK_OVERSAMPLING_DISABLE
Definition: stm32h735/stm32h735g-dk/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_sai.h:372
BSP_ERROR_NO_INIT
#define BSP_ERROR_NO_INIT
Definition: stm32h747i_discovery_errno.h:31
AUDIO_IN_Ctx_t::Device
uint32_t Device
Definition: stm32h747i_discovery_audio.h:68
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
BSP_AUDIO_OUT_GetBitsPerSample
int32_t BSP_AUDIO_OUT_GetBitsPerSample(uint32_t Instance, uint32_t *BitsPerSample)
Get the audio Resolution.
Definition: stm32h747i_discovery_audio.c:1146
AUDIO_IN_Ctx_t::BitsPerSample
uint32_t BitsPerSample
Definition: stm32h747i_discovery_audio.h:70
AUDIO_IN_Ctx_t::SampleRate
uint32_t SampleRate
Definition: stm32h747i_discovery_audio.h:69
SAI_FrameInitTypeDef::FSPolarity
uint32_t FSPolarity
Definition: stm32f7xx_hal_sai.h:154
HAL_SAI_ErrorCallback
void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai)
SAI error callbacks.
Definition: stm32h747i_discovery_audio.c:1312
BSP_AUDIO_OUT_Stop
int32_t BSP_AUDIO_OUT_Stop(uint32_t Instance)
Stops audio playing and Power down the Audio Codec.
Definition: stm32h747i_discovery_audio.c:729
AUDIO_IN_SAI_PDMx_DATA_IN_ENABLE
#define AUDIO_IN_SAI_PDMx_DATA_IN_ENABLE()
Definition: stm32h747i_discovery_audio.h:276
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)
BSP_I2C4_Init
int32_t BSP_I2C4_Init(void)
Initializes I2C HAL.
Definition: stm32h747i_discovery_bus.c:190
CODEC_AUDIOFRAME_SLOT_02
#define CODEC_AUDIOFRAME_SLOT_02
Definition: stm32469i_discovery_audio.h:107
AUDIO_IN_STATE_RESET
#define AUDIO_IN_STATE_RESET
Definition: stm32h747i_discovery_audio.h:300
HAL_DMA_Init
HAL_StatusTypeDef HAL_DMA_Init(DMA_HandleTypeDef *hdma)
SAI_PdmInitTypeDef::ClockEnable
uint32_t ClockEnable
Definition: stm32h735/stm32h735g-dk/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_sai.h:70
AUDIO_IN_SAIx_SD_PIN
#define AUDIO_IN_SAIx_SD_PIN
Definition: stm32f769i_discovery_audio.h:146
AUDIO_VOLUME_INPUT
#define AUDIO_VOLUME_INPUT
Definition: stm32h747i_discovery_audio.h:178
BSP_AUDIO_IN_GetState
int32_t BSP_AUDIO_IN_GetState(uint32_t Instance, uint32_t *State)
Get Audio In device.
Definition: stm32h747i_discovery_audio.c:2385
SAI_OUTPUT_NOTRELEASED
#define SAI_OUTPUT_NOTRELEASED
Definition: stm32f7xx_hal_sai.h:491
CODEC_PDWN_SW
#define CODEC_PDWN_SW
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/cs43l22/cs43l22.h:86
__HAL_RCC_GPIOG_CLK_ENABLE
#define __HAL_RCC_GPIOG_CLK_ENABLE()
Definition: stm32f7xx_hal_rcc_ex.h:677
RCC_PeriphCLKInitTypeDef::Sai1ClockSelection
uint32_t Sai1ClockSelection
Definition: stm32f7xx_hal_rcc_ex.h:157
BSP_AUDIO_IN_GetSampleRate
int32_t BSP_AUDIO_IN_GetSampleRate(uint32_t Instance, uint32_t *SampleRate)
Get Audio In frequency.
Definition: stm32h747i_discovery_audio.c:2207
BSP_AUDIO_OUT_Pause
int32_t BSP_AUDIO_OUT_Pause(uint32_t Instance)
This function Pauses the audio file stream. In case of using DMA, the DMA Pause feature is used.
Definition: stm32h747i_discovery_audio.c:647
BSP_AUDIO_Init_t::BitsPerSample
uint32_t BitsPerSample
Definition: stm32h747i_discovery_audio.h:60
DMA_InitTypeDef::Direction
uint32_t Direction
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:54
AUDIO_IN_SAI_PDMx_CLK_ENABLE
#define AUDIO_IN_SAI_PDMx_CLK_ENABLE()
Definition: stm32h747i_discovery_audio.h:265
BSP_AUDIO_IN_IRQHandler
void BSP_AUDIO_IN_IRQHandler(uint32_t Instance, uint32_t InputDevice)
This function handles Audio Out DMA interrupt requests.
Definition: stm32h747i_discovery_audio.c:2409
HAL_DMA_DeInit
HAL_StatusTypeDef HAL_DMA_DeInit(DMA_HandleTypeDef *hdma)
WM8994_Init_t::Volume
uint32_t Volume
Definition: stm32h747/stm32h747i-disco/CM7/Drivers/BSP/Components/wm8994/wm8994.h:75
BSP_AUDIO_OUT_Error_CallBack
__weak void BSP_AUDIO_OUT_Error_CallBack(uint32_t Instance)
Manages the DMA FIFO error event.
Definition: stm32h747i_discovery_audio.c:1353
AUDIO_OUT_SAIx_SCK_GPIO_PORT
#define AUDIO_OUT_SAIx_SCK_GPIO_PORT
Definition: stm32h747i_discovery_audio.h:213
SAI_FIRSTBIT_LSB
#define SAI_FIRSTBIT_LSB
Definition: stm32f7xx_hal_sai.h:374
BSP_AUDIO_IN_SetBitsPerSample
int32_t BSP_AUDIO_IN_SetBitsPerSample(uint32_t Instance, uint32_t BitsPerSample)
Set Audio In Resolution.
Definition: stm32h747i_discovery_audio.c:2231
BSP_AUDIO_OUT_IsMute
int32_t BSP_AUDIO_OUT_IsMute(uint32_t Instance, uint32_t *IsMute)
Check whether the MUTE mode is enabled or not.
Definition: stm32h747i_discovery_audio.c:894
GPIOG
#define GPIOG
Definition: stm32f407xx.h:1109
SAI_MCK_OUTPUT_DISABLE
#define SAI_MCK_OUTPUT_DISABLE
Definition: stm32h735/stm32h735g-dk/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_sai.h:323
SAI_FS_ACTIVE_LOW
#define SAI_FS_ACTIVE_LOW
Definition: stm32f7xx_hal_sai.h:429
MX_SAI4_ClockConfig
__weak HAL_StatusTypeDef MX_SAI4_ClockConfig(SAI_HandleTypeDef *hsai, uint32_t SampleRate)
SAI clock Config.
Definition: stm32h747i_discovery_audio.c:485
CODEC_AUDIOFRAME_SLOT_0123
#define CODEC_AUDIOFRAME_SLOT_0123
Definition: stm32469i_discovery_audio.h:105
SAI_ASYNCHRONOUS
#define SAI_ASYNCHRONOUS
Definition: stm32f7xx_hal_sai.h:391
HAL_SAI_Init
HAL_StatusTypeDef HAL_SAI_Init(SAI_HandleTypeDef *hsai)
AUDIO_Drv_t
Definition: stm32h747/stm32h747i-disco/CM7/Drivers/BSP/Components/Common/audio.h:61
BSP_AUDIO_MUTE_DISABLED
#define BSP_AUDIO_MUTE_DISABLED
Definition: stm32h747i_discovery_audio.h:167
AUDIO_OUT_Ctx_t::SampleRate
uint32_t SampleRate
Definition: stm32h747i_discovery_audio.h:85
AUDIO_IN_Ctx_t::ChannelsNbr
uint32_t ChannelsNbr
Definition: stm32h747i_discovery_audio.h:71
HAL_NVIC_SetPriority
void HAL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority)
AUDIO_OUT_Ctx_t::BitsPerSample
uint32_t BitsPerSample
Definition: stm32h747i_discovery_audio.h:86
MX_SAI1_Block_A_Init
__weak HAL_StatusTypeDef MX_SAI1_Block_A_Init(SAI_HandleTypeDef *hsai, MX_SAI_Config_t *MXConfig)
Initializes the Audio Codec audio out instance (SAI).
Definition: stm32h747i_discovery_audio.c:384
AUDIO_IN_SAI_PDMx_DMAx_REQUEST
#define AUDIO_IN_SAI_PDMx_DMAx_REQUEST
Definition: stm32h747i_discovery_audio.h:286
RCC_PeriphCLKInitTypeDef
RCC extended clocks structure definition.
Definition: stm32f7xx_hal_rcc_ex.h:126
HAL_SAI_RxCpltCallback
void HAL_SAI_RxCpltCallback(SAI_HandleTypeDef *hsai)
Reception complete callback.
Definition: stm32h747i_discovery_audio.c:2441
Audio_Drv
static AUDIO_Drv_t * Audio_Drv
Definition: stm32h747i_discovery_audio.c:154
AUDIO_OUT_SAIx_MCLK_PIN
#define AUDIO_OUT_SAIx_MCLK_PIN
Definition: stm32f769i_discovery_audio.h:115
AUDIO_IN_DEVICE_DIGITAL_MIC
#define AUDIO_IN_DEVICE_DIGITAL_MIC
Definition: stm32h747i_discovery_audio.h:297
BSP_AUDIO_IN_GetDevice
int32_t BSP_AUDIO_IN_GetDevice(uint32_t Instance, uint32_t *Device)
Get Audio In device.
Definition: stm32h747i_discovery_audio.c:2148
AUDIO_IN_STATE_STOP
#define AUDIO_IN_STATE_STOP
Definition: stm32h747i_discovery_audio.h:302
BSP_AUDIO_Init_t::Device
uint32_t Device
Definition: stm32h747i_discovery_audio.h:58
WM8994_RegisterBusIO
int32_t WM8994_RegisterBusIO(WM8994_Object_t *pObj, WM8994_IO_t *pIO)
Function.
Definition: stm32h747/stm32h747i-disco/CM7/Drivers/BSP/Components/wm8994/wm8994.c:1327
AUDIO_IN_SAI_PDMx_FS_PIN
#define AUDIO_IN_SAI_PDMx_FS_PIN
Definition: stm32h747i_discovery_audio.h:270
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
AUDIO_OUT_SAIx_SCK_AF
#define AUDIO_OUT_SAIx_SCK_AF
Definition: stm32h747i_discovery_audio.h:215
BSP_ERROR_WRONG_PARAM
#define BSP_ERROR_WRONG_PARAM
Definition: stm32h747i_discovery_errno.h:32
AUDIO_RESOLUTION_32B
#define AUDIO_RESOLUTION_32B
Definition: stm32h747i_discovery_audio.h:156
SAI_STEREOMODE
#define SAI_STEREOMODE
Definition: stm32f7xx_hal_sai.h:482
AUDIO_OUT_SAIx_CLK_DISABLE
#define AUDIO_OUT_SAIx_CLK_DISABLE()
Definition: stm32f769i_discovery_audio.h:110
SAI_CLOCKSTROBING_RISINGEDGE
#define SAI_CLOCKSTROBING_RISINGEDGE
Definition: stm32f7xx_hal_sai.h:383
GPIO_PIN_7
#define GPIO_PIN_7
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:93
GPIO_PIN_5
#define GPIO_PIN_5
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:91
SAI_FrameInitTypeDef::FrameLength
uint32_t FrameLength
Definition: stm32f7xx_hal_sai.h:140
SAI1_Block_B
#define SAI1_Block_B
Definition: stm32f469xx.h:1335
GPIO_PIN_4
#define GPIO_PIN_4
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:90
HAL_SAI_STATE_RESET
@ HAL_SAI_STATE_RESET
Definition: stm32f7xx_hal_sai.h:50
AUDIO_OUT_SAIx_SD_AF
#define AUDIO_OUT_SAIx_SD_AF
Definition: stm32h747i_discovery_audio.h:220
BSP_AUDIO_IN_HalfTransfer_CallBack
__weak void BSP_AUDIO_IN_HalfTransfer_CallBack(uint32_t Instance)
Manages the DMA Half Transfer complete event.
Definition: stm32h747i_discovery_audio.c:2473
DMA_FIFO_THRESHOLD_FULL
#define DMA_FIFO_THRESHOLD_FULL
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:317
__HAL_RCC_SAI1_CLK_ENABLE
#define __HAL_RCC_SAI1_CLK_ENABLE()
Definition: stm32f7xx_hal_rcc_ex.h:1339
SAI_FS_ACTIVE_HIGH
#define SAI_FS_ACTIVE_HIGH
Definition: stm32f7xx_hal_sai.h:430
__SAI_HandleTypeDef::SlotInit
SAI_SlotInitTypeDef SlotInit
Definition: stm32f7xx_hal_sai.h:199
BSP_AUDIO_IN_PDMToPCM
int32_t BSP_AUDIO_IN_PDMToPCM(uint32_t Instance, uint16_t *PDMBuf, uint16_t *PCMBuf)
Converts audio format from PDM to PCM.
Definition: stm32h747i_discovery_audio.c:1908
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
__HAL_RCC_BDMA_CLK_ENABLE
#define __HAL_RCC_BDMA_CLK_ENABLE()
Definition: stm32h735/stm32h735g-dk/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_rcc.h:1536
AUDIO_OUT_Ctx_t::State
uint32_t State
Definition: stm32h747i_discovery_audio.h:90
BSP_ERROR_PERIPH_FAILURE
#define BSP_ERROR_PERIPH_FAILURE
Definition: stm32h747i_discovery_errno.h:34
AUDIO_OUT_INSTANCES_NBR
#define AUDIO_OUT_INSTANCES_NBR
Definition: stm32h747i_discovery_audio.h:139
AUDIO_OUT_SAIx_DMAx_STREAM
#define AUDIO_OUT_SAIx_DMAx_STREAM
Definition: stm32f769i_discovery_audio.h:124
AUDIO_IN_SAI_PDMx_FS_SCK_ENABLE
#define AUDIO_IN_SAI_PDMx_FS_SCK_ENABLE()
Definition: stm32h747i_discovery_audio.h:268
AUDIO_IN_SAI_PDMx
#define AUDIO_IN_SAI_PDMx
Definition: stm32h747i_discovery_audio.h:264
SAI_FS_BEFOREFIRSTBIT
#define SAI_FS_BEFOREFIRSTBIT
Definition: stm32f7xx_hal_sai.h:439
AUDIO_IN_SAI_PDMx_DMAx_PERIPH_DATA_SIZE
#define AUDIO_IN_SAI_PDMx_DMAx_PERIPH_DATA_SIZE
Definition: stm32h747i_discovery_audio.h:288
AUDIO_IN_SAIx_SD_GPIO_PORT
#define AUDIO_IN_SAIx_SD_GPIO_PORT
Definition: stm32f769i_discovery_audio.h:145
WM8994_Init_t
Definition: stm32h747/stm32h747i-disco/CM7/Drivers/BSP/Components/wm8994/wm8994.h:69
AUDIO_IN_Ctx_t
Definition: stm32h747i_discovery_audio.h:65
SAI_InitTypeDef::FirstBit
uint32_t FirstBit
Definition: stm32f7xx_hal_sai.h:123
WM8994_Init_t::Frequency
uint32_t Frequency
Definition: stm32h747/stm32h747i-disco/CM7/Drivers/BSP/Components/wm8994/wm8994.h:73
HAL_RCCEx_GetPeriphCLKConfig
void HAL_RCCEx_GetPeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit)
HAL_DMA_IRQHandler
void HAL_DMA_IRQHandler(DMA_HandleTypeDef *hdma)
HAL_SAI_Transmit_DMA
HAL_StatusTypeDef HAL_SAI_Transmit_DMA(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size)
AUDIO_IN_SAIx_DMAx_REQUEST
#define AUDIO_IN_SAIx_DMAx_REQUEST
Definition: stm32h747i_discovery_audio.h:251
DMA_InitTypeDef::Request
uint32_t Request
Definition: stm32h735/stm32h735g-dk/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_dma.h:51
AUDIO_IN_SAI_PDMx_FS_SCK_GPIO_PORT
#define AUDIO_IN_SAI_PDMx_FS_SCK_GPIO_PORT
Definition: stm32h747i_discovery_audio.h:269
DMA_MDATAALIGN_WORD
#define DMA_MDATAALIGN_WORD
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:272
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
BSP_ERROR_FEATURE_NOT_SUPPORTED
#define BSP_ERROR_FEATURE_NOT_SUPPORTED
Definition: stm32h747i_discovery_errno.h:41
AUDIO_IN_SAI_PDMx_DMAx_IRQ
#define AUDIO_IN_SAI_PDMx_DMAx_IRQ
Definition: stm32h747i_discovery_audio.h:287
stm32h747i_discovery_audio.h
This file contains the common defines and functions prototypes for the stm32h747i_discovery_audio....
SAI_PdmInitTypeDef::MicPairsNbr
uint32_t MicPairsNbr
Definition: stm32h735/stm32h735g-dk/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_sai.h:68
SAI_InitTypeDef::PdmInit
SAI_PdmInitTypeDef PdmInit
Definition: stm32h735/stm32h735g-dk/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_sai.h:135


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