stm32f7xx_hal_sai.c
Go to the documentation of this file.
1 
207 /* Includes ------------------------------------------------------------------*/
208 #include "stm32f7xx_hal.h"
209 
219 #ifdef HAL_SAI_MODULE_ENABLED
220 
221 /* Private typedef -----------------------------------------------------------*/
225 typedef enum {
226  SAI_MODE_DMA,
227  SAI_MODE_IT
228 }SAI_ModeTypedef;
233 /* Private define ------------------------------------------------------------*/
234 
238 #define SAI_DEFAULT_TIMEOUT 4 /* 4ms */
239 
243 /* Private macro -------------------------------------------------------------*/
244 /* Private variables ---------------------------------------------------------*/
245 /* Private function prototypes -----------------------------------------------*/
246 
250 static void SAI_FillFifo(SAI_HandleTypeDef *hsai);
251 static uint32_t SAI_InterruptFlag(SAI_HandleTypeDef *hsai, uint32_t mode);
252 static HAL_StatusTypeDef SAI_InitI2S(SAI_HandleTypeDef *hsai, uint32_t protocol, uint32_t datasize, uint32_t nbslot);
253 static HAL_StatusTypeDef SAI_InitPCM(SAI_HandleTypeDef *hsai, uint32_t protocol, uint32_t datasize, uint32_t nbslot);
254 
255 static HAL_StatusTypeDef SAI_Disable(SAI_HandleTypeDef *hsai);
256 static void SAI_Transmit_IT8Bit(SAI_HandleTypeDef *hsai);
257 static void SAI_Transmit_IT16Bit(SAI_HandleTypeDef *hsai);
258 static void SAI_Transmit_IT32Bit(SAI_HandleTypeDef *hsai);
259 static void SAI_Receive_IT8Bit(SAI_HandleTypeDef *hsai);
260 static void SAI_Receive_IT16Bit(SAI_HandleTypeDef *hsai);
261 static void SAI_Receive_IT32Bit(SAI_HandleTypeDef *hsai);
262 
263 static void SAI_DMATxCplt(DMA_HandleTypeDef *hdma);
264 static void SAI_DMATxHalfCplt(DMA_HandleTypeDef *hdma);
265 static void SAI_DMARxCplt(DMA_HandleTypeDef *hdma);
266 static void SAI_DMARxHalfCplt(DMA_HandleTypeDef *hdma);
267 static void SAI_DMAError(DMA_HandleTypeDef *hdma);
268 static void SAI_DMAAbort(DMA_HandleTypeDef *hdma);
273 /* Exported functions ---------------------------------------------------------*/
274 
322 HAL_StatusTypeDef HAL_SAI_InitProtocol(SAI_HandleTypeDef *hsai, uint32_t protocol, uint32_t datasize, uint32_t nbslot)
323 {
324  HAL_StatusTypeDef status = HAL_OK;
325 
326  /* Check the parameters */
329 
330  switch(protocol)
331  {
332  case SAI_I2S_STANDARD :
333  case SAI_I2S_MSBJUSTIFIED :
334  case SAI_I2S_LSBJUSTIFIED :
335  status = SAI_InitI2S(hsai, protocol, datasize, nbslot);
336  break;
337  case SAI_PCM_LONG :
338  case SAI_PCM_SHORT :
339  status = SAI_InitPCM(hsai, protocol, datasize, nbslot);
340  break;
341  default :
342  status = HAL_ERROR;
343  break;
344  }
345 
346  if(status == HAL_OK)
347  {
348  status = HAL_SAI_Init(hsai);
349  }
350 
351  return status;
352 }
353 
362 {
363  uint32_t tmpregisterGCR = 0;
364  uint32_t ckstr_bits = 0;
365  uint32_t syncen_bits = 0;
366 
367  /* Check the SAI handle allocation */
368  if(hsai == NULL)
369  {
370  return HAL_ERROR;
371  }
372 
373  /* check the instance */
375 
376  /* Check the SAI Block parameters */
391 
392  /* Check the SAI Block Frame parameters */
398 
399  /* Check the SAI Block Slot parameters */
404 
405  if(hsai->State == HAL_SAI_STATE_RESET)
406  {
407  /* Allocate lock resource and initialize it */
408  hsai->Lock = HAL_UNLOCKED;
409 
410 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
411  /* Reset callback pointers to the weak predefined callbacks */
412  hsai->RxCpltCallback = HAL_SAI_RxCpltCallback;
413  hsai->RxHalfCpltCallback = HAL_SAI_RxHalfCpltCallback;
414  hsai->TxCpltCallback = HAL_SAI_TxCpltCallback;
415  hsai->TxHalfCpltCallback = HAL_SAI_TxHalfCpltCallback;
416  hsai->ErrorCallback = HAL_SAI_ErrorCallback;
417 
418  /* Init the low level hardware : GPIO, CLOCK, NVIC and DMA */
419  if (hsai->MspInitCallback == NULL)
420  {
421  hsai->MspInitCallback = HAL_SAI_MspInit;
422  }
423  hsai->MspInitCallback(hsai);
424 #else
425  /* Init the low level hardware : GPIO, CLOCK, NVIC and DMA */
426  HAL_SAI_MspInit(hsai);
427 #endif /* USE_HAL_SAI_REGISTER_CALLBACKS */
428  }
429 
430  hsai->State = HAL_SAI_STATE_BUSY;
431 
432  /* Disable the selected SAI peripheral */
433  SAI_Disable(hsai);
434 
435  /* SAI Block Synchro Configuration -----------------------------------------*/
436  /* This setting must be done with both audio block (A & B) disabled */
437  switch(hsai->Init.SynchroExt)
438  {
439  case SAI_SYNCEXT_DISABLE :
440  tmpregisterGCR = 0;
441  break;
443  tmpregisterGCR = SAI_GCR_SYNCOUT_0;
444  break;
446  tmpregisterGCR = SAI_GCR_SYNCOUT_1;
447  break;
448  default:
449  break;
450  }
451 
452  switch(hsai->Init.Synchro)
453  {
454  case SAI_ASYNCHRONOUS :
455  {
456  syncen_bits = 0;
457  }
458  break;
459  case SAI_SYNCHRONOUS :
460  {
461  syncen_bits = SAI_xCR1_SYNCEN_0;
462  }
463  break;
465  {
466  syncen_bits = SAI_xCR1_SYNCEN_1;
467  }
468  break;
470  {
471  syncen_bits = SAI_xCR1_SYNCEN_1;
472  tmpregisterGCR |= SAI_GCR_SYNCIN_0;
473  }
474  break;
475  default:
476  break;
477  }
478 
479  if((hsai->Instance == SAI1_Block_A) || (hsai->Instance == SAI1_Block_B))
480  {
481  SAI1->GCR = tmpregisterGCR;
482  }
483  else
484  {
485  SAI2->GCR = tmpregisterGCR;
486  }
487 
489  {
490  uint32_t freq = 0;
491  uint32_t tmpval;
492 
493  if((hsai->Instance == SAI1_Block_A ) || (hsai->Instance == SAI1_Block_B ))
494  {
496  }
497  if((hsai->Instance == SAI2_Block_A ) || (hsai->Instance == SAI2_Block_B ))
498  {
500  }
501 
502  /* Configure Master Clock using the following formula :
503  MCLK_x = SAI_CK_x / (MCKDIV[3:0] * 2) with MCLK_x = 256 * FS
504  FS = SAI_CK_x / (MCKDIV[3:0] * 2) * 256
505  MCKDIV[3:0] = SAI_CK_x / FS * 512 */
506  /* (freq x 10) to keep Significant digits */
507  tmpval = (freq * 10) / (hsai->Init.AudioFrequency * 2 * 256);
508  hsai->Init.Mckdiv = tmpval / 10;
509 
510  /* Round result to the nearest integer */
511  if((tmpval % 10) > 8)
512  {
513  hsai->Init.Mckdiv+= 1;
514  }
515  }
516  /* Check the SAI Block master clock divider parameter */
518 
519  /* Compute CKSTR bits of SAI CR1 according ClockStrobing and AudioMode */
520  if((hsai->Init.AudioMode == SAI_MODEMASTER_TX) || (hsai->Init.AudioMode == SAI_MODESLAVE_TX))
521  { /* Transmit */
522  ckstr_bits = (hsai->Init.ClockStrobing == SAI_CLOCKSTROBING_RISINGEDGE) ? 0 : SAI_xCR1_CKSTR;
523  }
524  else
525  { /* Receive */
526  ckstr_bits = (hsai->Init.ClockStrobing == SAI_CLOCKSTROBING_RISINGEDGE) ? SAI_xCR1_CKSTR : 0;
527  }
528 
529  /* SAI Block Configuration -------------------------------------------------*/
530  /* SAI CR1 Configuration */
532  SAI_xCR1_LSBFIRST | SAI_xCR1_CKSTR | SAI_xCR1_SYNCEN |\
533  SAI_xCR1_MONO | SAI_xCR1_OUTDRIV | SAI_xCR1_DMAEN | \
534  SAI_xCR1_NODIV | SAI_xCR1_MCKDIV);
535 
536  hsai->Instance->CR1|=(hsai->Init.AudioMode | hsai->Init.Protocol | \
537  hsai->Init.DataSize | hsai->Init.FirstBit | \
538  ckstr_bits | syncen_bits | \
539  hsai->Init.MonoStereoMode | hsai->Init.OutputDrive | \
540  hsai->Init.NoDivider | (hsai->Init.Mckdiv << 20));
541 
542  /* SAI CR2 Configuration */
544  hsai->Instance->CR2|= (hsai->Init.FIFOThreshold | hsai->Init.CompandingMode | hsai->Init.TriState);
545 
546  /* SAI Frame Configuration -----------------------------------------*/
548  SAI_xFRCR_FSPOL | SAI_xFRCR_FSOFF));
549  hsai->Instance->FRCR|=((hsai->FrameInit.FrameLength - 1) |
550  hsai->FrameInit.FSOffset |
551  hsai->FrameInit.FSDefinition |
552  hsai->FrameInit.FSPolarity |
553  ((hsai->FrameInit.ActiveFrameLength - 1) << 8));
554 
555  /* SAI Block_x SLOT Configuration ------------------------------------------*/
556  /* This register has no meaning in AC 97 and SPDIF audio protocol */
558  SAI_xSLOTR_NBSLOT | SAI_xSLOTR_SLOTEN ));
559 
560  hsai->Instance->SLOTR|= hsai->SlotInit.FirstBitOffset | hsai->SlotInit.SlotSize
561  | (hsai->SlotInit.SlotActive << 16) | ((hsai->SlotInit.SlotNumber - 1) << 8);
562 
563  /* Initialize the error code */
565 
566  /* Initialize the SAI state */
567  hsai->State= HAL_SAI_STATE_READY;
568 
569  /* Release Lock */
570  __HAL_UNLOCK(hsai);
571 
572  return HAL_OK;
573 }
574 
582 {
583  /* Check the SAI handle allocation */
584  if(hsai == NULL)
585  {
586  return HAL_ERROR;
587  }
588 
589  hsai->State = HAL_SAI_STATE_BUSY;
590 
591  /* Disabled All interrupt and clear all the flag */
592  hsai->Instance->IMR = 0;
593  hsai->Instance->CLRFR = 0xFFFFFFFFU;
594 
595  /* Disable the SAI */
596  SAI_Disable(hsai);
597 
598  /* Flush the fifo */
600 
601  /* DeInit the low level hardware: GPIO, CLOCK, NVIC and DMA */
602 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
603  if (hsai->MspDeInitCallback == NULL)
604  {
605  hsai->MspDeInitCallback = HAL_SAI_MspDeInit;
606  }
607  hsai->MspDeInitCallback(hsai);
608 #else
609  HAL_SAI_MspDeInit(hsai);
610 #endif /* USE_HAL_SAI_REGISTER_CALLBACKS */
611 
612  /* Initialize the error code */
614 
615  /* Initialize the SAI state */
616  hsai->State = HAL_SAI_STATE_RESET;
617 
618  /* Release Lock */
619  __HAL_UNLOCK(hsai);
620 
621  return HAL_OK;
622 }
623 
630 __weak void HAL_SAI_MspInit(SAI_HandleTypeDef *hsai)
631 {
632  /* Prevent unused argument(s) compilation warning */
633  UNUSED(hsai);
634 
635  /* NOTE : This function should not be modified, when the callback is needed,
636  the HAL_SAI_MspInit could be implemented in the user file
637  */
638 }
639 
646 __weak void HAL_SAI_MspDeInit(SAI_HandleTypeDef *hsai)
647 {
648  /* Prevent unused argument(s) compilation warning */
649  UNUSED(hsai);
650 
651  /* NOTE : This function should not be modified, when the callback is needed,
652  the HAL_SAI_MspDeInit could be implemented in the user file
653  */
654 }
655 
656 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
657 
673 HAL_StatusTypeDef HAL_SAI_RegisterCallback(SAI_HandleTypeDef *hsai,
674  HAL_SAI_CallbackIDTypeDef CallbackID,
675  pSAI_CallbackTypeDef pCallback)
676 {
677  HAL_StatusTypeDef status = HAL_OK;
678 
679  if (pCallback == NULL)
680  {
681  /* update the error code */
682  hsai->ErrorCode |= HAL_SAI_ERROR_INVALID_CALLBACK;
683  /* update return status */
684  status = HAL_ERROR;
685  }
686  else
687  {
688  if (HAL_SAI_STATE_READY == hsai->State)
689  {
690  switch (CallbackID)
691  {
692  case HAL_SAI_RX_COMPLETE_CB_ID :
693  hsai->RxCpltCallback = pCallback;
694  break;
695  case HAL_SAI_RX_HALFCOMPLETE_CB_ID :
696  hsai->RxHalfCpltCallback = pCallback;
697  break;
698  case HAL_SAI_TX_COMPLETE_CB_ID :
699  hsai->TxCpltCallback = pCallback;
700  break;
701  case HAL_SAI_TX_HALFCOMPLETE_CB_ID :
702  hsai->TxHalfCpltCallback = pCallback;
703  break;
704  case HAL_SAI_ERROR_CB_ID :
705  hsai->ErrorCallback = pCallback;
706  break;
707  case HAL_SAI_MSPINIT_CB_ID :
708  hsai->MspInitCallback = pCallback;
709  break;
710  case HAL_SAI_MSPDEINIT_CB_ID :
711  hsai->MspDeInitCallback = pCallback;
712  break;
713  default :
714  /* update the error code */
715  hsai->ErrorCode |= HAL_SAI_ERROR_INVALID_CALLBACK;
716  /* update return status */
717  status = HAL_ERROR;
718  break;
719  }
720  }
721  else if (HAL_SAI_STATE_RESET == hsai->State)
722  {
723  switch (CallbackID)
724  {
725  case HAL_SAI_MSPINIT_CB_ID :
726  hsai->MspInitCallback = pCallback;
727  break;
728  case HAL_SAI_MSPDEINIT_CB_ID :
729  hsai->MspDeInitCallback = pCallback;
730  break;
731  default :
732  /* update the error code */
733  hsai->ErrorCode |= HAL_SAI_ERROR_INVALID_CALLBACK;
734  /* update return status */
735  status = HAL_ERROR;
736  break;
737  }
738  }
739  else
740  {
741  /* update the error code */
742  hsai->ErrorCode |= HAL_SAI_ERROR_INVALID_CALLBACK;
743  /* update return status */
744  status = HAL_ERROR;
745  }
746  }
747  return status;
748 }
749 
765 HAL_StatusTypeDef HAL_SAI_UnRegisterCallback(SAI_HandleTypeDef *hsai,
766  HAL_SAI_CallbackIDTypeDef CallbackID)
767 {
768  HAL_StatusTypeDef status = HAL_OK;
769 
770  if (HAL_SAI_STATE_READY == hsai->State)
771  {
772  switch (CallbackID)
773  {
774  case HAL_SAI_RX_COMPLETE_CB_ID :
775  hsai->RxCpltCallback = HAL_SAI_RxCpltCallback;
776  break;
777  case HAL_SAI_RX_HALFCOMPLETE_CB_ID :
778  hsai->RxHalfCpltCallback = HAL_SAI_RxHalfCpltCallback;
779  break;
780  case HAL_SAI_TX_COMPLETE_CB_ID :
781  hsai->TxCpltCallback = HAL_SAI_TxCpltCallback;
782  break;
783  case HAL_SAI_TX_HALFCOMPLETE_CB_ID :
784  hsai->TxHalfCpltCallback = HAL_SAI_TxHalfCpltCallback;
785  break;
786  case HAL_SAI_ERROR_CB_ID :
787  hsai->ErrorCallback = HAL_SAI_ErrorCallback;
788  break;
789  case HAL_SAI_MSPINIT_CB_ID :
790  hsai->MspInitCallback = HAL_SAI_MspInit;
791  break;
792  case HAL_SAI_MSPDEINIT_CB_ID :
793  hsai->MspDeInitCallback = HAL_SAI_MspDeInit;
794  break;
795  default :
796  /* update the error code */
797  hsai->ErrorCode |= HAL_SAI_ERROR_INVALID_CALLBACK;
798  /* update return status */
799  status = HAL_ERROR;
800  break;
801  }
802  }
803  else if (HAL_SAI_STATE_RESET == hsai->State)
804  {
805  switch (CallbackID)
806  {
807  case HAL_SAI_MSPINIT_CB_ID :
808  hsai->MspInitCallback = HAL_SAI_MspInit;
809  break;
810  case HAL_SAI_MSPDEINIT_CB_ID :
811  hsai->MspDeInitCallback = HAL_SAI_MspDeInit;
812  break;
813  default :
814  /* update the error code */
815  hsai->ErrorCode |= HAL_SAI_ERROR_INVALID_CALLBACK;
816  /* update return status */
817  status = HAL_ERROR;
818  break;
819  }
820  }
821  else
822  {
823  /* update the error code */
824  hsai->ErrorCode |= HAL_SAI_ERROR_INVALID_CALLBACK;
825  /* update return status */
826  status = HAL_ERROR;
827  }
828  return status;
829 }
830 #endif /* USE_HAL_SAI_REGISTER_CALLBACKS */
831 
887 HAL_StatusTypeDef HAL_SAI_Transmit(SAI_HandleTypeDef *hsai, uint8_t* pData, uint16_t Size, uint32_t Timeout)
888 {
889  uint32_t tickstart = HAL_GetTick();
890 
891  if((pData == NULL ) || (Size == 0))
892  {
893  return HAL_ERROR;
894  }
895 
896  if(hsai->State == HAL_SAI_STATE_READY)
897  {
898  /* Process Locked */
899  __HAL_LOCK(hsai);
900 
901  hsai->XferSize = Size;
902  hsai->XferCount = Size;
903  hsai->pBuffPtr = pData;
906 
907  /* Check if the SAI is already enabled */
908  if((hsai->Instance->CR1 & SAI_xCR1_SAIEN) == RESET)
909  {
910  /* fill the fifo with data before to enabled the SAI */
911  SAI_FillFifo(hsai);
912  /* Enable SAI peripheral */
913  __HAL_SAI_ENABLE(hsai);
914  }
915 
916  while(hsai->XferCount > 0)
917  {
918  /* Write data if the FIFO is not full */
919  if((hsai->Instance->SR & SAI_xSR_FLVL) != SAI_FIFOSTATUS_FULL)
920  {
921  if((hsai->Init.DataSize == SAI_DATASIZE_8) && (hsai->Init.CompandingMode == SAI_NOCOMPANDING))
922  {
923  hsai->Instance->DR = (*hsai->pBuffPtr++);
924  }
925  else if(hsai->Init.DataSize <= SAI_DATASIZE_16)
926  {
927  hsai->Instance->DR = *((uint16_t *)hsai->pBuffPtr);
928  hsai->pBuffPtr+= 2;
929  }
930  else
931  {
932  hsai->Instance->DR = *((uint32_t *)hsai->pBuffPtr);
933  hsai->pBuffPtr+= 4;
934  }
935  hsai->XferCount--;
936  }
937  else
938  {
939  /* Check for the Timeout */
940  if((Timeout != HAL_MAX_DELAY) && ((Timeout == 0)||((HAL_GetTick() - tickstart) > Timeout)))
941  {
942  /* Update error code */
944 
945  /* Clear all the flags */
946  hsai->Instance->CLRFR = 0xFFFFFFFFU;
947 
948  /* Disable SAI peripheral */
949  SAI_Disable(hsai);
950 
951  /* Flush the fifo */
953 
954  /* Change the SAI state */
955  hsai->State = HAL_SAI_STATE_READY;
956 
957  /* Process Unlocked */
958  __HAL_UNLOCK(hsai);
959 
960  return HAL_ERROR;
961  }
962  }
963  }
964 
965  hsai->State = HAL_SAI_STATE_READY;
966 
967  /* Process Unlocked */
968  __HAL_UNLOCK(hsai);
969 
970  return HAL_OK;
971  }
972  else
973  {
974  return HAL_BUSY;
975  }
976 }
977 
987 HAL_StatusTypeDef HAL_SAI_Receive(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size, uint32_t Timeout)
988 {
989  uint32_t tickstart = HAL_GetTick();
990 
991  if((pData == NULL ) || (Size == 0))
992  {
993  return HAL_ERROR;
994  }
995 
996  if(hsai->State == HAL_SAI_STATE_READY)
997  {
998  /* Process Locked */
999  __HAL_LOCK(hsai);
1000 
1001  hsai->pBuffPtr = pData;
1002  hsai->XferSize = Size;
1003  hsai->XferCount = Size;
1004  hsai->State = HAL_SAI_STATE_BUSY_RX;
1005  hsai->ErrorCode = HAL_SAI_ERROR_NONE;
1006 
1007  /* Check if the SAI is already enabled */
1008  if((hsai->Instance->CR1 & SAI_xCR1_SAIEN) == RESET)
1009  {
1010  /* Enable SAI peripheral */
1011  __HAL_SAI_ENABLE(hsai);
1012  }
1013 
1014  /* Receive data */
1015  while(hsai->XferCount > 0)
1016  {
1017  if((hsai->Instance->SR & SAI_xSR_FLVL) != SAI_FIFOSTATUS_EMPTY)
1018  {
1019  if((hsai->Init.DataSize == SAI_DATASIZE_8) && (hsai->Init.CompandingMode == SAI_NOCOMPANDING))
1020  {
1021  (*hsai->pBuffPtr++) = hsai->Instance->DR;
1022  }
1023  else if(hsai->Init.DataSize <= SAI_DATASIZE_16)
1024  {
1025  *((uint16_t*)hsai->pBuffPtr) = hsai->Instance->DR;
1026  hsai->pBuffPtr+= 2;
1027  }
1028  else
1029  {
1030  *((uint32_t*)hsai->pBuffPtr) = hsai->Instance->DR;
1031  hsai->pBuffPtr+= 4;
1032  }
1033  hsai->XferCount--;
1034  }
1035  else
1036  {
1037  /* Check for the Timeout */
1038  if((Timeout != HAL_MAX_DELAY) && ((Timeout == 0)||((HAL_GetTick() - tickstart) > Timeout)))
1039  {
1040  /* Update error code */
1042 
1043  /* Clear all the flags */
1044  hsai->Instance->CLRFR = 0xFFFFFFFFU;
1045 
1046  /* Disable SAI peripheral */
1047  SAI_Disable(hsai);
1048 
1049  /* Flush the fifo */
1051 
1052  /* Change the SAI state */
1053  hsai->State = HAL_SAI_STATE_READY;
1054 
1055  /* Process Unlocked */
1056  __HAL_UNLOCK(hsai);
1057 
1058  return HAL_ERROR;
1059  }
1060  }
1061  }
1062 
1063  hsai->State = HAL_SAI_STATE_READY;
1064 
1065  /* Process Unlocked */
1066  __HAL_UNLOCK(hsai);
1067 
1068  return HAL_OK;
1069  }
1070  else
1071  {
1072  return HAL_BUSY;
1073  }
1074 }
1075 
1084 HAL_StatusTypeDef HAL_SAI_Transmit_IT(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size)
1085 {
1086  if((pData == NULL) || (Size == 0))
1087  {
1088  return HAL_ERROR;
1089  }
1090 
1091  if(hsai->State == HAL_SAI_STATE_READY)
1092  {
1093  /* Process Locked */
1094  __HAL_LOCK(hsai);
1095 
1096  hsai->pBuffPtr = pData;
1097  hsai->XferSize = Size;
1098  hsai->XferCount = Size;
1099  hsai->ErrorCode = HAL_SAI_ERROR_NONE;
1100  hsai->State = HAL_SAI_STATE_BUSY_TX;
1101 
1102  if((hsai->Init.DataSize == SAI_DATASIZE_8) && (hsai->Init.CompandingMode == SAI_NOCOMPANDING))
1103  {
1104  hsai->InterruptServiceRoutine = SAI_Transmit_IT8Bit;
1105  }
1106  else if(hsai->Init.DataSize <= SAI_DATASIZE_16)
1107  {
1108  hsai->InterruptServiceRoutine = SAI_Transmit_IT16Bit;
1109  }
1110  else
1111  {
1112  hsai->InterruptServiceRoutine = SAI_Transmit_IT32Bit;
1113  }
1114 
1115  /* Fill the fifo before starting the communication */
1116  SAI_FillFifo(hsai);
1117 
1118  /* Enable FRQ and OVRUDR interrupts */
1119  __HAL_SAI_ENABLE_IT(hsai, SAI_InterruptFlag(hsai, SAI_MODE_IT));
1120 
1121  /* Check if the SAI is already enabled */
1122  if((hsai->Instance->CR1 & SAI_xCR1_SAIEN) == RESET)
1123  {
1124  /* Enable SAI peripheral */
1125  __HAL_SAI_ENABLE(hsai);
1126  }
1127  /* Process Unlocked */
1128  __HAL_UNLOCK(hsai);
1129 
1130  return HAL_OK;
1131  }
1132  else
1133  {
1134  return HAL_BUSY;
1135  }
1136 }
1137 
1146 HAL_StatusTypeDef HAL_SAI_Receive_IT(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size)
1147 {
1148  if((pData == NULL) || (Size == 0))
1149  {
1150  return HAL_ERROR;
1151  }
1152 
1153  if(hsai->State == HAL_SAI_STATE_READY)
1154  {
1155  /* Process Locked */
1156  __HAL_LOCK(hsai);
1157 
1158  hsai->pBuffPtr = pData;
1159  hsai->XferSize = Size;
1160  hsai->XferCount = Size;
1161  hsai->ErrorCode = HAL_SAI_ERROR_NONE;
1162  hsai->State = HAL_SAI_STATE_BUSY_RX;
1163 
1164  if((hsai->Init.DataSize == SAI_DATASIZE_8) && (hsai->Init.CompandingMode == SAI_NOCOMPANDING))
1165  {
1166  hsai->InterruptServiceRoutine = SAI_Receive_IT8Bit;
1167  }
1168  else if(hsai->Init.DataSize <= SAI_DATASIZE_16)
1169  {
1170  hsai->InterruptServiceRoutine = SAI_Receive_IT16Bit;
1171  }
1172  else
1173  {
1174  hsai->InterruptServiceRoutine = SAI_Receive_IT32Bit;
1175  }
1176 
1177  /* Enable TXE and OVRUDR interrupts */
1178  __HAL_SAI_ENABLE_IT(hsai, SAI_InterruptFlag(hsai, SAI_MODE_IT));
1179 
1180  /* Check if the SAI is already enabled */
1181  if((hsai->Instance->CR1 & SAI_xCR1_SAIEN) == RESET)
1182  {
1183  /* Enable SAI peripheral */
1184  __HAL_SAI_ENABLE(hsai);
1185  }
1186 
1187  /* Process Unlocked */
1188  __HAL_UNLOCK(hsai);
1189 
1190  return HAL_OK;
1191  }
1192  else
1193  {
1194  return HAL_BUSY;
1195  }
1196 }
1197 
1205 {
1206  /* Process Locked */
1207  __HAL_LOCK(hsai);
1208 
1209  /* Pause the audio file playing by disabling the SAI DMA requests */
1210  hsai->Instance->CR1 &= ~SAI_xCR1_DMAEN;
1211 
1212  /* Process Unlocked */
1213  __HAL_UNLOCK(hsai);
1214 
1215  return HAL_OK;
1216 }
1217 
1225 {
1226  /* Process Locked */
1227  __HAL_LOCK(hsai);
1228 
1229  /* Enable the SAI DMA requests */
1230  hsai->Instance->CR1 |= SAI_xCR1_DMAEN;
1231 
1232  /* If the SAI peripheral is still not enabled, enable it */
1233  if ((hsai->Instance->CR1 & SAI_xCR1_SAIEN) == RESET)
1234  {
1235  /* Enable SAI peripheral */
1236  __HAL_SAI_ENABLE(hsai);
1237  }
1238 
1239  /* Process Unlocked */
1240  __HAL_UNLOCK(hsai);
1241 
1242  return HAL_OK;
1243 }
1244 
1252 {
1253  HAL_StatusTypeDef status = HAL_OK;
1254 
1255  /* Process Locked */
1256  __HAL_LOCK(hsai);
1257 
1258  /* Disable the SAI DMA request */
1259  hsai->Instance->CR1 &= ~SAI_xCR1_DMAEN;
1260 
1261  /* Abort the SAI Tx DMA Stream */
1262  if((hsai->hdmatx != NULL) && (hsai->State == HAL_SAI_STATE_BUSY_TX))
1263  {
1264  if(HAL_DMA_Abort(hsai->hdmatx) != HAL_OK)
1265  {
1266  /* If the DMA Tx errorCode is different from DMA No Transfer then return Error */
1267  if(hsai->hdmatx->ErrorCode != HAL_DMA_ERROR_NO_XFER)
1268  {
1269  status = HAL_ERROR;
1270  hsai->ErrorCode |= HAL_SAI_ERROR_DMA;
1271  }
1272  }
1273  }
1274 
1275  /* Abort the SAI Rx DMA Stream */
1276  if((hsai->hdmarx != NULL) && (hsai->State == HAL_SAI_STATE_BUSY_RX))
1277  {
1278  if(HAL_DMA_Abort(hsai->hdmarx) != HAL_OK)
1279  {
1280  /* If the DMA Rx errorCode is different from DMA No Transfer then return Error */
1281  if(hsai->hdmarx->ErrorCode != HAL_DMA_ERROR_NO_XFER)
1282  {
1283  status = HAL_ERROR;
1284  hsai->ErrorCode |= HAL_SAI_ERROR_DMA;
1285  }
1286  }
1287  }
1288 
1289  /* Disable SAI peripheral */
1290  SAI_Disable(hsai);
1291 
1292  /* Flush the fifo */
1294 
1295  /* Set hsai state to ready */
1296  hsai->State = HAL_SAI_STATE_READY;
1297 
1298  /* Process Unlocked */
1299  __HAL_UNLOCK(hsai);
1300 
1301  return status;
1302 }
1303 
1311 {
1312  HAL_StatusTypeDef status = HAL_OK;
1313 
1314  /* Process Locked */
1315  __HAL_LOCK(hsai);
1316 
1317  /* Check SAI DMA is enabled or not */
1318  if((hsai->Instance->CR1 & SAI_xCR1_DMAEN) == SAI_xCR1_DMAEN)
1319  {
1320  /* Disable the SAI DMA request */
1321  hsai->Instance->CR1 &= ~SAI_xCR1_DMAEN;
1322 
1323  /* Abort the SAI Tx DMA Stream */
1324  if((hsai->hdmatx != NULL) && (hsai->State == HAL_SAI_STATE_BUSY_TX))
1325  {
1326  if(HAL_DMA_Abort(hsai->hdmatx) != HAL_OK)
1327  {
1328  /* If the DMA Tx errorCode is different from DMA No Transfer then return Error */
1329  if(hsai->hdmatx->ErrorCode != HAL_DMA_ERROR_NO_XFER)
1330  {
1331  status = HAL_ERROR;
1332  hsai->ErrorCode |= HAL_SAI_ERROR_DMA;
1333  }
1334  }
1335  }
1336 
1337  /* Abort the SAI Rx DMA Stream */
1338  if((hsai->hdmarx != NULL) && (hsai->State == HAL_SAI_STATE_BUSY_RX))
1339  {
1340  if(HAL_DMA_Abort(hsai->hdmarx) != HAL_OK)
1341  {
1342  /* If the DMA Rx errorCode is different from DMA No Transfer then return Error */
1343  if(hsai->hdmarx->ErrorCode != HAL_DMA_ERROR_NO_XFER)
1344  {
1345  status = HAL_ERROR;
1346  hsai->ErrorCode |= HAL_SAI_ERROR_DMA;
1347  }
1348  }
1349  }
1350  }
1351  /* Disabled All interrupt and clear all the flag */
1352  hsai->Instance->IMR = 0;
1353  hsai->Instance->CLRFR = 0xFFFFFFFFU;
1354 
1355  /* Disable SAI peripheral */
1356  SAI_Disable(hsai);
1357 
1358  /* Flush the fifo */
1360 
1361  /* Set hsai state to ready */
1362  hsai->State = HAL_SAI_STATE_READY;
1363 
1364  /* Process Unlocked */
1365  __HAL_UNLOCK(hsai);
1366 
1367  return status;
1368 }
1369 
1378 HAL_StatusTypeDef HAL_SAI_Transmit_DMA(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size)
1379 {
1380  if((pData == NULL) || (Size == 0))
1381  {
1382  return HAL_ERROR;
1383  }
1384 
1385  if(hsai->State == HAL_SAI_STATE_READY)
1386  {
1387  /* Process Locked */
1388  __HAL_LOCK(hsai);
1389 
1390  hsai->pBuffPtr = pData;
1391  hsai->XferSize = Size;
1392  hsai->XferCount = Size;
1393  hsai->ErrorCode = HAL_SAI_ERROR_NONE;
1394  hsai->State = HAL_SAI_STATE_BUSY_TX;
1395 
1396  /* Set the SAI Tx DMA Half transfer complete callback */
1397  hsai->hdmatx->XferHalfCpltCallback = SAI_DMATxHalfCplt;
1398 
1399  /* Set the SAI TxDMA transfer complete callback */
1400  hsai->hdmatx->XferCpltCallback = SAI_DMATxCplt;
1401 
1402  /* Set the DMA error callback */
1403  hsai->hdmatx->XferErrorCallback = SAI_DMAError;
1404 
1405  /* Set the DMA Tx abort callback */
1406  hsai->hdmatx->XferAbortCallback = NULL;
1407 
1408  /* Enable the Tx DMA Stream */
1409  if(HAL_DMA_Start_IT(hsai->hdmatx, (uint32_t)hsai->pBuffPtr, (uint32_t)&hsai->Instance->DR, hsai->XferSize) != HAL_OK)
1410  {
1411  __HAL_UNLOCK(hsai);
1412  return HAL_ERROR;
1413  }
1414 
1415  /* Check if the SAI is already enabled */
1416  if((hsai->Instance->CR1 & SAI_xCR1_SAIEN) == RESET)
1417  {
1418  /* Enable SAI peripheral */
1419  __HAL_SAI_ENABLE(hsai);
1420  }
1421 
1422  /* Enable the interrupts for error handling */
1423  __HAL_SAI_ENABLE_IT(hsai, SAI_InterruptFlag(hsai, SAI_MODE_DMA));
1424 
1425  /* Enable SAI Tx DMA Request */
1426  hsai->Instance->CR1 |= SAI_xCR1_DMAEN;
1427 
1428  /* Process Unlocked */
1429  __HAL_UNLOCK(hsai);
1430 
1431  return HAL_OK;
1432  }
1433  else
1434  {
1435  return HAL_BUSY;
1436  }
1437 }
1438 
1447 HAL_StatusTypeDef HAL_SAI_Receive_DMA(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size)
1448 {
1449 
1450  if((pData == NULL) || (Size == 0))
1451  {
1452  return HAL_ERROR;
1453  }
1454 
1455  if(hsai->State == HAL_SAI_STATE_READY)
1456  {
1457  /* Process Locked */
1458  __HAL_LOCK(hsai);
1459 
1460  hsai->pBuffPtr = pData;
1461  hsai->XferSize = Size;
1462  hsai->XferCount = Size;
1463  hsai->ErrorCode = HAL_SAI_ERROR_NONE;
1464  hsai->State = HAL_SAI_STATE_BUSY_RX;
1465 
1466  /* Set the SAI Rx DMA Half transfer complete callback */
1467  hsai->hdmarx->XferHalfCpltCallback = SAI_DMARxHalfCplt;
1468 
1469  /* Set the SAI Rx DMA transfer complete callback */
1470  hsai->hdmarx->XferCpltCallback = SAI_DMARxCplt;
1471 
1472  /* Set the DMA error callback */
1473  hsai->hdmarx->XferErrorCallback = SAI_DMAError;
1474 
1475  /* Set the DMA Rx abort callback */
1476  hsai->hdmarx->XferAbortCallback = NULL;
1477 
1478  /* Enable the Rx DMA Stream */
1479  if(HAL_DMA_Start_IT(hsai->hdmarx, (uint32_t)&hsai->Instance->DR, (uint32_t)hsai->pBuffPtr, hsai->XferSize) != HAL_OK)
1480  {
1481  __HAL_UNLOCK(hsai);
1482  return HAL_ERROR;
1483  }
1484 
1485  /* Check if the SAI is already enabled */
1486  if((hsai->Instance->CR1 & SAI_xCR1_SAIEN) == RESET)
1487  {
1488  /* Enable SAI peripheral */
1489  __HAL_SAI_ENABLE(hsai);
1490  }
1491 
1492  /* Enable the interrupts for error handling */
1493  __HAL_SAI_ENABLE_IT(hsai, SAI_InterruptFlag(hsai, SAI_MODE_DMA));
1494 
1495  /* Enable SAI Rx DMA Request */
1496  hsai->Instance->CR1 |= SAI_xCR1_DMAEN;
1497 
1498  /* Process Unlocked */
1499  __HAL_UNLOCK(hsai);
1500 
1501  return HAL_OK;
1502  }
1503  else
1504  {
1505  return HAL_BUSY;
1506  }
1507 }
1508 
1517 {
1519 
1520  if(hsai->State != HAL_SAI_STATE_RESET)
1521  {
1523  SET_BIT(hsai->Instance->CR2, SAI_xCR2_MUTE | val);
1524  return HAL_OK;
1525  }
1526  return HAL_ERROR;
1527 }
1528 
1536 {
1537  if(hsai->State != HAL_SAI_STATE_RESET)
1538  {
1540  return HAL_OK;
1541  }
1542  return HAL_ERROR;
1543 }
1544 
1554 {
1556 
1557  if(hsai->State != HAL_SAI_STATE_RESET)
1558  {
1559  /* set the mute counter */
1561  SET_BIT(hsai->Instance->CR2, (uint32_t)((uint32_t)counter << SAI_xCR2_MUTECNT_Pos));
1562  hsai->mutecallback = callback;
1563  /* enable the IT interrupt */
1565  return HAL_OK;
1566  }
1567  return HAL_ERROR;
1568 }
1569 
1577 {
1578  if(hsai->State != HAL_SAI_STATE_RESET)
1579  {
1580  /* set the mutecallback to NULL */
1581  hsai->mutecallback = (SAIcallback)NULL;
1582  /* enable the IT interrupt */
1584  return HAL_OK;
1585  }
1586  return HAL_ERROR;
1587 }
1588 
1596 {
1597  if(hsai->State != HAL_SAI_STATE_RESET)
1598  {
1599  uint32_t itflags = hsai->Instance->SR;
1600  uint32_t itsources = hsai->Instance->IMR;
1601  uint32_t cr1config = hsai->Instance->CR1;
1602  uint32_t tmperror;
1603 
1604  /* SAI Fifo request interrupt occurred ------------------------------------*/
1605  if(((itflags & SAI_xSR_FREQ) == SAI_xSR_FREQ) && ((itsources & SAI_IT_FREQ) == SAI_IT_FREQ))
1606  {
1607  hsai->InterruptServiceRoutine(hsai);
1608  }
1609  /* SAI Overrun error interrupt occurred ----------------------------------*/
1610  else if(((itflags & SAI_FLAG_OVRUDR) == SAI_FLAG_OVRUDR) && ((itsources & SAI_IT_OVRUDR) == SAI_IT_OVRUDR))
1611  {
1612  /* Clear the SAI Overrun flag */
1614  /* Get the SAI error code */
1615  tmperror = ((hsai->State == HAL_SAI_STATE_BUSY_RX) ? HAL_SAI_ERROR_OVR : HAL_SAI_ERROR_UDR);
1616  /* Change the SAI error code */
1617  hsai->ErrorCode |= tmperror;
1618  /* the transfer is not stopped, we will forward the information to the user and we let the user decide what needs to be done */
1619 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
1620  hsai->ErrorCallback(hsai);
1621 #else
1622  HAL_SAI_ErrorCallback(hsai);
1623 #endif /* USE_HAL_SAI_REGISTER_CALLBACKS */
1624  }
1625  /* SAI mutedet interrupt occurred ----------------------------------*/
1626  else if(((itflags & SAI_FLAG_MUTEDET) == SAI_FLAG_MUTEDET) && ((itsources & SAI_IT_MUTEDET) == SAI_IT_MUTEDET))
1627  {
1628  /* Clear the SAI mutedet flag */
1630  /* call the call back function */
1631  if(hsai->mutecallback != (SAIcallback)NULL)
1632  {
1633  /* inform the user that an RX mute event has been detected */
1634  hsai->mutecallback();
1635  }
1636  }
1637  /* SAI AFSDET interrupt occurred ----------------------------------*/
1638  else if(((itflags & SAI_FLAG_AFSDET) == SAI_FLAG_AFSDET) && ((itsources & SAI_IT_AFSDET) == SAI_IT_AFSDET))
1639  {
1640  /* Change the SAI error code */
1642  /* Check SAI DMA is enabled or not */
1643  if((cr1config & SAI_xCR1_DMAEN) == SAI_xCR1_DMAEN)
1644  {
1645  /* Abort the SAI DMA Streams */
1646  if(hsai->hdmatx != NULL)
1647  {
1648  /* Set the DMA Tx abort callback */
1649  hsai->hdmatx->XferAbortCallback = SAI_DMAAbort;
1650 
1651  /* Abort DMA in IT mode */
1652  HAL_DMA_Abort_IT(hsai->hdmatx);
1653  }
1654  else if(hsai->hdmarx != NULL)
1655  {
1656  /* Set the DMA Rx abort callback */
1657  hsai->hdmarx->XferAbortCallback = SAI_DMAAbort;
1658  /* Abort DMA in IT mode */
1659  HAL_DMA_Abort_IT(hsai->hdmarx);
1660  }
1661  }
1662  else
1663  {
1664  /* Abort SAI */
1665  HAL_SAI_Abort(hsai);
1666 
1667  /* Set error callback */
1668 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
1669  hsai->ErrorCallback(hsai);
1670 #else
1671  HAL_SAI_ErrorCallback(hsai);
1672 #endif /* USE_HAL_SAI_REGISTER_CALLBACKS */
1673  }
1674  }
1675  /* SAI LFSDET interrupt occurred ----------------------------------*/
1676  else if(((itflags & SAI_FLAG_LFSDET) == SAI_FLAG_LFSDET) && ((itsources & SAI_IT_LFSDET) == SAI_IT_LFSDET))
1677  {
1678  /* Change the SAI error code */
1680 
1681  /* Check SAI DMA is enabled or not */
1682  if((cr1config & SAI_xCR1_DMAEN) == SAI_xCR1_DMAEN)
1683  {
1684  /* Abort the SAI DMA Streams */
1685  if(hsai->hdmatx != NULL)
1686  {
1687  /* Set the DMA Tx abort callback */
1688  hsai->hdmatx->XferAbortCallback = SAI_DMAAbort;
1689  /* Abort DMA in IT mode */
1690  HAL_DMA_Abort_IT(hsai->hdmatx);
1691  }
1692  else if(hsai->hdmarx != NULL)
1693  {
1694  /* Set the DMA Rx abort callback */
1695  hsai->hdmarx->XferAbortCallback = SAI_DMAAbort;
1696  /* Abort DMA in IT mode */
1697  HAL_DMA_Abort_IT(hsai->hdmarx);
1698  }
1699  }
1700  else
1701  {
1702  /* Abort SAI */
1703  HAL_SAI_Abort(hsai);
1704 
1705  /* Set error callback */
1706 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
1707  hsai->ErrorCallback(hsai);
1708 #else
1709  HAL_SAI_ErrorCallback(hsai);
1710 #endif /* USE_HAL_SAI_REGISTER_CALLBACKS */
1711  }
1712  }
1713  /* SAI WCKCFG interrupt occurred ----------------------------------*/
1714  else if(((itflags & SAI_FLAG_WCKCFG) == SAI_FLAG_WCKCFG) && ((itsources & SAI_IT_WCKCFG) == SAI_IT_WCKCFG))
1715  {
1716  /* Change the SAI error code */
1718 
1719  /* Abort the SAI DMA Streams */
1720  if(hsai->hdmatx != NULL)
1721  {
1722  /* Set the DMA Tx abort callback */
1723  hsai->hdmatx->XferAbortCallback = SAI_DMAAbort;
1724  /* Abort DMA in IT mode */
1725  HAL_DMA_Abort_IT(hsai->hdmatx);
1726  }
1727  else if(hsai->hdmarx != NULL)
1728  {
1729  /* Set the DMA Rx abort callback */
1730  hsai->hdmarx->XferAbortCallback = SAI_DMAAbort;
1731  /* Abort DMA in IT mode */
1732  HAL_DMA_Abort_IT(hsai->hdmarx);
1733  }
1734  else
1735  {
1736  /* If WCKCFG occurs, SAI audio block is automatically disabled */
1737  /* Disable all interrupts and clear all flags */
1738  hsai->Instance->IMR = 0U;
1739  hsai->Instance->CLRFR = 0xFFFFFFFFU;
1740  /* Set the SAI state to ready to be able to start again the process */
1741  hsai->State = HAL_SAI_STATE_READY;
1742 
1743  /* Initialize XferCount */
1744  hsai->XferCount = 0U;
1745 
1746  /* SAI error Callback */
1747 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
1748  hsai->ErrorCallback(hsai);
1749 #else
1750  HAL_SAI_ErrorCallback(hsai);
1751 #endif /* USE_HAL_SAI_REGISTER_CALLBACKS */
1752  }
1753  }
1754  /* SAI CNRDY interrupt occurred ----------------------------------*/
1755  else if(((itflags & SAI_FLAG_CNRDY) == SAI_FLAG_CNRDY) && ((itsources & SAI_IT_CNRDY) == SAI_IT_CNRDY))
1756  {
1757  /* Clear the SAI CNRDY flag */
1759  /* Change the SAI error code */
1761  /* the transfer is not stopped, we will forward the information to the user and we let the user decide what needs to be done */
1762 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
1763  hsai->ErrorCallback(hsai);
1764 #else
1765  HAL_SAI_ErrorCallback(hsai);
1766 #endif /* USE_HAL_SAI_REGISTER_CALLBACKS */
1767  }
1768  else
1769  {
1770  /* Nothing to do */
1771  }
1772  }
1773 }
1774 
1781 __weak void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai)
1782 {
1783  /* Prevent unused argument(s) compilation warning */
1784  UNUSED(hsai);
1785 
1786  /* NOTE : This function should not be modified, when the callback is needed,
1787  the HAL_SAI_TxCpltCallback could be implemented in the user file
1788  */
1789 }
1790 
1798 {
1799  /* Prevent unused argument(s) compilation warning */
1800  UNUSED(hsai);
1801 
1802  /* NOTE : This function should not be modified, when the callback is needed,
1803  the HAL_SAI_TxHalfCpltCallback could be implemented in the user file
1804  */
1805 }
1806 
1813 __weak void HAL_SAI_RxCpltCallback(SAI_HandleTypeDef *hsai)
1814 {
1815  /* Prevent unused argument(s) compilation warning */
1816  UNUSED(hsai);
1817 
1818  /* NOTE : This function should not be modified, when the callback is needed,
1819  the HAL_SAI_RxCpltCallback could be implemented in the user file
1820  */
1821 }
1822 
1830 {
1831  /* Prevent unused argument(s) compilation warning */
1832  UNUSED(hsai);
1833 
1834  /* NOTE : This function should not be modified, when the callback is needed,
1835  the HAL_SAI_RxHalfCpltCallback could be implemented in the user file
1836  */
1837 }
1838 
1845 __weak void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai)
1846 {
1847  /* Prevent unused argument(s) compilation warning */
1848  UNUSED(hsai);
1849 
1850  /* NOTE : This function should not be modified, when the callback is needed,
1851  the HAL_SAI_ErrorCallback could be implemented in the user file
1852  */
1853 }
1854 
1881 {
1882  return hsai->State;
1883 }
1884 
1891 uint32_t HAL_SAI_GetError(SAI_HandleTypeDef *hsai)
1892 {
1893  return hsai->ErrorCode;
1894 }
1895 
1921 static HAL_StatusTypeDef SAI_InitI2S(SAI_HandleTypeDef *hsai, uint32_t protocol, uint32_t datasize, uint32_t nbslot)
1922 {
1924  hsai->Init.FirstBit = SAI_FIRSTBIT_MSB;
1925  /* Compute ClockStrobing according AudioMode */
1926  if((hsai->Init.AudioMode == SAI_MODEMASTER_TX) || (hsai->Init.AudioMode == SAI_MODESLAVE_TX))
1927  { /* Transmit */
1929  }
1930  else
1931  { /* Receive */
1933  }
1936  hsai->SlotInit.FirstBitOffset = 0;
1937  hsai->SlotInit.SlotNumber = nbslot;
1938 
1939  /* in IS2 the number of slot must be even */
1940  if((nbslot & 0x1) != 0 )
1941  {
1942  return HAL_ERROR;
1943  }
1944 
1945  switch(protocol)
1946  {
1947  case SAI_I2S_STANDARD :
1950  break;
1951  case SAI_I2S_MSBJUSTIFIED :
1952  case SAI_I2S_LSBJUSTIFIED :
1955  break;
1956  default :
1957  return HAL_ERROR;
1958  }
1959 
1960  /* Frame definition */
1961  switch(datasize)
1962  {
1964  hsai->Init.DataSize = SAI_DATASIZE_16;
1965  hsai->FrameInit.FrameLength = 32*(nbslot/2);
1966  hsai->FrameInit.ActiveFrameLength = 16*(nbslot/2);
1968  break;
1970  hsai->Init.DataSize = SAI_DATASIZE_16;
1971  hsai->FrameInit.FrameLength = 64*(nbslot/2);
1972  hsai->FrameInit.ActiveFrameLength = 32*(nbslot/2);
1974  break;
1976  hsai->Init.DataSize = SAI_DATASIZE_24;
1977  hsai->FrameInit.FrameLength = 64*(nbslot/2);
1978  hsai->FrameInit.ActiveFrameLength = 32*(nbslot/2);
1980  break;
1982  hsai->Init.DataSize = SAI_DATASIZE_32;
1983  hsai->FrameInit.FrameLength = 64*(nbslot/2);
1984  hsai->FrameInit.ActiveFrameLength = 32*(nbslot/2);
1986  break;
1987  default :
1988  return HAL_ERROR;
1989  }
1990  if(protocol == SAI_I2S_LSBJUSTIFIED)
1991  {
1992  if (datasize == SAI_PROTOCOL_DATASIZE_16BITEXTENDED)
1993  {
1994  hsai->SlotInit.FirstBitOffset = 16;
1995  }
1996  if (datasize == SAI_PROTOCOL_DATASIZE_24BIT)
1997  {
1998  hsai->SlotInit.FirstBitOffset = 8;
1999  }
2000  }
2001  return HAL_OK;
2002 }
2003 
2014 static HAL_StatusTypeDef SAI_InitPCM(SAI_HandleTypeDef *hsai, uint32_t protocol, uint32_t datasize, uint32_t nbslot)
2015 {
2017  hsai->Init.FirstBit = SAI_FIRSTBIT_MSB;
2018  /* Compute ClockStrobing according AudioMode */
2019  if((hsai->Init.AudioMode == SAI_MODEMASTER_TX) || (hsai->Init.AudioMode == SAI_MODESLAVE_TX))
2020  { /* Transmit */
2022  }
2023  else
2024  { /* Receive */
2026  }
2030  hsai->SlotInit.FirstBitOffset = 0;
2031  hsai->SlotInit.SlotNumber = nbslot;
2033 
2034  switch(protocol)
2035  {
2036  case SAI_PCM_SHORT :
2037  hsai->FrameInit.ActiveFrameLength = 1;
2038  break;
2039  case SAI_PCM_LONG :
2040  hsai->FrameInit.ActiveFrameLength = 13;
2041  break;
2042  default :
2043  return HAL_ERROR;
2044  }
2045 
2046  switch(datasize)
2047  {
2049  hsai->Init.DataSize = SAI_DATASIZE_16;
2050  hsai->FrameInit.FrameLength = 16 * nbslot;
2052  break;
2054  hsai->Init.DataSize = SAI_DATASIZE_16;
2055  hsai->FrameInit.FrameLength = 32 * nbslot;
2057  break;
2059  hsai->Init.DataSize = SAI_DATASIZE_24;
2060  hsai->FrameInit.FrameLength = 32 * nbslot;
2062  break;
2064  hsai->Init.DataSize = SAI_DATASIZE_32;
2065  hsai->FrameInit.FrameLength = 32 * nbslot;
2067  break;
2068  default :
2069  return HAL_ERROR;
2070  }
2071 
2072  return HAL_OK;
2073 }
2074 
2081 static void SAI_FillFifo(SAI_HandleTypeDef *hsai)
2082 {
2083  /* fill the fifo with data before to enabled the SAI */
2084  while(((hsai->Instance->SR & SAI_xSR_FLVL) != SAI_FIFOSTATUS_FULL) && (hsai->XferCount > 0))
2085  {
2086  if((hsai->Init.DataSize == SAI_DATASIZE_8) && (hsai->Init.CompandingMode == SAI_NOCOMPANDING))
2087  {
2088  hsai->Instance->DR = (*hsai->pBuffPtr++);
2089  }
2090  else if(hsai->Init.DataSize <= SAI_DATASIZE_16)
2091  {
2092  hsai->Instance->DR = *((uint32_t *)hsai->pBuffPtr);
2093  hsai->pBuffPtr+= 2;
2094  }
2095  else
2096  {
2097  hsai->Instance->DR = *((uint32_t *)hsai->pBuffPtr);
2098  hsai->pBuffPtr+= 4;
2099  }
2100  hsai->XferCount--;
2101  }
2102 }
2103 
2111 static uint32_t SAI_InterruptFlag(SAI_HandleTypeDef *hsai, uint32_t mode)
2112 {
2113  uint32_t tmpIT = SAI_IT_OVRUDR;
2114 
2115  if(mode == SAI_MODE_IT)
2116  {
2117  tmpIT|= SAI_IT_FREQ;
2118  }
2119 
2120  if((hsai->Init.Protocol == SAI_AC97_PROTOCOL) &&
2121  ((hsai->Init.AudioMode == SAI_MODESLAVE_RX) || (hsai->Init.AudioMode == SAI_MODEMASTER_RX)))
2122  {
2123  tmpIT|= SAI_IT_CNRDY;
2124  }
2125 
2126  if((hsai->Init.AudioMode == SAI_MODESLAVE_RX) || (hsai->Init.AudioMode == SAI_MODESLAVE_TX))
2127  {
2128  tmpIT|= SAI_IT_AFSDET | SAI_IT_LFSDET;
2129  }
2130  else
2131  {
2132  /* hsai has been configured in master mode */
2133  tmpIT|= SAI_IT_WCKCFG;
2134  }
2135  return tmpIT;
2136 }
2137 
2144 static HAL_StatusTypeDef SAI_Disable(SAI_HandleTypeDef *hsai)
2145 {
2146  register uint32_t count = SAI_DEFAULT_TIMEOUT * (SystemCoreClock /7/1000);
2147  HAL_StatusTypeDef status = HAL_OK;
2148 
2149  /* Disable the SAI instance */
2150  __HAL_SAI_DISABLE(hsai);
2151 
2152  do
2153  {
2154  /* Check for the Timeout */
2155  if (count-- == 0)
2156  {
2157  /* Update error code */
2159  status = HAL_TIMEOUT;
2160  break;
2161  }
2162  } while((hsai->Instance->CR1 & SAI_xCR1_SAIEN) != RESET);
2163 
2164  return status;
2165 }
2166 
2173 static void SAI_Transmit_IT8Bit(SAI_HandleTypeDef *hsai)
2174 {
2175  if(hsai->XferCount == 0)
2176  {
2177  /* Handle the end of the transmission */
2178  /* Disable FREQ and OVRUDR interrupts */
2179  __HAL_SAI_DISABLE_IT(hsai, SAI_InterruptFlag(hsai, SAI_MODE_IT));
2180  hsai->State = HAL_SAI_STATE_READY;
2181 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
2182  hsai->TxCpltCallback(hsai);
2183 #else
2184  HAL_SAI_TxCpltCallback(hsai);
2185 #endif /* USE_HAL_SAI_REGISTER_CALLBACKS */
2186  }
2187  else
2188  {
2189  /* Write data on DR register */
2190  hsai->Instance->DR = (*hsai->pBuffPtr++);
2191  hsai->XferCount--;
2192  }
2193 }
2194 
2201 static void SAI_Transmit_IT16Bit(SAI_HandleTypeDef *hsai)
2202 {
2203  if(hsai->XferCount == 0)
2204  {
2205  /* Handle the end of the transmission */
2206  /* Disable FREQ and OVRUDR interrupts */
2207  __HAL_SAI_DISABLE_IT(hsai, SAI_InterruptFlag(hsai, SAI_MODE_IT));
2208  hsai->State = HAL_SAI_STATE_READY;
2209 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
2210  hsai->TxCpltCallback(hsai);
2211 #else
2212  HAL_SAI_TxCpltCallback(hsai);
2213 #endif /* USE_HAL_SAI_REGISTER_CALLBACKS */
2214  }
2215  else
2216  {
2217  /* Write data on DR register */
2218  hsai->Instance->DR = *(uint16_t *)hsai->pBuffPtr;
2219  hsai->pBuffPtr+=2;
2220  hsai->XferCount--;
2221  }
2222 }
2223 
2230 static void SAI_Transmit_IT32Bit(SAI_HandleTypeDef *hsai)
2231 {
2232  if(hsai->XferCount == 0)
2233  {
2234  /* Handle the end of the transmission */
2235  /* Disable FREQ and OVRUDR interrupts */
2236  __HAL_SAI_DISABLE_IT(hsai, SAI_InterruptFlag(hsai, SAI_MODE_IT));
2237  hsai->State = HAL_SAI_STATE_READY;
2238 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
2239  hsai->TxCpltCallback(hsai);
2240 #else
2241  HAL_SAI_TxCpltCallback(hsai);
2242 #endif /* USE_HAL_SAI_REGISTER_CALLBACKS */
2243  }
2244  else
2245  {
2246  /* Write data on DR register */
2247  hsai->Instance->DR = *(uint32_t *)hsai->pBuffPtr;
2248  hsai->pBuffPtr+=4;
2249  hsai->XferCount--;
2250  }
2251 }
2252 
2259 static void SAI_Receive_IT8Bit(SAI_HandleTypeDef *hsai)
2260 {
2261  /* Receive data */
2262  (*hsai->pBuffPtr++) = hsai->Instance->DR;
2263  hsai->XferCount--;
2264 
2265  /* Check end of the transfer */
2266  if(hsai->XferCount == 0)
2267  {
2268  /* Disable TXE and OVRUDR interrupts */
2269  __HAL_SAI_DISABLE_IT(hsai, SAI_InterruptFlag(hsai, SAI_MODE_IT));
2270 
2271  /* Clear the SAI Overrun flag */
2273 
2274  hsai->State = HAL_SAI_STATE_READY;
2275 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
2276  hsai->RxCpltCallback(hsai);
2277 #else
2278  HAL_SAI_RxCpltCallback(hsai);
2279 #endif /* USE_HAL_SAI_REGISTER_CALLBACKS */
2280  }
2281 }
2282 
2289 static void SAI_Receive_IT16Bit(SAI_HandleTypeDef *hsai)
2290 {
2291  /* Receive data */
2292  *(uint16_t*)hsai->pBuffPtr = hsai->Instance->DR;
2293  hsai->pBuffPtr+=2;
2294  hsai->XferCount--;
2295 
2296  /* Check end of the transfer */
2297  if(hsai->XferCount == 0)
2298  {
2299  /* Disable TXE and OVRUDR interrupts */
2300  __HAL_SAI_DISABLE_IT(hsai, SAI_InterruptFlag(hsai, SAI_MODE_IT));
2301 
2302  /* Clear the SAI Overrun flag */
2304 
2305  hsai->State = HAL_SAI_STATE_READY;
2306 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
2307  hsai->RxCpltCallback(hsai);
2308 #else
2309  HAL_SAI_RxCpltCallback(hsai);
2310 #endif /* USE_HAL_SAI_REGISTER_CALLBACKS */
2311  }
2312 }
2313 
2320 static void SAI_Receive_IT32Bit(SAI_HandleTypeDef *hsai)
2321 {
2322  /* Receive data */
2323  *(uint32_t*)hsai->pBuffPtr = hsai->Instance->DR;
2324  hsai->pBuffPtr+=4;
2325  hsai->XferCount--;
2326 
2327  /* Check end of the transfer */
2328  if(hsai->XferCount == 0)
2329  {
2330  /* Disable TXE and OVRUDR interrupts */
2331  __HAL_SAI_DISABLE_IT(hsai, SAI_InterruptFlag(hsai, SAI_MODE_IT));
2332 
2333  /* Clear the SAI Overrun flag */
2335 
2336  hsai->State = HAL_SAI_STATE_READY;
2337 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
2338  hsai->RxCpltCallback(hsai);
2339 #else
2340  HAL_SAI_RxCpltCallback(hsai);
2341 #endif /* USE_HAL_SAI_REGISTER_CALLBACKS */
2342  }
2343 }
2344 
2351 static void SAI_DMATxCplt(DMA_HandleTypeDef *hdma)
2352 {
2353  SAI_HandleTypeDef* hsai = (SAI_HandleTypeDef*)((DMA_HandleTypeDef* )hdma)->Parent;
2354 
2355  if (hdma->Init.Mode != DMA_CIRCULAR)
2356  {
2357  hsai->XferCount = 0;
2358 
2359  /* Disable SAI Tx DMA Request */
2360  hsai->Instance->CR1 &= (uint32_t)(~SAI_xCR1_DMAEN);
2361 
2362  /* Stop the interrupts error handling */
2363  __HAL_SAI_DISABLE_IT(hsai, SAI_InterruptFlag(hsai, SAI_MODE_DMA));
2364 
2365  hsai->State= HAL_SAI_STATE_READY;
2366  }
2367 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
2368  hsai->TxCpltCallback(hsai);
2369 #else
2370  HAL_SAI_TxCpltCallback(hsai);
2371 #endif /* USE_HAL_SAI_REGISTER_CALLBACKS */
2372 }
2373 
2380 static void SAI_DMATxHalfCplt(DMA_HandleTypeDef *hdma)
2381 {
2382  SAI_HandleTypeDef* hsai = (SAI_HandleTypeDef*)((DMA_HandleTypeDef*)hdma)->Parent;
2383 
2384 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
2385  hsai->TxHalfCpltCallback(hsai);
2386 #else
2388 #endif /* USE_HAL_SAI_REGISTER_CALLBACKS */
2389 }
2390 
2397 static void SAI_DMARxCplt(DMA_HandleTypeDef *hdma)
2398 {
2399  SAI_HandleTypeDef* hsai = ( SAI_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
2400 
2401  if (hdma->Init.Mode != DMA_CIRCULAR)
2402  {
2403  /* Disable Rx DMA Request */
2404  hsai->Instance->CR1 &= (uint32_t)(~SAI_xCR1_DMAEN);
2405  hsai->XferCount = 0;
2406 
2407  /* Stop the interrupts error handling */
2408  __HAL_SAI_DISABLE_IT(hsai, SAI_InterruptFlag(hsai, SAI_MODE_DMA));
2409 
2410  hsai->State = HAL_SAI_STATE_READY;
2411  }
2412 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
2413  hsai->RxCpltCallback(hsai);
2414 #else
2415  HAL_SAI_RxCpltCallback(hsai);
2416 #endif /* USE_HAL_SAI_REGISTER_CALLBACKS */
2417 }
2418 
2425 static void SAI_DMARxHalfCplt(DMA_HandleTypeDef *hdma)
2426 {
2427  SAI_HandleTypeDef* hsai = (SAI_HandleTypeDef*)((DMA_HandleTypeDef*)hdma)->Parent;
2428 
2429 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
2430  hsai->RxHalfCpltCallback(hsai);
2431 #else
2433 #endif /* USE_HAL_SAI_REGISTER_CALLBACKS */
2434 }
2435 
2442 static void SAI_DMAError(DMA_HandleTypeDef *hdma)
2443 {
2444  SAI_HandleTypeDef* hsai = ( SAI_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
2445 
2446  /* Set SAI error code */
2447  hsai->ErrorCode |= HAL_SAI_ERROR_DMA;
2448 
2449  if((hsai->hdmatx->ErrorCode == HAL_DMA_ERROR_TE) || (hsai->hdmarx->ErrorCode == HAL_DMA_ERROR_TE))
2450  {
2451  /* Disable the SAI DMA request */
2452  hsai->Instance->CR1 &= ~SAI_xCR1_DMAEN;
2453 
2454  /* Disable SAI peripheral */
2455  SAI_Disable(hsai);
2456 
2457  /* Set the SAI state ready to be able to start again the process */
2458  hsai->State = HAL_SAI_STATE_READY;
2459 
2460  /* Initialize XferCount */
2461  hsai->XferCount = 0U;
2462  }
2463  /* SAI error Callback */
2464 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
2465  hsai->ErrorCallback(hsai);
2466 #else
2467  HAL_SAI_ErrorCallback(hsai);
2468 #endif /* USE_HAL_SAI_REGISTER_CALLBACKS */
2469 }
2470 
2477 static void SAI_DMAAbort(DMA_HandleTypeDef *hdma)
2478 {
2479  SAI_HandleTypeDef* hsai = ( SAI_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
2480 
2481  /* Disable DMA request */
2482  hsai->Instance->CR1 &= ~SAI_xCR1_DMAEN;
2483 
2484  /* Disable all interrupts and clear all flags */
2485  hsai->Instance->IMR = 0U;
2486  hsai->Instance->CLRFR = 0xFFFFFFFFU;
2487 
2488  if(hsai->ErrorCode != HAL_SAI_ERROR_WCKCFG)
2489  {
2490  /* Disable SAI peripheral */
2491  SAI_Disable(hsai);
2492 
2493  /* Flush the fifo */
2495  }
2496  /* Set the SAI state to ready to be able to start again the process */
2497  hsai->State = HAL_SAI_STATE_READY;
2498 
2499  /* Initialize XferCount */
2500  hsai->XferCount = 0U;
2501 
2502  /* SAI error Callback */
2503 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
2504  hsai->ErrorCallback(hsai);
2505 #else
2506  HAL_SAI_ErrorCallback(hsai);
2507 #endif /* USE_HAL_SAI_REGISTER_CALLBACKS */
2508 }
2509 
2514 #endif /* HAL_SAI_MODULE_ENABLED */
2515 
2523 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
SAI_xCR2_CPL
#define SAI_xCR2_CPL
Definition: stm32f469xx.h:15462
__SAI_HandleTypeDef::mutecallback
SAIcallback mutecallback
Definition: stm32f7xx_hal_sai.h:211
HAL_SAI_DisableRxMuteMode
HAL_StatusTypeDef HAL_SAI_DisableRxMuteMode(SAI_HandleTypeDef *hsai)
IS_SAI_BLOCK_PROTOCOL
#define IS_SAI_BLOCK_PROTOCOL(PROTOCOL)
Definition: stm32f7xx_hal_sai.h:775
SAI_FS_STARTFRAME
#define SAI_FS_STARTFRAME
Definition: stm32f7xx_hal_sai.h:420
SAI_PROTOCOL_DATASIZE_24BIT
#define SAI_PROTOCOL_DATASIZE_24BIT
Definition: stm32f7xx_hal_sai.h:312
assert_param
#define assert_param(expr)
Include module's header file.
Definition: stm32f407/stm32f407g-disc1/Inc/stm32f4xx_hal_conf.h:353
SAI_xCR1_CKSTR
#define SAI_xCR1_CKSTR
Definition: stm32f469xx.h:15397
SAI_InitTypeDef::MonoStereoMode
uint32_t MonoStereoMode
Definition: stm32f7xx_hal_sai.h:105
HAL_SAI_DisableTxMuteMode
HAL_StatusTypeDef HAL_SAI_DisableTxMuteMode(SAI_HandleTypeDef *hsai)
SAI_PCM_LONG
#define SAI_PCM_LONG
Definition: stm32f7xx_hal_sai.h:301
SAI_IT_AFSDET
#define SAI_IT_AFSDET
Definition: stm32f7xx_hal_sai.h:538
HAL_StatusTypeDef
HAL_StatusTypeDef
HAL Status structures definition
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:40
IS_SAI_BLOCK_MUTE_COUNTER
#define IS_SAI_BLOCK_MUTE_COUNTER(COUNTER)
Definition: stm32f7xx_hal_sai.h:803
SAI_FREE_PROTOCOL
#define SAI_FREE_PROTOCOL
Definition: stm32f7xx_hal_sai.h:350
SAI_Block_TypeDef::SLOTR
__IO uint32_t SLOTR
Definition: stm32f469xx.h:853
SAI_xCR2_FTH
#define SAI_xCR2_FTH
Definition: stm32f469xx.h:15432
SAI_InitTypeDef::ClockStrobing
uint32_t ClockStrobing
Definition: stm32f7xx_hal_sai.h:126
SAI_FLAG_MUTEDET
#define SAI_FLAG_MUTEDET
Definition: stm32f7xx_hal_sai.h:548
HAL_SAI_MspInit
void HAL_SAI_MspInit(SAI_HandleTypeDef *hsai)
Definition: stm32h7xx_hal_msp.c:398
SAI_InitTypeDef::Mckdiv
uint32_t Mckdiv
Definition: stm32f7xx_hal_sai.h:100
HAL_SAI_DMAStop
HAL_StatusTypeDef HAL_SAI_DMAStop(SAI_HandleTypeDef *hsai)
SAI_xCR1_OUTDRIV
#define SAI_xCR1_OUTDRIV
Definition: stm32f469xx.h:15410
SAI_CLOCKSTROBING_FALLINGEDGE
#define SAI_CLOCKSTROBING_FALLINGEDGE
Definition: stm32f7xx_hal_sai.h:382
SAI_IT_CNRDY
#define SAI_IT_CNRDY
Definition: stm32f7xx_hal_sai.h:537
SAI_InitTypeDef::CompandingMode
uint32_t CompandingMode
Definition: stm32f7xx_hal_sai.h:108
SAI_xCR1_SYNCEN
#define SAI_xCR1_SYNCEN
Definition: stm32f469xx.h:15401
HAL_RCCEx_GetPeriphCLKFreq
uint32_t HAL_RCCEx_GetPeriphCLKFreq(uint32_t PeriphClk)
SAI_FLAG_CNRDY
#define SAI_FLAG_CNRDY
Definition: stm32f7xx_hal_sai.h:551
SAI_GCR_SYNCIN_0
#define SAI_GCR_SYNCIN_0
Definition: stm32f469xx.h:15363
SAI_FLAG_LFSDET
#define SAI_FLAG_LFSDET
Definition: stm32f7xx_hal_sai.h:553
__DMA_HandleTypeDef::XferHalfCpltCallback
void(* XferHalfCpltCallback)(struct __DMA_HandleTypeDef *hdma)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:153
SAI_xCR2_MUTE
#define SAI_xCR2_MUTE
Definition: stm32f469xx.h:15445
SAI_FrameInitTypeDef::ActiveFrameLength
uint32_t ActiveFrameLength
Definition: stm32f7xx_hal_sai.h:146
__DMA_HandleTypeDef
DMA handle Structure definition.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:139
NULL
#define NULL
Definition: porcupine/demo/c/dr_libs/tests/external/miniaudio/extras/speex_resampler/thirdparty/resample.c:92
__SAI_HandleTypeDef::hdmatx
DMA_HandleTypeDef * hdmatx
Definition: stm32f7xx_hal_sai.h:207
HAL_SAI_DMAPause
HAL_StatusTypeDef HAL_SAI_DMAPause(SAI_HandleTypeDef *hsai)
SAI_xCR1_DMAEN
#define SAI_xCR1_DMAEN
Definition: stm32f469xx.h:15416
SAI_GCR_SYNCOUT_1
#define SAI_GCR_SYNCOUT_1
Definition: stm32f469xx.h:15370
IS_SAI_BLOCK_COMPANDING_MODE
#define IS_SAI_BLOCK_COMPANDING_MODE(MODE)
Definition: stm32f7xx_hal_sai.h:808
__SAI_HandleTypeDef::ErrorCode
__IO uint32_t ErrorCode
Definition: stm32f7xx_hal_sai.h:219
SAI_xCR1_SYNCEN_0
#define SAI_xCR1_SYNCEN_0
Definition: stm32f469xx.h:15402
HAL_UNLOCKED
@ HAL_UNLOCKED
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:53
IS_SAI_BLOCK_FRAME_LENGTH
#define IS_SAI_BLOCK_FRAME_LENGTH(LENGTH)
Definition: stm32f7xx_hal_sai.h:847
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_FIFOSTATUS_FULL
#define SAI_FIFOSTATUS_FULL
Definition: stm32f7xx_hal_sai.h:566
__DMA_HandleTypeDef::ErrorCode
__IO uint32_t ErrorCode
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:163
HAL_DMA_Abort_IT
HAL_StatusTypeDef HAL_DMA_Abort_IT(DMA_HandleTypeDef *hdma)
HAL_SAI_DeInit
HAL_StatusTypeDef HAL_SAI_DeInit(SAI_HandleTypeDef *hsai)
__SAI_HandleTypeDef::pBuffPtr
uint8_t * pBuffPtr
Definition: stm32f7xx_hal_sai.h:201
IS_SAI_BLOCK_SLOT_SIZE
#define IS_SAI_BLOCK_SLOT_SIZE(SIZE)
Definition: stm32f7xx_hal_sai.h:830
SAI_IT_OVRUDR
#define SAI_IT_OVRUDR
Definition: stm32f7xx_hal_sai.h:533
HAL_SAI_ERROR_WCKCFG
#define HAL_SAI_ERROR_WCKCFG
Definition: stm32f7xx_hal_sai.h:275
HAL_SAI_ERROR_TIMEOUT
#define HAL_SAI_ERROR_TIMEOUT
Definition: stm32f7xx_hal_sai.h:276
SAI_Block_TypeDef::SR
__IO uint32_t SR
Definition: stm32f469xx.h:855
SAI_PCM_SHORT
#define SAI_PCM_SHORT
Definition: stm32f7xx_hal_sai.h:302
SAI_Block_TypeDef::IMR
__IO uint32_t IMR
Definition: stm32f469xx.h:854
SAI_IT_LFSDET
#define SAI_IT_LFSDET
Definition: stm32f7xx_hal_sai.h:539
IS_SAI_SLOT_ACTIVE
#define IS_SAI_SLOT_ACTIVE(ACTIVE)
Definition: stm32f7xx_hal_sai.h:826
SAI_xCR2_MUTECNT_Pos
#define SAI_xCR2_MUTECNT_Pos
Definition: stm32f469xx.h:15450
IS_SAI_AUDIO_FREQUENCY
#define IS_SAI_AUDIO_FREQUENCY(AUDIO)
Definition: stm32f7xx_hal_sai.h:764
SAI_SYNCEXT_DISABLE
#define SAI_SYNCEXT_DISABLE
Definition: stm32f7xx_hal_sai.h:288
__DMA_HandleTypeDef::XferAbortCallback
void(* XferAbortCallback)(struct __DMA_HandleTypeDef *hdma)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:161
HAL_DMA_ERROR_NO_XFER
#define HAL_DMA_ERROR_NO_XFER
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:192
HAL_SAI_GetState
HAL_SAI_StateTypeDef HAL_SAI_GetState(SAI_HandleTypeDef *hsai)
SAI_FS_CHANNEL_IDENTIFICATION
#define SAI_FS_CHANNEL_IDENTIFICATION
Definition: stm32f7xx_hal_sai.h:421
SAI_InitTypeDef::Protocol
uint32_t Protocol
Definition: stm32f7xx_hal_sai.h:117
__DMA_HandleTypeDef::Init
DMA_InitTypeDef Init
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:143
HAL_ERROR
@ HAL_ERROR
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:43
__SAI_HandleTypeDef::State
__IO HAL_SAI_StateTypeDef State
Definition: stm32f7xx_hal_sai.h:217
CLEAR_BIT
#define CLEAR_BIT(REG, BIT)
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:214
HAL_GetTick
uint32_t HAL_GetTick(void)
Provides a tick value in millisecond.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:323
HAL_SAI_STATE_READY
@ HAL_SAI_STATE_READY
Definition: stm32f7xx_hal_sai.h:51
SAI_xSR_FREQ
#define SAI_xSR_FREQ
Definition: stm32f469xx.h:15569
DMA_CIRCULAR
#define DMA_CIRCULAR
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:282
HAL_SAI_Receive
HAL_StatusTypeDef HAL_SAI_Receive(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size, uint32_t Timeout)
SAI_SlotInitTypeDef::SlotNumber
uint32_t SlotNumber
Definition: stm32f7xx_hal_sai.h:177
SAI_xFRCR_FSDEF
#define SAI_xFRCR_FSDEF
Definition: stm32f469xx.h:15496
HAL_SAI_ERROR_AFSDET
#define HAL_SAI_ERROR_AFSDET
Definition: stm32f7xx_hal_sai.h:272
HAL_SAI_IRQHandler
void HAL_SAI_IRQHandler(SAI_HandleTypeDef *hsai)
IS_SAI_BLOCK_FIRST_BIT
#define IS_SAI_BLOCK_FIRST_BIT(BIT)
Definition: stm32f7xx_hal_sai.h:786
__SAI_HandleTypeDef::hdmarx
DMA_HandleTypeDef * hdmarx
Definition: stm32f7xx_hal_sai.h:209
__SAI_HandleTypeDef::Instance
SAI_Block_TypeDef * Instance
Definition: stm32f7xx_hal_sai.h:193
__SAI_HandleTypeDef::XferSize
uint16_t XferSize
Definition: stm32f7xx_hal_sai.h:203
IS_SAI_ALL_INSTANCE
#define IS_SAI_ALL_INSTANCE(PERIPH)
Definition: stm32f469xx.h:19803
SAI_InitTypeDef::FIFOThreshold
uint32_t FIFOThreshold
Definition: stm32f7xx_hal_sai.h:94
SAI_xCR1_MCKDIV
#define SAI_xCR1_MCKDIV
Definition: stm32f469xx.h:15423
SAI_IT_MUTEDET
#define SAI_IT_MUTEDET
Definition: stm32f7xx_hal_sai.h:534
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
SAI1_Block_A
#define SAI1_Block_A
Definition: stm32f469xx.h:1334
HAL_SAI_ERROR_DMA
#define HAL_SAI_ERROR_DMA
Definition: stm32f7xx_hal_sai.h:277
HAL_OK
@ HAL_OK
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:42
SAI1
#define SAI1
Definition: MIMXRT1052.h:20666
SAI_FrameInitTypeDef::FSOffset
uint32_t FSOffset
Definition: stm32f7xx_hal_sai.h:157
IS_SAI_BLOCK_NODIVIDER
#define IS_SAI_BLOCK_NODIVIDER(NODIVIDER)
Definition: stm32f7xx_hal_sai.h:800
SAI_xFRCR_FSOFF
#define SAI_xFRCR_FSOFF
Definition: stm32f469xx.h:15502
SAI_InitTypeDef::Synchro
uint32_t Synchro
Definition: stm32f7xx_hal_sai.h:71
IS_SAI_BLOCK_MUTE_VALUE
#define IS_SAI_BLOCK_MUTE_VALUE(VALUE)
Definition: stm32f7xx_hal_sai.h:805
SAI_SYNCHRONOUS
#define SAI_SYNCHRONOUS
Definition: stm32f7xx_hal_sai.h:392
HAL_SAI_ERROR_UDR
#define HAL_SAI_ERROR_UDR
Definition: stm32f7xx_hal_sai.h:271
SAI_SLOTSIZE_32B
#define SAI_SLOTSIZE_32B
Definition: stm32f7xx_hal_sai.h:449
SAI_xCR1_SAIEN
#define SAI_xCR1_SAIEN
Definition: stm32f469xx.h:15413
HAL_SAI_STATE_BUSY_RX
@ HAL_SAI_STATE_BUSY_RX
Definition: stm32f7xx_hal_sai.h:54
UNUSED
#define UNUSED(x)
Definition: porcupine/demo/c/dr_libs/old/dr.h:92
__HAL_SAI_CLEAR_FLAG
#define __HAL_SAI_CLEAR_FLAG(__HANDLE__, __FLAG__)
Clear the specified SAI pending flag.
Definition: stm32f7xx_hal_sai.h:655
SAI2_Block_B
#define SAI2_Block_B
Definition: stm32f769xx.h:1612
SAI_FLAG_OVRUDR
#define SAI_FLAG_OVRUDR
Definition: stm32f7xx_hal_sai.h:547
SAI_xCR2_FFLUSH
#define SAI_xCR2_FFLUSH
Definition: stm32f469xx.h:15439
SAI_DATASIZE_32
#define SAI_DATASIZE_32
Definition: stm32f7xx_hal_sai.h:365
SAI_DATASIZE_8
#define SAI_DATASIZE_8
Definition: stm32f7xx_hal_sai.h:360
IS_SAI_BLOCK_SYNCEXT
#define IS_SAI_BLOCK_SYNCEXT(STATE)
Definition: stm32f7xx_hal_sai.h:749
HAL_SAI_InitProtocol
HAL_StatusTypeDef HAL_SAI_InitProtocol(SAI_HandleTypeDef *hsai, uint32_t protocol, uint32_t datasize, uint32_t nbslot)
SAI_FLAG_AFSDET
#define SAI_FLAG_AFSDET
Definition: stm32f7xx_hal_sai.h:552
__SAI_HandleTypeDef::Init
SAI_InitTypeDef Init
Definition: stm32f7xx_hal_sai.h:195
IS_SAI_BLOCK_FIFO_THRESHOLD
#define IS_SAI_BLOCK_FIFO_THRESHOLD(THRESHOLD)
Definition: stm32f7xx_hal_sai.h:814
SAI_AC97_PROTOCOL
#define SAI_AC97_PROTOCOL
Definition: stm32f7xx_hal_sai.h:352
IS_SAI_PROTOCOL_DATASIZE
#define IS_SAI_PROTOCOL_DATASIZE(DATASIZE)
Definition: stm32f7xx_hal_sai.h:759
__SAI_HandleTypeDef
Definition: stm32f7xx_hal_sai.h:191
__SAI_HandleTypeDef::Lock
HAL_LockTypeDef Lock
Definition: stm32f7xx_hal_sai.h:215
HAL_SAI_RxHalfCpltCallback
void HAL_SAI_RxHalfCpltCallback(SAI_HandleTypeDef *hsai)
Half reception complete callback.
Definition: stm32f769i_discovery_audio.c:1593
SAI_InitTypeDef::OutputDrive
uint32_t OutputDrive
Definition: stm32f7xx_hal_sai.h:80
HAL_SAI_ERROR_LFSDET
#define HAL_SAI_ERROR_LFSDET
Definition: stm32f7xx_hal_sai.h:273
IS_SAI_BLOCK_CLOCK_STROBING
#define IS_SAI_BLOCK_CLOCK_STROBING(CLOCK)
Definition: stm32f7xx_hal_sai.h:789
__HAL_LOCK
#define __HAL_LOCK(__HANDLE__)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:93
SAI_NOCOMPANDING
#define SAI_NOCOMPANDING
Definition: stm32f7xx_hal_sai.h:512
SAI_xSLOTR_FBOFF
#define SAI_xSLOTR_FBOFF
Definition: stm32f469xx.h:15509
SAI_InitTypeDef::NoDivider
uint32_t NoDivider
Definition: stm32f7xx_hal_sai.h:85
HAL_SAI_ERROR_OVR
#define HAL_SAI_ERROR_OVR
Definition: stm32f7xx_hal_sai.h:270
HAL_SAI_GetError
uint32_t HAL_SAI_GetError(SAI_HandleTypeDef *hsai)
SAI_AUDIO_FREQUENCY_MCKDIV
#define SAI_AUDIO_FREQUENCY_MCKDIV
Definition: stm32f7xx_hal_sai.h:330
HAL_SAI_DMAResume
HAL_StatusTypeDef HAL_SAI_DMAResume(SAI_HandleTypeDef *hsai)
SystemCoreClock
uint32_t SystemCoreClock
Definition: system_MIMXRT1052.c:69
__SAI_HandleTypeDef::XferCount
uint16_t XferCount
Definition: stm32f7xx_hal_sai.h:205
HAL_SAI_RxCpltCallback
void HAL_SAI_RxCpltCallback(SAI_HandleTypeDef *hsai)
Reception complete callback.
Definition: stm32f769i_discovery_audio.c:1605
IS_SAI_BLOCK_FIRSTBIT_OFFSET
#define IS_SAI_BLOCK_FIRSTBIT_OFFSET(OFFSET)
Definition: stm32f7xx_hal_sai.h:834
SAI_I2S_MSBJUSTIFIED
#define SAI_I2S_MSBJUSTIFIED
Definition: stm32f7xx_hal_sai.h:299
HAL_SAI_Transmit_IT
HAL_StatusTypeDef HAL_SAI_Transmit_IT(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size)
RESET
@ RESET
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:187
count
size_t count
Definition: porcupine/demo/c/dr_libs/tests/external/miniaudio/tests/test_common/ma_test_common.c:31
SAI_MODESLAVE_RX
#define SAI_MODESLAVE_RX
Definition: stm32f7xx_hal_sai.h:341
SAI_SLOTACTIVE_ALL
#define SAI_SLOTACTIVE_ALL
Definition: stm32f7xx_hal_sai.h:474
HAL_SAI_ErrorCallback
void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai)
SAI error callbacks.
Definition: stm32469i_discovery_audio.c:628
HAL_BUSY
@ HAL_BUSY
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:44
HAL_DMA_Start_IT
HAL_StatusTypeDef HAL_DMA_Start_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength)
SAI_FS_FIRSTBIT
#define SAI_FS_FIRSTBIT
Definition: stm32f7xx_hal_sai.h:438
IS_SAI_BLOCK_FS_DEFINITION
#define IS_SAI_BLOCK_FS_DEFINITION(DEFINITION)
Definition: stm32f7xx_hal_sai.h:842
HAL_SAI_TxHalfCpltCallback
void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai)
Tx Half Transfer completed callbacks.
Definition: stm32469i_discovery_audio.c:617
SAI2_Block_A
#define SAI2_Block_A
Definition: stm32f769xx.h:1611
HAL_SAI_EnableTxMuteMode
HAL_StatusTypeDef HAL_SAI_EnableTxMuteMode(SAI_HandleTypeDef *hsai, uint16_t val)
SAI_InitTypeDef::TriState
uint32_t TriState
Definition: stm32f7xx_hal_sai.h:111
RCC_PERIPHCLK_SAI2
#define RCC_PERIPHCLK_SAI2
Definition: stm32f7xx_hal_rcc_ex.h:257
__HAL_UNLOCK
#define __HAL_UNLOCK(__HANDLE__)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:105
IS_SAI_BLOCK_MASTER_DIVIDER
#define IS_SAI_BLOCK_MASTER_DIVIDER(DIVIDER)
Definition: stm32f7xx_hal_sai.h:845
__HAL_SAI_ENABLE_IT
#define __HAL_SAI_ENABLE_IT(__HANDLE__, __INTERRUPT__)
Enable or disable the specified SAI interrupts.
Definition: stm32f7xx_hal_sai.h:608
SAI_IT_WCKCFG
#define SAI_IT_WCKCFG
Definition: stm32f7xx_hal_sai.h:535
__HAL_SAI_DISABLE
#define __HAL_SAI_DISABLE(__HANDLE__)
Definition: stm32f7xx_hal_sai.h:658
HAL_MAX_DELAY
#define HAL_MAX_DELAY
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:61
SAI_xCR2_COMP
#define SAI_xCR2_COMP
Definition: stm32f469xx.h:15466
SAI_xCR1_MODE
#define SAI_xCR1_MODE
Definition: stm32f469xx.h:15375
SAI_MODEMASTER_TX
#define SAI_MODEMASTER_TX
Definition: stm32f7xx_hal_sai.h:338
HAL_DMA_Abort
HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma)
__SAI_HandleTypeDef::InterruptServiceRoutine
void(* InterruptServiceRoutine)(struct __SAI_HandleTypeDef *hsai)
Definition: stm32f7xx_hal_sai.h:213
SAI_InitTypeDef::DataSize
uint32_t DataSize
Definition: stm32f7xx_hal_sai.h:120
IS_SAI_BLOCK_FS_OFFSET
#define IS_SAI_BLOCK_FS_OFFSET(OFFSET)
Definition: stm32f7xx_hal_sai.h:836
SAI_xCR2_MUTEVAL
#define SAI_xCR2_MUTEVAL
Definition: stm32f469xx.h:15448
SAI_IT_FREQ
#define SAI_IT_FREQ
Definition: stm32f7xx_hal_sai.h:536
SAI_I2S_LSBJUSTIFIED
#define SAI_I2S_LSBJUSTIFIED
Definition: stm32f7xx_hal_sai.h:300
SAI_DATASIZE_24
#define SAI_DATASIZE_24
Definition: stm32f7xx_hal_sai.h:364
SAI_xCR2_MUTECNT
#define SAI_xCR2_MUTECNT
Definition: stm32f469xx.h:15452
SAI_SlotInitTypeDef::SlotSize
uint32_t SlotSize
Definition: stm32f7xx_hal_sai.h:174
IS_SAI_BLOCK_MODE
#define IS_SAI_BLOCK_MODE(MODE)
Definition: stm32f7xx_hal_sai.h:770
HAL_SAI_Transmit
HAL_StatusTypeDef HAL_SAI_Transmit(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size, uint32_t Timeout)
IS_SAI_SUPPORTED_PROTOCOL
#define IS_SAI_SUPPORTED_PROTOCOL(PROTOCOL)
Definition: stm32f7xx_hal_sai.h:753
SAI_SYNCHRONOUS_EXT_SAI2
#define SAI_SYNCHRONOUS_EXT_SAI2
Definition: stm32f7xx_hal_sai.h:394
SAI_SYNCEXT_OUTBLOCKA_ENABLE
#define SAI_SYNCEXT_OUTBLOCKA_ENABLE
Definition: stm32f7xx_hal_sai.h:289
SAI_SlotInitTypeDef::SlotActive
uint32_t SlotActive
Definition: stm32f7xx_hal_sai.h:180
HAL_SAI_TxCpltCallback
void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai)
Tx Transfer completed callbacks.
Definition: stm32469i_discovery_audio.c:606
__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
SAI_Block_TypeDef::CR2
__IO uint32_t CR2
Definition: stm32f469xx.h:851
SAI_SlotInitTypeDef::FirstBitOffset
uint32_t FirstBitOffset
Definition: stm32f7xx_hal_sai.h:171
HAL_TIMEOUT
@ HAL_TIMEOUT
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:45
HAL_SAI_Receive_DMA
HAL_StatusTypeDef HAL_SAI_Receive_DMA(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size)
SAI_Block_TypeDef::CLRFR
__IO uint32_t CLRFR
Definition: stm32f469xx.h:856
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
SAI_FIFOSTATUS_EMPTY
#define SAI_FIFOSTATUS_EMPTY
Definition: stm32f7xx_hal_sai.h:561
HAL_SAI_STATE_BUSY_TX
@ HAL_SAI_STATE_BUSY_TX
Definition: stm32f7xx_hal_sai.h:53
SAI_FrameInitTypeDef::FSPolarity
uint32_t FSPolarity
Definition: stm32f7xx_hal_sai.h:154
__DMA_HandleTypeDef::XferCpltCallback
void(* XferCpltCallback)(struct __DMA_HandleTypeDef *hdma)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:151
SAI_xFRCR_FSALL
#define SAI_xFRCR_FSALL
Definition: stm32f469xx.h:15485
SAI_FLAG_WCKCFG
#define SAI_FLAG_WCKCFG
Definition: stm32f7xx_hal_sai.h:549
IS_SAI_BLOCK_DATASIZE
#define IS_SAI_BLOCK_DATASIZE(DATASIZE)
Definition: stm32f7xx_hal_sai.h:779
HAL_SAI_StateTypeDef
HAL_SAI_StateTypeDef
HAL State structures definition.
Definition: stm32f7xx_hal_sai.h:48
HAL_DMA_ERROR_TE
#define HAL_DMA_ERROR_TE
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:187
IS_SAI_BLOCK_ACTIVE_FRAME
#define IS_SAI_BLOCK_ACTIVE_FRAME(LENGTH)
Definition: stm32f7xx_hal_sai.h:849
SAI_FS_ACTIVE_LOW
#define SAI_FS_ACTIVE_LOW
Definition: stm32f7xx_hal_sai.h:429
SAI_ASYNCHRONOUS
#define SAI_ASYNCHRONOUS
Definition: stm32f7xx_hal_sai.h:391
HAL_SAI_ERROR_CNREADY
#define HAL_SAI_ERROR_CNREADY
Definition: stm32f7xx_hal_sai.h:274
HAL_SAI_Init
HAL_StatusTypeDef HAL_SAI_Init(SAI_HandleTypeDef *hsai)
SAI_xSR_FLVL
#define SAI_xSR_FLVL
Definition: stm32f469xx.h:15582
SAI_PROTOCOL_DATASIZE_32BIT
#define SAI_PROTOCOL_DATASIZE_32BIT
Definition: stm32f7xx_hal_sai.h:313
HAL_SAI_STATE_BUSY
@ HAL_SAI_STATE_BUSY
Definition: stm32f7xx_hal_sai.h:52
IS_SAI_MONO_STEREO_MODE
#define IS_SAI_MONO_STEREO_MODE(MODE)
Definition: stm32f7xx_hal_sai.h:823
SAI_xCR1_SYNCEN_1
#define SAI_xCR1_SYNCEN_1
Definition: stm32f469xx.h:15403
SAI_PROTOCOL_DATASIZE_16BITEXTENDED
#define SAI_PROTOCOL_DATASIZE_16BITEXTENDED
Definition: stm32f7xx_hal_sai.h:311
SAI_Block_TypeDef::FRCR
__IO uint32_t FRCR
Definition: stm32f469xx.h:852
SAI_xCR1_PRTCFG
#define SAI_xCR1_PRTCFG
Definition: stm32f469xx.h:15381
HAL_SAI_Receive_IT
HAL_StatusTypeDef HAL_SAI_Receive_IT(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size)
SAI_InitTypeDef::AudioMode
uint32_t AudioMode
Definition: stm32f7xx_hal_sai.h:68
DMA_InitTypeDef::Mode
uint32_t Mode
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:70
IS_SAI_BLOCK_SYNCHRO
#define IS_SAI_BLOCK_SYNCHRO(SYNCHRO)
Definition: stm32f7xx_hal_sai.h:792
SET_BIT
#define SET_BIT(REG, BIT)
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:212
SAI_Block_TypeDef::DR
__IO uint32_t DR
Definition: stm32f469xx.h:857
IS_SAI_BLOCK_TRISTATE_MANAGEMENT
#define IS_SAI_BLOCK_TRISTATE_MANAGEMENT(STATE)
Definition: stm32f7xx_hal_sai.h:820
IS_SAI_BLOCK_FS_POLARITY
#define IS_SAI_BLOCK_FS_POLARITY(POLARITY)
Definition: stm32f7xx_hal_sai.h:839
SAI_SYNCHRONOUS_EXT_SAI1
#define SAI_SYNCHRONOUS_EXT_SAI1
Definition: stm32f7xx_hal_sai.h:393
IS_SAI_BLOCK_OUTPUT_DRIVE
#define IS_SAI_BLOCK_OUTPUT_DRIVE(DRIVE)
Definition: stm32f7xx_hal_sai.h:797
SAI_CLOCKSTROBING_RISINGEDGE
#define SAI_CLOCKSTROBING_RISINGEDGE
Definition: stm32f7xx_hal_sai.h:383
__HAL_SAI_DISABLE_IT
#define __HAL_SAI_DISABLE_IT(__HANDLE__, __INTERRUPT__)
Definition: stm32f7xx_hal_sai.h:609
SAI_FrameInitTypeDef::FrameLength
uint32_t FrameLength
Definition: stm32f7xx_hal_sai.h:140
SAI1_Block_B
#define SAI1_Block_B
Definition: stm32f469xx.h:1335
HAL_SAI_STATE_RESET
@ HAL_SAI_STATE_RESET
Definition: stm32f7xx_hal_sai.h:50
SAIcallback
void(* SAIcallback)(void)
SAI Callback prototype.
Definition: stm32f7xx_hal_sai.h:60
SAI2
#define SAI2
Definition: MIMXRT1052.h:20670
HAL_SAI_MspDeInit
void HAL_SAI_MspDeInit(SAI_HandleTypeDef *hsai)
Definition: stm32h7xx_hal_msp.c:456
HAL_SAI_Abort
HAL_StatusTypeDef HAL_SAI_Abort(SAI_HandleTypeDef *hsai)
SAI_xSLOTR_SLOTSZ
#define SAI_xSLOTR_SLOTSZ
Definition: stm32f469xx.h:15518
SAI_FS_ACTIVE_HIGH
#define SAI_FS_ACTIVE_HIGH
Definition: stm32f7xx_hal_sai.h:430
SAI_I2S_STANDARD
#define SAI_I2S_STANDARD
Definition: stm32f7xx_hal_sai.h:298
__SAI_HandleTypeDef::SlotInit
SAI_SlotInitTypeDef SlotInit
Definition: stm32f7xx_hal_sai.h:199
IS_SAI_BLOCK_SLOT_NUMBER
#define IS_SAI_BLOCK_SLOT_NUMBER(NUMBER)
Definition: stm32f7xx_hal_sai.h:828
__SAI_HandleTypeDef::FrameInit
SAI_FrameInitTypeDef FrameInit
Definition: stm32f7xx_hal_sai.h:197
SAI_GCR_SYNCOUT_0
#define SAI_GCR_SYNCOUT_0
Definition: stm32f469xx.h:15369
SAI_xCR1_DS
#define SAI_xCR1_DS
Definition: stm32f469xx.h:15387
SAI_FS_BEFOREFIRSTBIT
#define SAI_FS_BEFOREFIRSTBIT
Definition: stm32f7xx_hal_sai.h:439
SAI_MODESLAVE_TX
#define SAI_MODESLAVE_TX
Definition: stm32f7xx_hal_sai.h:340
HAL_SAI_ERROR_NONE
#define HAL_SAI_ERROR_NONE
Definition: stm32f7xx_hal_sai.h:269
SAI_xSLOTR_SLOTEN
#define SAI_xSLOTR_SLOTEN
Definition: stm32f469xx.h:15532
SAI_xFRCR_FRL
#define SAI_xFRCR_FRL
Definition: stm32f469xx.h:15473
SAI_InitTypeDef::FirstBit
uint32_t FirstBit
Definition: stm32f7xx_hal_sai.h:123
stm32f7xx_hal.h
This file contains all the functions prototypes for the HAL module driver.
SAI_SLOTSIZE_16B
#define SAI_SLOTSIZE_16B
Definition: stm32f7xx_hal_sai.h:448
SAI_SYNCEXT_OUTBLOCKB_ENABLE
#define SAI_SYNCEXT_OUTBLOCKB_ENABLE
Definition: stm32f7xx_hal_sai.h:290
HAL_SAI_Transmit_DMA
HAL_StatusTypeDef HAL_SAI_Transmit_DMA(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size)
__DMA_HandleTypeDef::XferErrorCallback
void(* XferErrorCallback)(struct __DMA_HandleTypeDef *hdma)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:159
HAL_SAI_EnableRxMuteMode
HAL_StatusTypeDef HAL_SAI_EnableRxMuteMode(SAI_HandleTypeDef *hsai, SAIcallback callback, uint16_t counter)
SAI_Block_TypeDef::CR1
__IO uint32_t CR1
Definition: stm32f469xx.h:850
SAI_PROTOCOL_DATASIZE_16BIT
#define SAI_PROTOCOL_DATASIZE_16BIT
Definition: stm32f7xx_hal_sai.h:310


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