stm32f469/stm32f469i-disco/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2s.c
Go to the documentation of this file.
1 
186 /* Includes ------------------------------------------------------------------*/
187 #include "stm32f4xx_hal.h"
188 
189 #ifdef HAL_I2S_MODULE_ENABLED
190 
200 /* Private typedef -----------------------------------------------------------*/
201 /* Private define ------------------------------------------------------------*/
202 #define I2S_TIMEOUT_FLAG 100U
203 /* Private macro -------------------------------------------------------------*/
204 /* Private variables ---------------------------------------------------------*/
205 /* Private function prototypes -----------------------------------------------*/
209 static void I2S_DMATxCplt(DMA_HandleTypeDef *hdma);
210 static void I2S_DMATxHalfCplt(DMA_HandleTypeDef *hdma);
211 static void I2S_DMARxCplt(DMA_HandleTypeDef *hdma);
212 static void I2S_DMARxHalfCplt(DMA_HandleTypeDef *hdma);
213 static void I2S_DMAError(DMA_HandleTypeDef *hdma);
214 static void I2S_Transmit_IT(I2S_HandleTypeDef *hi2s);
215 static void I2S_Receive_IT(I2S_HandleTypeDef *hi2s);
216 static void I2S_IRQHandler(I2S_HandleTypeDef *hi2s);
217 static HAL_StatusTypeDef I2S_WaitFlagStateUntilTimeout(I2S_HandleTypeDef *hi2s, uint32_t Flag, FlagStatus State,
218  uint32_t Timeout);
223 /* Exported functions ---------------------------------------------------------*/
224 
266 {
267  uint32_t i2sdiv;
268  uint32_t i2sodd;
269  uint32_t packetlength;
270  uint32_t tmp;
271  uint32_t i2sclk;
272 #if defined (SPI_I2S_FULLDUPLEX_SUPPORT)
273  uint16_t tmpreg;
274 #endif
275 
276  /* Check the I2S handle allocation */
277  if (hi2s == NULL)
278  {
279  return HAL_ERROR;
280  }
281 
282  /* Check the I2S parameters */
291 
292  if (hi2s->State == HAL_I2S_STATE_RESET)
293  {
294  /* Allocate lock resource and initialize it */
295  hi2s->Lock = HAL_UNLOCKED;
296 
297  /* Initialize Default I2S IrqHandler ISR */
298  hi2s->IrqHandlerISR = I2S_IRQHandler;
299 
300 #if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U)
301  /* Init the I2S Callback settings */
302  hi2s->TxCpltCallback = HAL_I2S_TxCpltCallback; /* Legacy weak TxCpltCallback */
303  hi2s->RxCpltCallback = HAL_I2S_RxCpltCallback; /* Legacy weak RxCpltCallback */
304 #if defined (SPI_I2S_FULLDUPLEX_SUPPORT)
305  hi2s->TxRxCpltCallback = HAL_I2SEx_TxRxCpltCallback; /* Legacy weak TxRxCpltCallback */
306 #endif
307  hi2s->TxHalfCpltCallback = HAL_I2S_TxHalfCpltCallback; /* Legacy weak TxHalfCpltCallback */
308  hi2s->RxHalfCpltCallback = HAL_I2S_RxHalfCpltCallback; /* Legacy weak RxHalfCpltCallback */
309 #if defined (SPI_I2S_FULLDUPLEX_SUPPORT)
310  hi2s->TxRxHalfCpltCallback = HAL_I2SEx_TxRxHalfCpltCallback; /* Legacy weak TxRxHalfCpltCallback */
311 #endif
312  hi2s->ErrorCallback = HAL_I2S_ErrorCallback; /* Legacy weak ErrorCallback */
313 
314  if (hi2s->MspInitCallback == NULL)
315  {
316  hi2s->MspInitCallback = HAL_I2S_MspInit; /* Legacy weak MspInit */
317  }
318 
319  /* Init the low level hardware : GPIO, CLOCK, NVIC... */
320  hi2s->MspInitCallback(hi2s);
321 #else
322  /* Init the low level hardware : GPIO, CLOCK, CORTEX...etc */
323  HAL_I2S_MspInit(hi2s);
324 #endif /* USE_HAL_I2S_REGISTER_CALLBACKS */
325  }
326 
327  hi2s->State = HAL_I2S_STATE_BUSY;
328 
329  /*----------------------- SPIx I2SCFGR & I2SPR Configuration ----------------*/
330  /* Clear I2SMOD, I2SE, I2SCFG, PCMSYNC, I2SSTD, CKPOL, DATLEN and CHLEN bits */
334  hi2s->Instance->I2SPR = 0x0002U;
335 
336  /*----------------------- I2SPR: I2SDIV and ODD Calculation -----------------*/
337  /* If the requested audio frequency is not the default, compute the prescaler */
338  if (hi2s->Init.AudioFreq != I2S_AUDIOFREQ_DEFAULT)
339  {
340  /* Check the frame length (For the Prescaler computing) ********************/
341  if (hi2s->Init.DataFormat == I2S_DATAFORMAT_16B)
342  {
343  /* Packet length is 16 bits */
344  packetlength = 16U;
345  }
346  else
347  {
348  /* Packet length is 32 bits */
349  packetlength = 32U;
350  }
351 
352  /* I2S standard */
353  if (hi2s->Init.Standard <= I2S_STANDARD_LSB)
354  {
355  /* In I2S standard packet lenght is multiplied by 2 */
356  packetlength = packetlength * 2U;
357  }
358 
359  /* Get the source clock value **********************************************/
360 #if defined(I2S_APB1_APB2_FEATURE)
361  if (IS_I2S_APB1_INSTANCE(hi2s->Instance))
362  {
363  i2sclk = HAL_RCCEx_GetPeriphCLKFreq(RCC_PERIPHCLK_I2S_APB1);
364  }
365  else
366  {
367  i2sclk = HAL_RCCEx_GetPeriphCLKFreq(RCC_PERIPHCLK_I2S_APB2);
368  }
369 #else
371 #endif
372 
373  /* Compute the Real divider depending on the MCLK output state, with a floating point */
375  {
376  /* MCLK output is enabled */
377  if (hi2s->Init.DataFormat != I2S_DATAFORMAT_16B)
378  {
379  tmp = (uint32_t)(((((i2sclk / (packetlength * 4U)) * 10U) / hi2s->Init.AudioFreq)) + 5U);
380  }
381  else
382  {
383  tmp = (uint32_t)(((((i2sclk / (packetlength * 8U)) * 10U) / hi2s->Init.AudioFreq)) + 5U);
384  }
385  }
386  else
387  {
388  /* MCLK output is disabled */
389  tmp = (uint32_t)(((((i2sclk / packetlength) * 10U) / hi2s->Init.AudioFreq)) + 5U);
390  }
391 
392  /* Remove the flatting point */
393  tmp = tmp / 10U;
394 
395  /* Check the parity of the divider */
396  i2sodd = (uint32_t)(tmp & (uint32_t)1U);
397 
398  /* Compute the i2sdiv prescaler */
399  i2sdiv = (uint32_t)((tmp - i2sodd) / 2U);
400 
401  /* Get the Mask for the Odd bit (SPI_I2SPR[8]) register */
402  i2sodd = (uint32_t)(i2sodd << 8U);
403  }
404  else
405  {
406  /* Set the default values */
407  i2sdiv = 2U;
408  i2sodd = 0U;
409  }
410 
411  /* Test if the divider is 1 or 0 or greater than 0xFF */
412  if ((i2sdiv < 2U) || (i2sdiv > 0xFFU))
413  {
414  /* Set the error code and execute error callback*/
416  return HAL_ERROR;
417  }
418 
419  /*----------------------- SPIx I2SCFGR & I2SPR Configuration ----------------*/
420 
421  /* Write to SPIx I2SPR register the computed value */
422  hi2s->Instance->I2SPR = (uint32_t)((uint32_t)i2sdiv | (uint32_t)(i2sodd | (uint32_t)hi2s->Init.MCLKOutput));
423 
424  /* Clear I2SMOD, I2SE, I2SCFG, PCMSYNC, I2SSTD, CKPOL, DATLEN and CHLEN bits */
425  /* And configure the I2S with the I2S_InitStruct values */
430  (SPI_I2SCFGR_I2SMOD | hi2s->Init.Mode | \
431  hi2s->Init.Standard | hi2s->Init.DataFormat | \
432  hi2s->Init.CPOL));
433 
434 #if defined(SPI_I2SCFGR_ASTRTEN)
436  {
437  /* Write to SPIx I2SCFGR */
439  }
440 #endif /* SPI_I2SCFGR_ASTRTEN */
441 
442 #if defined (SPI_I2S_FULLDUPLEX_SUPPORT)
443 
444  /* Configure the I2S extended if the full duplex mode is enabled */
446 
448  {
449  /* Set FullDuplex I2S IrqHandler ISR if FULLDUPLEXMODE is enabled */
450  hi2s->IrqHandlerISR = HAL_I2SEx_FullDuplex_IRQHandler;
451 
452  /* Clear I2SMOD, I2SE, I2SCFG, PCMSYNC, I2SSTD, CKPOL, DATLEN and CHLEN bits */
456  I2SxEXT(hi2s->Instance)->I2SPR = 2U;
457 
458  /* Get the I2SCFGR register value */
459  tmpreg = I2SxEXT(hi2s->Instance)->I2SCFGR;
460 
461  /* Get the mode to be configured for the extended I2S */
462  if ((hi2s->Init.Mode == I2S_MODE_MASTER_TX) || (hi2s->Init.Mode == I2S_MODE_SLAVE_TX))
463  {
464  tmp = I2S_MODE_SLAVE_RX;
465  }
466  else /* I2S_MODE_MASTER_RX || I2S_MODE_SLAVE_RX */
467  {
468  tmp = I2S_MODE_SLAVE_TX;
469  }
470 
471  /* Configure the I2S Slave with the I2S Master parameter values */
472  tmpreg |= (uint16_t)((uint16_t)SPI_I2SCFGR_I2SMOD | (uint16_t)(tmp | \
473  (uint16_t)(hi2s->Init.Standard | (uint16_t)(hi2s->Init.DataFormat | \
474  (uint16_t)hi2s->Init.CPOL))));
475 
476  /* Write to SPIx I2SCFGR */
477  WRITE_REG(I2SxEXT(hi2s->Instance)->I2SCFGR, tmpreg);
478  }
479 #endif /* SPI_I2S_FULLDUPLEX_SUPPORT */
480 
482  hi2s->State = HAL_I2S_STATE_READY;
483 
484  return HAL_OK;
485 }
486 
494 {
495  /* Check the I2S handle allocation */
496  if (hi2s == NULL)
497  {
498  return HAL_ERROR;
499  }
500 
501  /* Check the parameters */
503 
504  hi2s->State = HAL_I2S_STATE_BUSY;
505 
506  /* Disable the I2S Peripheral Clock */
507  __HAL_I2S_DISABLE(hi2s);
508 
509 #if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U)
510  if (hi2s->MspDeInitCallback == NULL)
511  {
512  hi2s->MspDeInitCallback = HAL_I2S_MspDeInit; /* Legacy weak MspDeInit */
513  }
514 
515  /* DeInit the low level hardware: GPIO, CLOCK, NVIC... */
516  hi2s->MspDeInitCallback(hi2s);
517 #else
518  /* DeInit the low level hardware: GPIO, CLOCK, NVIC... */
519  HAL_I2S_MspDeInit(hi2s);
520 #endif /* USE_HAL_I2S_REGISTER_CALLBACKS */
521 
523  hi2s->State = HAL_I2S_STATE_RESET;
524 
525  /* Release Lock */
526  __HAL_UNLOCK(hi2s);
527 
528  return HAL_OK;
529 }
530 
537 __weak void HAL_I2S_MspInit(I2S_HandleTypeDef *hi2s)
538 {
539  /* Prevent unused argument(s) compilation warning */
540  UNUSED(hi2s);
541 
542  /* NOTE : This function Should not be modified, when the callback is needed,
543  the HAL_I2S_MspInit could be implemented in the user file
544  */
545 }
546 
553 __weak void HAL_I2S_MspDeInit(I2S_HandleTypeDef *hi2s)
554 {
555  /* Prevent unused argument(s) compilation warning */
556  UNUSED(hi2s);
557 
558  /* NOTE : This function Should not be modified, when the callback is needed,
559  the HAL_I2S_MspDeInit could be implemented in the user file
560  */
561 }
562 
563 #if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U)
564 
573 HAL_StatusTypeDef HAL_I2S_RegisterCallback(I2S_HandleTypeDef *hi2s, HAL_I2S_CallbackIDTypeDef CallbackID,
574  pI2S_CallbackTypeDef pCallback)
575 {
576  HAL_StatusTypeDef status = HAL_OK;
577 
578  if (pCallback == NULL)
579  {
580  /* Update the error code */
581  hi2s->ErrorCode |= HAL_I2S_ERROR_INVALID_CALLBACK;
582 
583  return HAL_ERROR;
584  }
585  /* Process locked */
586  __HAL_LOCK(hi2s);
587 
588  if (HAL_I2S_STATE_READY == hi2s->State)
589  {
590  switch (CallbackID)
591  {
592  case HAL_I2S_TX_COMPLETE_CB_ID :
593  hi2s->TxCpltCallback = pCallback;
594  break;
595 
596  case HAL_I2S_RX_COMPLETE_CB_ID :
597  hi2s->RxCpltCallback = pCallback;
598  break;
599 
600 #if defined (SPI_I2S_FULLDUPLEX_SUPPORT)
601  case HAL_I2S_TX_RX_COMPLETE_CB_ID :
602  hi2s->TxRxCpltCallback = pCallback;
603  break;
604 #endif
605 
606  case HAL_I2S_TX_HALF_COMPLETE_CB_ID :
607  hi2s->TxHalfCpltCallback = pCallback;
608  break;
609 
610  case HAL_I2S_RX_HALF_COMPLETE_CB_ID :
611  hi2s->RxHalfCpltCallback = pCallback;
612  break;
613 
614 #if defined (SPI_I2S_FULLDUPLEX_SUPPORT)
615  case HAL_I2S_TX_RX_HALF_COMPLETE_CB_ID :
616  hi2s->TxRxHalfCpltCallback = pCallback;
617  break;
618 #endif
619 
620  case HAL_I2S_ERROR_CB_ID :
621  hi2s->ErrorCallback = pCallback;
622  break;
623 
624  case HAL_I2S_MSPINIT_CB_ID :
625  hi2s->MspInitCallback = pCallback;
626  break;
627 
628  case HAL_I2S_MSPDEINIT_CB_ID :
629  hi2s->MspDeInitCallback = pCallback;
630  break;
631 
632  default :
633  /* Update the error code */
634  SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_INVALID_CALLBACK);
635 
636  /* Return error status */
637  status = HAL_ERROR;
638  break;
639  }
640  }
641  else if (HAL_I2S_STATE_RESET == hi2s->State)
642  {
643  switch (CallbackID)
644  {
645  case HAL_I2S_MSPINIT_CB_ID :
646  hi2s->MspInitCallback = pCallback;
647  break;
648 
649  case HAL_I2S_MSPDEINIT_CB_ID :
650  hi2s->MspDeInitCallback = pCallback;
651  break;
652 
653  default :
654  /* Update the error code */
655  SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_INVALID_CALLBACK);
656 
657  /* Return error status */
658  status = HAL_ERROR;
659  break;
660  }
661  }
662  else
663  {
664  /* Update the error code */
665  SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_INVALID_CALLBACK);
666 
667  /* Return error status */
668  status = HAL_ERROR;
669  }
670 
671  /* Release Lock */
672  __HAL_UNLOCK(hi2s);
673  return status;
674 }
675 
684 HAL_StatusTypeDef HAL_I2S_UnRegisterCallback(I2S_HandleTypeDef *hi2s, HAL_I2S_CallbackIDTypeDef CallbackID)
685 {
686  HAL_StatusTypeDef status = HAL_OK;
687 
688  /* Process locked */
689  __HAL_LOCK(hi2s);
690 
691  if (HAL_I2S_STATE_READY == hi2s->State)
692  {
693  switch (CallbackID)
694  {
695  case HAL_I2S_TX_COMPLETE_CB_ID :
696  hi2s->TxCpltCallback = HAL_I2S_TxCpltCallback; /* Legacy weak TxCpltCallback */
697  break;
698 
699  case HAL_I2S_RX_COMPLETE_CB_ID :
700  hi2s->RxCpltCallback = HAL_I2S_RxCpltCallback; /* Legacy weak RxCpltCallback */
701  break;
702 
703 #if defined (SPI_I2S_FULLDUPLEX_SUPPORT)
704  case HAL_I2S_TX_RX_COMPLETE_CB_ID :
705  hi2s->TxRxCpltCallback = HAL_I2SEx_TxRxCpltCallback; /* Legacy weak TxRxCpltCallback */
706  break;
707 #endif
708 
709  case HAL_I2S_TX_HALF_COMPLETE_CB_ID :
710  hi2s->TxHalfCpltCallback = HAL_I2S_TxHalfCpltCallback; /* Legacy weak TxHalfCpltCallback */
711  break;
712 
713  case HAL_I2S_RX_HALF_COMPLETE_CB_ID :
714  hi2s->RxHalfCpltCallback = HAL_I2S_RxHalfCpltCallback; /* Legacy weak RxHalfCpltCallback */
715  break;
716 
717 #if defined (SPI_I2S_FULLDUPLEX_SUPPORT)
718  case HAL_I2S_TX_RX_HALF_COMPLETE_CB_ID :
719  hi2s->TxRxHalfCpltCallback = HAL_I2SEx_TxRxHalfCpltCallback; /* Legacy weak TxRxHalfCpltCallback */
720  break;
721 #endif
722 
723  case HAL_I2S_ERROR_CB_ID :
724  hi2s->ErrorCallback = HAL_I2S_ErrorCallback; /* Legacy weak ErrorCallback */
725  break;
726 
727  case HAL_I2S_MSPINIT_CB_ID :
728  hi2s->MspInitCallback = HAL_I2S_MspInit; /* Legacy weak MspInit */
729  break;
730 
731  case HAL_I2S_MSPDEINIT_CB_ID :
732  hi2s->MspDeInitCallback = HAL_I2S_MspDeInit; /* Legacy weak MspDeInit */
733  break;
734 
735  default :
736  /* Update the error code */
737  SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_INVALID_CALLBACK);
738 
739  /* Return error status */
740  status = HAL_ERROR;
741  break;
742  }
743  }
744  else if (HAL_I2S_STATE_RESET == hi2s->State)
745  {
746  switch (CallbackID)
747  {
748  case HAL_I2S_MSPINIT_CB_ID :
749  hi2s->MspInitCallback = HAL_I2S_MspInit; /* Legacy weak MspInit */
750  break;
751 
752  case HAL_I2S_MSPDEINIT_CB_ID :
753  hi2s->MspDeInitCallback = HAL_I2S_MspDeInit; /* Legacy weak MspDeInit */
754  break;
755 
756  default :
757  /* Update the error code */
758  SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_INVALID_CALLBACK);
759 
760  /* Return error status */
761  status = HAL_ERROR;
762  break;
763  }
764  }
765  else
766  {
767  /* Update the error code */
768  SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_INVALID_CALLBACK);
769 
770  /* Return error status */
771  status = HAL_ERROR;
772  }
773 
774  /* Release Lock */
775  __HAL_UNLOCK(hi2s);
776  return status;
777 }
778 #endif /* USE_HAL_I2S_REGISTER_CALLBACKS */
779 
840 HAL_StatusTypeDef HAL_I2S_Transmit(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size, uint32_t Timeout)
841 {
842  uint32_t tmpreg_cfgr;
843 
844  if ((pData == NULL) || (Size == 0U))
845  {
846  return HAL_ERROR;
847  }
848 
849  /* Process Locked */
850  __HAL_LOCK(hi2s);
851 
852  if (hi2s->State != HAL_I2S_STATE_READY)
853  {
854  __HAL_UNLOCK(hi2s);
855  return HAL_BUSY;
856  }
857 
858  /* Set state and reset error code */
861  hi2s->pTxBuffPtr = pData;
862 
863  tmpreg_cfgr = hi2s->Instance->I2SCFGR & (SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN);
864 
865  if ((tmpreg_cfgr == I2S_DATAFORMAT_24B) || (tmpreg_cfgr == I2S_DATAFORMAT_32B))
866  {
867  hi2s->TxXferSize = (Size << 1U);
868  hi2s->TxXferCount = (Size << 1U);
869  }
870  else
871  {
872  hi2s->TxXferSize = Size;
873  hi2s->TxXferCount = Size;
874  }
875 
876  tmpreg_cfgr = hi2s->Instance->I2SCFGR;
877 
878  /* Check if the I2S is already enabled */
880  {
881  /* Enable I2S peripheral */
882  __HAL_I2S_ENABLE(hi2s);
883  }
884 
885  /* Wait until TXE flag is set */
886  if (I2S_WaitFlagStateUntilTimeout(hi2s, I2S_FLAG_TXE, SET, Timeout) != HAL_OK)
887  {
888  /* Set the error code */
890  hi2s->State = HAL_I2S_STATE_READY;
891  __HAL_UNLOCK(hi2s);
892  return HAL_ERROR;
893  }
894 
895  while (hi2s->TxXferCount > 0U)
896  {
897  hi2s->Instance->DR = (*hi2s->pTxBuffPtr);
898  hi2s->pTxBuffPtr++;
899  hi2s->TxXferCount--;
900 
901  /* Wait until TXE flag is set */
902  if (I2S_WaitFlagStateUntilTimeout(hi2s, I2S_FLAG_TXE, SET, Timeout) != HAL_OK)
903  {
904  /* Set the error code */
906  hi2s->State = HAL_I2S_STATE_READY;
907  __HAL_UNLOCK(hi2s);
908  return HAL_ERROR;
909  }
910 
911  /* Check if an underrun occurs */
912  if (__HAL_I2S_GET_FLAG(hi2s, I2S_FLAG_UDR) == SET)
913  {
914  /* Clear underrun flag */
916 
917  /* Set the error code */
919  }
920  }
921 
922  /* Check if Slave mode is selected */
923  if (((tmpreg_cfgr & SPI_I2SCFGR_I2SCFG) == I2S_MODE_SLAVE_TX)
924  || ((tmpreg_cfgr & SPI_I2SCFGR_I2SCFG) == I2S_MODE_SLAVE_RX))
925  {
926  /* Wait until Busy flag is reset */
927  if (I2S_WaitFlagStateUntilTimeout(hi2s, I2S_FLAG_BSY, RESET, Timeout) != HAL_OK)
928  {
929  /* Set the error code */
931  hi2s->State = HAL_I2S_STATE_READY;
932  __HAL_UNLOCK(hi2s);
933  return HAL_ERROR;
934  }
935  }
936 
937  hi2s->State = HAL_I2S_STATE_READY;
938  __HAL_UNLOCK(hi2s);
939  return HAL_OK;
940 }
941 
959 HAL_StatusTypeDef HAL_I2S_Receive(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size, uint32_t Timeout)
960 {
961  uint32_t tmpreg_cfgr;
962 
963  if ((pData == NULL) || (Size == 0U))
964  {
965  return HAL_ERROR;
966  }
967 
968  /* Process Locked */
969  __HAL_LOCK(hi2s);
970 
971  if (hi2s->State != HAL_I2S_STATE_READY)
972  {
973  __HAL_UNLOCK(hi2s);
974  return HAL_BUSY;
975  }
976 
977  /* Set state and reset error code */
980  hi2s->pRxBuffPtr = pData;
981 
982  tmpreg_cfgr = hi2s->Instance->I2SCFGR & (SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN);
983 
984  if ((tmpreg_cfgr == I2S_DATAFORMAT_24B) || (tmpreg_cfgr == I2S_DATAFORMAT_32B))
985  {
986  hi2s->RxXferSize = (Size << 1U);
987  hi2s->RxXferCount = (Size << 1U);
988  }
989  else
990  {
991  hi2s->RxXferSize = Size;
992  hi2s->RxXferCount = Size;
993  }
994 
995  /* Check if the I2S is already enabled */
997  {
998  /* Enable I2S peripheral */
999  __HAL_I2S_ENABLE(hi2s);
1000  }
1001 
1002  /* Check if Master Receiver mode is selected */
1004  {
1005  /* Clear the Overrun Flag by a read operation on the SPI_DR register followed by a read
1006  access to the SPI_SR register. */
1008  }
1009 
1010  /* Receive data */
1011  while (hi2s->RxXferCount > 0U)
1012  {
1013  /* Wait until RXNE flag is set */
1014  if (I2S_WaitFlagStateUntilTimeout(hi2s, I2S_FLAG_RXNE, SET, Timeout) != HAL_OK)
1015  {
1016  /* Set the error code */
1018  hi2s->State = HAL_I2S_STATE_READY;
1019  __HAL_UNLOCK(hi2s);
1020  return HAL_ERROR;
1021  }
1022 
1023  (*hi2s->pRxBuffPtr) = (uint16_t)hi2s->Instance->DR;
1024  hi2s->pRxBuffPtr++;
1025  hi2s->RxXferCount--;
1026 
1027  /* Check if an overrun occurs */
1028  if (__HAL_I2S_GET_FLAG(hi2s, I2S_FLAG_OVR) == SET)
1029  {
1030  /* Clear overrun flag */
1032 
1033  /* Set the error code */
1035  }
1036  }
1037 
1038  hi2s->State = HAL_I2S_STATE_READY;
1039  __HAL_UNLOCK(hi2s);
1040  return HAL_OK;
1041 }
1042 
1057 HAL_StatusTypeDef HAL_I2S_Transmit_IT(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size)
1058 {
1059  uint32_t tmpreg_cfgr;
1060 
1061  if ((pData == NULL) || (Size == 0U))
1062  {
1063  return HAL_ERROR;
1064  }
1065 
1066  /* Process Locked */
1067  __HAL_LOCK(hi2s);
1068 
1069  if (hi2s->State != HAL_I2S_STATE_READY)
1070  {
1071  __HAL_UNLOCK(hi2s);
1072  return HAL_BUSY;
1073  }
1074 
1075  /* Set state and reset error code */
1076  hi2s->State = HAL_I2S_STATE_BUSY_TX;
1077  hi2s->ErrorCode = HAL_I2S_ERROR_NONE;
1078  hi2s->pTxBuffPtr = pData;
1079 
1080  tmpreg_cfgr = hi2s->Instance->I2SCFGR & (SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN);
1081 
1082  if ((tmpreg_cfgr == I2S_DATAFORMAT_24B) || (tmpreg_cfgr == I2S_DATAFORMAT_32B))
1083  {
1084  hi2s->TxXferSize = (Size << 1U);
1085  hi2s->TxXferCount = (Size << 1U);
1086  }
1087  else
1088  {
1089  hi2s->TxXferSize = Size;
1090  hi2s->TxXferCount = Size;
1091  }
1092 
1093  /* Enable TXE and ERR interrupt */
1095 
1096  /* Check if the I2S is already enabled */
1098  {
1099  /* Enable I2S peripheral */
1100  __HAL_I2S_ENABLE(hi2s);
1101  }
1102 
1103  __HAL_UNLOCK(hi2s);
1104  return HAL_OK;
1105 }
1106 
1123 HAL_StatusTypeDef HAL_I2S_Receive_IT(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size)
1124 {
1125  uint32_t tmpreg_cfgr;
1126 
1127  if ((pData == NULL) || (Size == 0U))
1128  {
1129  return HAL_ERROR;
1130  }
1131 
1132  /* Process Locked */
1133  __HAL_LOCK(hi2s);
1134 
1135  if (hi2s->State != HAL_I2S_STATE_READY)
1136  {
1137  __HAL_UNLOCK(hi2s);
1138  return HAL_BUSY;
1139  }
1140 
1141  /* Set state and reset error code */
1142  hi2s->State = HAL_I2S_STATE_BUSY_RX;
1143  hi2s->ErrorCode = HAL_I2S_ERROR_NONE;
1144  hi2s->pRxBuffPtr = pData;
1145 
1146  tmpreg_cfgr = hi2s->Instance->I2SCFGR & (SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN);
1147 
1148  if ((tmpreg_cfgr == I2S_DATAFORMAT_24B) || (tmpreg_cfgr == I2S_DATAFORMAT_32B))
1149  {
1150  hi2s->RxXferSize = (Size << 1U);
1151  hi2s->RxXferCount = (Size << 1U);
1152  }
1153  else
1154  {
1155  hi2s->RxXferSize = Size;
1156  hi2s->RxXferCount = Size;
1157  }
1158 
1159  /* Enable RXNE and ERR interrupt */
1161 
1162  /* Check if the I2S is already enabled */
1164  {
1165  /* Enable I2S peripheral */
1166  __HAL_I2S_ENABLE(hi2s);
1167  }
1168 
1169  __HAL_UNLOCK(hi2s);
1170  return HAL_OK;
1171 }
1172 
1187 HAL_StatusTypeDef HAL_I2S_Transmit_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size)
1188 {
1189  uint32_t tmpreg_cfgr;
1190 
1191  if ((pData == NULL) || (Size == 0U))
1192  {
1193  return HAL_ERROR;
1194  }
1195 
1196  /* Process Locked */
1197  __HAL_LOCK(hi2s);
1198 
1199  if (hi2s->State != HAL_I2S_STATE_READY)
1200  {
1201  __HAL_UNLOCK(hi2s);
1202  return HAL_BUSY;
1203  }
1204 
1205  /* Set state and reset error code */
1206  hi2s->State = HAL_I2S_STATE_BUSY_TX;
1207  hi2s->ErrorCode = HAL_I2S_ERROR_NONE;
1208  hi2s->pTxBuffPtr = pData;
1209 
1210  tmpreg_cfgr = hi2s->Instance->I2SCFGR & (SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN);
1211 
1212  if ((tmpreg_cfgr == I2S_DATAFORMAT_24B) || (tmpreg_cfgr == I2S_DATAFORMAT_32B))
1213  {
1214  hi2s->TxXferSize = (Size << 1U);
1215  hi2s->TxXferCount = (Size << 1U);
1216  }
1217  else
1218  {
1219  hi2s->TxXferSize = Size;
1220  hi2s->TxXferCount = Size;
1221  }
1222 
1223  /* Set the I2S Tx DMA Half transfer complete callback */
1224  hi2s->hdmatx->XferHalfCpltCallback = I2S_DMATxHalfCplt;
1225 
1226  /* Set the I2S Tx DMA transfer complete callback */
1227  hi2s->hdmatx->XferCpltCallback = I2S_DMATxCplt;
1228 
1229  /* Set the DMA error callback */
1230  hi2s->hdmatx->XferErrorCallback = I2S_DMAError;
1231 
1232  /* Enable the Tx DMA Stream/Channel */
1233  if (HAL_OK != HAL_DMA_Start_IT(hi2s->hdmatx,
1234  (uint32_t)hi2s->pTxBuffPtr,
1235  (uint32_t)&hi2s->Instance->DR,
1236  hi2s->TxXferSize))
1237  {
1238  /* Update SPI error code */
1240  hi2s->State = HAL_I2S_STATE_READY;
1241 
1242  __HAL_UNLOCK(hi2s);
1243  return HAL_ERROR;
1244  }
1245 
1246  /* Check if the I2S is already enabled */
1248  {
1249  /* Enable I2S peripheral */
1250  __HAL_I2S_ENABLE(hi2s);
1251  }
1252 
1253  /* Check if the I2S Tx request is already enabled */
1255  {
1256  /* Enable Tx DMA Request */
1258  }
1259 
1260  __HAL_UNLOCK(hi2s);
1261  return HAL_OK;
1262 }
1263 
1278 HAL_StatusTypeDef HAL_I2S_Receive_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size)
1279 {
1280  uint32_t tmpreg_cfgr;
1281 
1282  if ((pData == NULL) || (Size == 0U))
1283  {
1284  return HAL_ERROR;
1285  }
1286 
1287  /* Process Locked */
1288  __HAL_LOCK(hi2s);
1289 
1290  if (hi2s->State != HAL_I2S_STATE_READY)
1291  {
1292  __HAL_UNLOCK(hi2s);
1293  return HAL_BUSY;
1294  }
1295 
1296  /* Set state and reset error code */
1297  hi2s->State = HAL_I2S_STATE_BUSY_RX;
1298  hi2s->ErrorCode = HAL_I2S_ERROR_NONE;
1299  hi2s->pRxBuffPtr = pData;
1300 
1301  tmpreg_cfgr = hi2s->Instance->I2SCFGR & (SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN);
1302 
1303  if ((tmpreg_cfgr == I2S_DATAFORMAT_24B) || (tmpreg_cfgr == I2S_DATAFORMAT_32B))
1304  {
1305  hi2s->RxXferSize = (Size << 1U);
1306  hi2s->RxXferCount = (Size << 1U);
1307  }
1308  else
1309  {
1310  hi2s->RxXferSize = Size;
1311  hi2s->RxXferCount = Size;
1312  }
1313 
1314  /* Set the I2S Rx DMA Half transfer complete callback */
1315  hi2s->hdmarx->XferHalfCpltCallback = I2S_DMARxHalfCplt;
1316 
1317  /* Set the I2S Rx DMA transfer complete callback */
1318  hi2s->hdmarx->XferCpltCallback = I2S_DMARxCplt;
1319 
1320  /* Set the DMA error callback */
1321  hi2s->hdmarx->XferErrorCallback = I2S_DMAError;
1322 
1323  /* Check if Master Receiver mode is selected */
1325  {
1326  /* Clear the Overrun Flag by a read operation to the SPI_DR register followed by a read
1327  access to the SPI_SR register. */
1329  }
1330 
1331  /* Enable the Rx DMA Stream/Channel */
1332  if (HAL_OK != HAL_DMA_Start_IT(hi2s->hdmarx, (uint32_t)&hi2s->Instance->DR, (uint32_t)hi2s->pRxBuffPtr,
1333  hi2s->RxXferSize))
1334  {
1335  /* Update SPI error code */
1337  hi2s->State = HAL_I2S_STATE_READY;
1338 
1339  __HAL_UNLOCK(hi2s);
1340  return HAL_ERROR;
1341  }
1342 
1343  /* Check if the I2S is already enabled */
1345  {
1346  /* Enable I2S peripheral */
1347  __HAL_I2S_ENABLE(hi2s);
1348  }
1349 
1350  /* Check if the I2S Rx request is already enabled */
1352  {
1353  /* Enable Rx DMA Request */
1355  }
1356 
1357  __HAL_UNLOCK(hi2s);
1358  return HAL_OK;
1359 }
1360 
1368 {
1369  /* Process Locked */
1370  __HAL_LOCK(hi2s);
1371 
1372  if (hi2s->State == HAL_I2S_STATE_BUSY_TX)
1373  {
1374  /* Disable the I2S DMA Tx request */
1376  }
1377  else if (hi2s->State == HAL_I2S_STATE_BUSY_RX)
1378  {
1379  /* Disable the I2S DMA Rx request */
1381  }
1382 #if defined (SPI_I2S_FULLDUPLEX_SUPPORT)
1383  else if (hi2s->State == HAL_I2S_STATE_BUSY_TX_RX)
1384  {
1385  /* Pause the audio file playing by disabling the I2S DMA request */
1387  CLEAR_BIT(I2SxEXT(hi2s->Instance)->CR2, (SPI_CR2_TXDMAEN | SPI_CR2_RXDMAEN));
1388  }
1389 #endif /* SPI_I2S_FULLDUPLEX_SUPPORT */
1390  else
1391  {
1392  /* nothing to do */
1393  }
1394 
1395  /* Process Unlocked */
1396  __HAL_UNLOCK(hi2s);
1397 
1398  return HAL_OK;
1399 }
1400 
1408 {
1409  /* Process Locked */
1410  __HAL_LOCK(hi2s);
1411 
1412  if (hi2s->State == HAL_I2S_STATE_BUSY_TX)
1413  {
1414  /* Enable the I2S DMA Tx request */
1416  }
1417  else if (hi2s->State == HAL_I2S_STATE_BUSY_RX)
1418  {
1419  /* Enable the I2S DMA Rx request */
1421  }
1422 #if defined (SPI_I2S_FULLDUPLEX_SUPPORT)
1423  else if (hi2s->State == HAL_I2S_STATE_BUSY_TX_RX)
1424  {
1425  /* Pause the audio file playing by disabling the I2S DMA request */
1427  SET_BIT(I2SxEXT(hi2s->Instance)->CR2, (SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN));
1428 
1429  /* If the I2Sext peripheral is still not enabled, enable it */
1430  if ((I2SxEXT(hi2s->Instance)->I2SCFGR & SPI_I2SCFGR_I2SE) == 0U)
1431  {
1432  /* Enable I2Sext peripheral */
1433  __HAL_I2SEXT_ENABLE(hi2s);
1434  }
1435  }
1436 #endif /* SPI_I2S_FULLDUPLEX_SUPPORT */
1437  else
1438  {
1439  /* nothing to do */
1440  }
1441 
1442  /* If the I2S peripheral is still not enabled, enable it */
1444  {
1445  /* Enable I2S peripheral */
1446  __HAL_I2S_ENABLE(hi2s);
1447  }
1448 
1449  /* Process Unlocked */
1450  __HAL_UNLOCK(hi2s);
1451 
1452  return HAL_OK;
1453 }
1454 
1462 {
1463 #if defined (SPI_I2S_FULLDUPLEX_SUPPORT)
1464  uint32_t tickstart;
1465 #endif /* SPI_I2S_FULLDUPLEX_SUPPORT */
1466  HAL_StatusTypeDef errorcode = HAL_OK;
1467  /* The Lock is not implemented on this API to allow the user application
1468  to call the HAL SPI API under callbacks HAL_I2S_TxCpltCallback() or HAL_I2S_RxCpltCallback()
1469  when calling HAL_DMA_Abort() API the DMA TX or RX Transfer complete interrupt is generated
1470  and the correspond call back is executed HAL_I2S_TxCpltCallback() or HAL_I2S_RxCpltCallback()
1471  */
1472 
1473  if ((hi2s->Init.Mode == I2S_MODE_MASTER_TX) || (hi2s->Init.Mode == I2S_MODE_SLAVE_TX))
1474  {
1475  /* Abort the I2S DMA tx Stream/Channel */
1476  if (hi2s->hdmatx != NULL)
1477  {
1478  /* Disable the I2S DMA tx Stream/Channel */
1479  if (HAL_OK != HAL_DMA_Abort(hi2s->hdmatx))
1480  {
1482  errorcode = HAL_ERROR;
1483  }
1484  }
1485 
1486  /* Wait until TXE flag is set */
1487  if (I2S_WaitFlagStateUntilTimeout(hi2s, I2S_FLAG_TXE, SET, I2S_TIMEOUT_FLAG) != HAL_OK)
1488  {
1489  /* Set the error code */
1491  hi2s->State = HAL_I2S_STATE_READY;
1492  errorcode = HAL_ERROR;
1493  }
1494 
1495  /* Wait until BSY flag is Reset */
1496  if (I2S_WaitFlagStateUntilTimeout(hi2s, I2S_FLAG_BSY, RESET, I2S_TIMEOUT_FLAG) != HAL_OK)
1497  {
1498  /* Set the error code */
1500  hi2s->State = HAL_I2S_STATE_READY;
1501  errorcode = HAL_ERROR;
1502  }
1503 
1504  /* Disable I2S peripheral */
1505  __HAL_I2S_DISABLE(hi2s);
1506 
1507  /* Clear UDR flag */
1509 
1510  /* Disable the I2S Tx DMA requests */
1512 
1513 #if defined (SPI_I2S_FULLDUPLEX_SUPPORT)
1514 
1515  if (hi2s->State == HAL_I2S_STATE_BUSY_TX_RX)
1516  {
1517  /* Abort the I2S DMA rx Stream/Channel */
1518  if (hi2s->hdmarx != NULL)
1519  {
1520  /* Disable the I2S DMA rx Stream/Channel */
1521  if (HAL_OK != HAL_DMA_Abort(hi2s->hdmarx))
1522  {
1524  errorcode = HAL_ERROR;
1525  }
1526  }
1527 
1528  /* Disable I2Sext peripheral */
1529  __HAL_I2SEXT_DISABLE(hi2s);
1530 
1531  /* Clear OVR flag */
1532  __HAL_I2SEXT_CLEAR_OVRFLAG(hi2s);
1533 
1534  /* Disable the I2SxEXT DMA request */
1535  CLEAR_BIT(I2SxEXT(hi2s->Instance)->CR2, SPI_CR2_RXDMAEN);
1536 
1537  if (hi2s->Init.Mode == I2S_MODE_SLAVE_TX)
1538  {
1539  /* Set the error code */
1541 
1542  /* Set the I2S State ready */
1543  hi2s->State = HAL_I2S_STATE_READY;
1544  errorcode = HAL_ERROR;
1545  }
1546  else
1547  {
1548  /* Read DR to Flush RX Data */
1549  READ_REG(I2SxEXT(hi2s->Instance)->DR);
1550  }
1551  }
1552 #endif /* SPI_I2S_FULLDUPLEX_SUPPORT */
1553  }
1554 
1555  else if ((hi2s->Init.Mode == I2S_MODE_MASTER_RX) || (hi2s->Init.Mode == I2S_MODE_SLAVE_RX))
1556  {
1557  /* Abort the I2S DMA rx Stream/Channel */
1558  if (hi2s->hdmarx != NULL)
1559  {
1560  /* Disable the I2S DMA rx Stream/Channel */
1561  if (HAL_OK != HAL_DMA_Abort(hi2s->hdmarx))
1562  {
1564  errorcode = HAL_ERROR;
1565  }
1566  }
1567 #if defined (SPI_I2S_FULLDUPLEX_SUPPORT)
1568 
1569  if (hi2s->State == HAL_I2S_STATE_BUSY_TX_RX)
1570  {
1571  /* Abort the I2S DMA tx Stream/Channel */
1572  if (hi2s->hdmatx != NULL)
1573  {
1574  /* Disable the I2S DMA tx Stream/Channel */
1575  if (HAL_OK != HAL_DMA_Abort(hi2s->hdmatx))
1576  {
1578  errorcode = HAL_ERROR;
1579  }
1580  }
1581 
1582  tickstart = HAL_GetTick();
1583 
1584  /* Wait until TXE flag is set */
1585  while (__HAL_I2SEXT_GET_FLAG(hi2s, I2S_FLAG_TXE) != SET)
1586  {
1587  if (((HAL_GetTick() - tickstart) > I2S_TIMEOUT_FLAG))
1588  {
1589  /* Set the error code */
1591 
1592  /* Set the I2S State ready */
1593  hi2s->State = HAL_I2S_STATE_READY;
1594  errorcode = HAL_ERROR;
1595  }
1596  }
1597 
1598  /* Wait until BSY flag is Reset */
1599  while (__HAL_I2SEXT_GET_FLAG(hi2s, I2S_FLAG_BSY) != RESET)
1600  {
1601  if (((HAL_GetTick() - tickstart) > I2S_TIMEOUT_FLAG))
1602  {
1603  /* Set the error code */
1605 
1606  /* Set the I2S State ready */
1607  hi2s->State = HAL_I2S_STATE_READY;
1608  errorcode = HAL_ERROR;
1609  }
1610  }
1611 
1612  /* Disable I2Sext peripheral */
1613  __HAL_I2SEXT_DISABLE(hi2s);
1614 
1615  /* Clear UDR flag */
1616  __HAL_I2SEXT_CLEAR_UDRFLAG(hi2s);
1617 
1618  /* Disable the I2SxEXT DMA request */
1619  CLEAR_BIT(I2SxEXT(hi2s->Instance)->CR2, SPI_CR2_TXDMAEN);
1620  }
1621 #endif /* SPI_I2S_FULLDUPLEX_SUPPORT */
1622 
1623  /* Disable I2S peripheral */
1624  __HAL_I2S_DISABLE(hi2s);
1625 
1626  /* Clear OVR flag */
1628 
1629  /* Disable the I2S Rx DMA request */
1631 
1632  if (hi2s->Init.Mode == I2S_MODE_SLAVE_RX)
1633  {
1634  /* Set the error code */
1636 
1637  /* Set the I2S State ready */
1638  hi2s->State = HAL_I2S_STATE_READY;
1639  errorcode = HAL_ERROR;
1640  }
1641  else
1642  {
1643  /* Read DR to Flush RX Data */
1644  READ_REG((hi2s->Instance)->DR);
1645  }
1646  }
1647 
1648  hi2s->State = HAL_I2S_STATE_READY;
1649 
1650  return errorcode;
1651 }
1652 
1660 {
1661  /* Call the IrqHandler ISR set during HAL_I2S_INIT */
1662  hi2s->IrqHandlerISR(hi2s);
1663 }
1664 
1672 {
1673  /* Prevent unused argument(s) compilation warning */
1674  UNUSED(hi2s);
1675 
1676  /* NOTE : This function Should not be modified, when the callback is needed,
1677  the HAL_I2S_TxHalfCpltCallback could be implemented in the user file
1678  */
1679 }
1680 
1687 __weak void HAL_I2S_TxCpltCallback(I2S_HandleTypeDef *hi2s)
1688 {
1689  /* Prevent unused argument(s) compilation warning */
1690  UNUSED(hi2s);
1691 
1692  /* NOTE : This function Should not be modified, when the callback is needed,
1693  the HAL_I2S_TxCpltCallback could be implemented in the user file
1694  */
1695 }
1696 
1704 {
1705  /* Prevent unused argument(s) compilation warning */
1706  UNUSED(hi2s);
1707 
1708  /* NOTE : This function Should not be modified, when the callback is needed,
1709  the HAL_I2S_RxHalfCpltCallback could be implemented in the user file
1710  */
1711 }
1712 
1719 __weak void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s)
1720 {
1721  /* Prevent unused argument(s) compilation warning */
1722  UNUSED(hi2s);
1723 
1724  /* NOTE : This function Should not be modified, when the callback is needed,
1725  the HAL_I2S_RxCpltCallback could be implemented in the user file
1726  */
1727 }
1728 
1735 __weak void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s)
1736 {
1737  /* Prevent unused argument(s) compilation warning */
1738  UNUSED(hi2s);
1739 
1740  /* NOTE : This function Should not be modified, when the callback is needed,
1741  the HAL_I2S_ErrorCallback could be implemented in the user file
1742  */
1743 }
1744 
1771 {
1772  return hi2s->State;
1773 }
1774 
1781 uint32_t HAL_I2S_GetError(I2S_HandleTypeDef *hi2s)
1782 {
1783  return hi2s->ErrorCode;
1784 }
1802 static void I2S_DMATxCplt(DMA_HandleTypeDef *hdma)
1803 {
1804  I2S_HandleTypeDef *hi2s = (I2S_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent; /* Derogation MISRAC2012-Rule-11.5 */
1805 
1806  /* if DMA is configured in DMA_NORMAL Mode */
1807  if (hdma->Init.Mode == DMA_NORMAL)
1808  {
1809  /* Disable Tx DMA Request */
1811 
1812  hi2s->TxXferCount = 0U;
1813  hi2s->State = HAL_I2S_STATE_READY;
1814  }
1815  /* Call user Tx complete callback */
1816 #if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U)
1817  hi2s->TxCpltCallback(hi2s);
1818 #else
1819  HAL_I2S_TxCpltCallback(hi2s);
1820 #endif /* USE_HAL_I2S_REGISTER_CALLBACKS */
1821 }
1822 
1829 static void I2S_DMATxHalfCplt(DMA_HandleTypeDef *hdma)
1830 {
1831  I2S_HandleTypeDef *hi2s = (I2S_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent; /* Derogation MISRAC2012-Rule-11.5 */
1832 
1833  /* Call user Tx half complete callback */
1834 #if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U)
1835  hi2s->TxHalfCpltCallback(hi2s);
1836 #else
1838 #endif /* USE_HAL_I2S_REGISTER_CALLBACKS */
1839 }
1840 
1847 static void I2S_DMARxCplt(DMA_HandleTypeDef *hdma)
1848 {
1849  I2S_HandleTypeDef *hi2s = (I2S_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent; /* Derogation MISRAC2012-Rule-11.5 */
1850 
1851  /* if DMA is configured in DMA_NORMAL Mode */
1852  if (hdma->Init.Mode == DMA_NORMAL)
1853  {
1854  /* Disable Rx DMA Request */
1856  hi2s->RxXferCount = 0U;
1857  hi2s->State = HAL_I2S_STATE_READY;
1858  }
1859  /* Call user Rx complete callback */
1860 #if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U)
1861  hi2s->RxCpltCallback(hi2s);
1862 #else
1863  HAL_I2S_RxCpltCallback(hi2s);
1864 #endif /* USE_HAL_I2S_REGISTER_CALLBACKS */
1865 }
1866 
1873 static void I2S_DMARxHalfCplt(DMA_HandleTypeDef *hdma)
1874 {
1875  I2S_HandleTypeDef *hi2s = (I2S_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent; /* Derogation MISRAC2012-Rule-11.5 */
1876 
1877  /* Call user Rx half complete callback */
1878 #if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U)
1879  hi2s->RxHalfCpltCallback(hi2s);
1880 #else
1882 #endif /* USE_HAL_I2S_REGISTER_CALLBACKS */
1883 }
1884 
1891 static void I2S_DMAError(DMA_HandleTypeDef *hdma)
1892 {
1893  I2S_HandleTypeDef *hi2s = (I2S_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent; /* Derogation MISRAC2012-Rule-11.5 */
1894 
1895  /* Disable Rx and Tx DMA Request */
1897  hi2s->TxXferCount = 0U;
1898  hi2s->RxXferCount = 0U;
1899 
1900  hi2s->State = HAL_I2S_STATE_READY;
1901 
1902  /* Set the error code and execute error callback*/
1904  /* Call user error callback */
1905 #if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U)
1906  hi2s->ErrorCallback(hi2s);
1907 #else
1908  HAL_I2S_ErrorCallback(hi2s);
1909 #endif /* USE_HAL_I2S_REGISTER_CALLBACKS */
1910 }
1911 
1918 static void I2S_Transmit_IT(I2S_HandleTypeDef *hi2s)
1919 {
1920  /* Transmit data */
1921  hi2s->Instance->DR = (*hi2s->pTxBuffPtr);
1922  hi2s->pTxBuffPtr++;
1923  hi2s->TxXferCount--;
1924 
1925  if (hi2s->TxXferCount == 0U)
1926  {
1927  /* Disable TXE and ERR interrupt */
1929 
1930  hi2s->State = HAL_I2S_STATE_READY;
1931  /* Call user Tx complete callback */
1932 #if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U)
1933  hi2s->TxCpltCallback(hi2s);
1934 #else
1935  HAL_I2S_TxCpltCallback(hi2s);
1936 #endif /* USE_HAL_I2S_REGISTER_CALLBACKS */
1937  }
1938 }
1939 
1946 static void I2S_Receive_IT(I2S_HandleTypeDef *hi2s)
1947 {
1948  /* Receive data */
1949  (*hi2s->pRxBuffPtr) = (uint16_t)hi2s->Instance->DR;
1950  hi2s->pRxBuffPtr++;
1951  hi2s->RxXferCount--;
1952 
1953  if (hi2s->RxXferCount == 0U)
1954  {
1955  /* Disable RXNE and ERR interrupt */
1957 
1958  hi2s->State = HAL_I2S_STATE_READY;
1959  /* Call user Rx complete callback */
1960 #if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U)
1961  hi2s->RxCpltCallback(hi2s);
1962 #else
1963  HAL_I2S_RxCpltCallback(hi2s);
1964 #endif /* USE_HAL_I2S_REGISTER_CALLBACKS */
1965  }
1966 }
1967 
1974 static void I2S_IRQHandler(I2S_HandleTypeDef *hi2s)
1975 {
1976  __IO uint32_t i2ssr = hi2s->Instance->SR;
1977 
1978  if (hi2s->State == HAL_I2S_STATE_BUSY_RX)
1979  {
1980  /* I2S in mode Receiver ------------------------------------------------*/
1981  if (((i2ssr & I2S_FLAG_RXNE) == I2S_FLAG_RXNE) && (__HAL_I2S_GET_IT_SOURCE(hi2s, I2S_IT_RXNE) != RESET))
1982  {
1983  I2S_Receive_IT(hi2s);
1984  }
1985 
1986  /* I2S Overrun error interrupt occurred -------------------------------------*/
1987  if (((i2ssr & I2S_FLAG_OVR) == I2S_FLAG_OVR) && (__HAL_I2S_GET_IT_SOURCE(hi2s, I2S_IT_ERR) != RESET))
1988  {
1989  /* Disable RXNE and ERR interrupt */
1991 
1992  /* Clear Overrun flag */
1994 
1995  /* Set the I2S State ready */
1996  hi2s->State = HAL_I2S_STATE_READY;
1997 
1998 
1999  /* Set the error code and execute error callback*/
2001  /* Call user error callback */
2002 #if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U)
2003  hi2s->ErrorCallback(hi2s);
2004 #else
2005  HAL_I2S_ErrorCallback(hi2s);
2006 #endif /* USE_HAL_I2S_REGISTER_CALLBACKS */
2007  }
2008  }
2009 
2010  if (hi2s->State == HAL_I2S_STATE_BUSY_TX)
2011  {
2012  /* I2S in mode Transmitter -----------------------------------------------*/
2013  if (((i2ssr & I2S_FLAG_TXE) == I2S_FLAG_TXE) && (__HAL_I2S_GET_IT_SOURCE(hi2s, I2S_IT_TXE) != RESET))
2014  {
2015  I2S_Transmit_IT(hi2s);
2016  }
2017 
2018  /* I2S Underrun error interrupt occurred --------------------------------*/
2019  if (((i2ssr & I2S_FLAG_UDR) == I2S_FLAG_UDR) && (__HAL_I2S_GET_IT_SOURCE(hi2s, I2S_IT_ERR) != RESET))
2020  {
2021  /* Disable TXE and ERR interrupt */
2023 
2024  /* Clear Underrun flag */
2026 
2027  /* Set the I2S State ready */
2028  hi2s->State = HAL_I2S_STATE_READY;
2029 
2030  /* Set the error code and execute error callback*/
2032  /* Call user error callback */
2033 #if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U)
2034  hi2s->ErrorCallback(hi2s);
2035 #else
2036  HAL_I2S_ErrorCallback(hi2s);
2037 #endif /* USE_HAL_I2S_REGISTER_CALLBACKS */
2038  }
2039  }
2040 }
2041 
2051 static HAL_StatusTypeDef I2S_WaitFlagStateUntilTimeout(I2S_HandleTypeDef *hi2s, uint32_t Flag, FlagStatus State,
2052  uint32_t Timeout)
2053 {
2054  uint32_t tickstart;
2055 
2056  /* Get tick */
2057  tickstart = HAL_GetTick();
2058 
2059  /* Wait until flag is set to status*/
2060  while (((__HAL_I2S_GET_FLAG(hi2s, Flag)) ? SET : RESET) != State)
2061  {
2062  if (Timeout != HAL_MAX_DELAY)
2063  {
2064  if (((HAL_GetTick() - tickstart) >= Timeout) || (Timeout == 0U))
2065  {
2066  /* Set the I2S State ready */
2067  hi2s->State = HAL_I2S_STATE_READY;
2068 
2069  /* Process Unlocked */
2070  __HAL_UNLOCK(hi2s);
2071 
2072  return HAL_TIMEOUT;
2073  }
2074  }
2075  }
2076  return HAL_OK;
2077 }
2078 
2091 #endif /* HAL_I2S_MODULE_ENABLED */
2092 
2093 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
__HAL_I2S_DISABLE_IT
#define __HAL_I2S_DISABLE_IT(__HANDLE__, __INTERRUPT__)
Disable the specified I2S interrupts.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:376
HAL_I2S_ERROR_TIMEOUT
#define HAL_I2S_ERROR_TIMEOUT
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:176
I2S_MODE_MASTER_TX
#define I2S_MODE_MASTER_TX
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:194
assert_param
#define assert_param(expr)
Include module's header file.
Definition: stm32f407/stm32f407g-disc1/Inc/stm32f4xx_hal_conf.h:353
SPI_I2SCFGR_CHLEN
#define SPI_I2SCFGR_CHLEN
Definition: stm32f407xx.h:11563
I2S_STANDARD_LSB
#define I2S_STANDARD_LSB
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:205
HAL_I2S_MspDeInit
void HAL_I2S_MspDeInit(I2S_HandleTypeDef *hi2s)
SPI_TypeDef::DR
__IO uint32_t DR
Definition: stm32f407xx.h:716
__HAL_I2S_CLEAR_OVRFLAG
#define __HAL_I2S_CLEAR_OVRFLAG(__HANDLE__)
Clears the I2S OVR pending flag.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:410
HAL_I2S_TxHalfCpltCallback
void HAL_I2S_TxHalfCpltCallback(I2S_HandleTypeDef *hi2s)
Tx Half Transfer completed callbacks.
Definition: stm32f4_discovery_audio.c:469
__IO
#define __IO
Definition: imxrt1050/imxrt1050-evkb/CMSIS/core_cm7.h:237
HAL_StatusTypeDef
HAL_StatusTypeDef
HAL Status structures definition
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:40
SPI_I2SCFGR_I2SE
#define SPI_I2SCFGR_I2SE
Definition: stm32f407xx.h:11593
__HAL_I2S_ENABLE
#define __HAL_I2S_ENABLE(__HANDLE__)
Enable the specified SPI peripheral (in I2S mode).
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:348
HAL_IS_BIT_CLR
#define HAL_IS_BIT_CLR(REG, BIT)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:64
SPI_I2SCFGR_ASTRTEN
#define SPI_I2SCFGR_ASTRTEN
Definition: stm32f469xx.h:16112
HAL_RCCEx_GetPeriphCLKFreq
uint32_t HAL_RCCEx_GetPeriphCLKFreq(uint32_t PeriphClk)
__DMA_HandleTypeDef::XferHalfCpltCallback
void(* XferHalfCpltCallback)(struct __DMA_HandleTypeDef *hdma)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:153
SPI_CR2_RXDMAEN
#define SPI_CR2_RXDMAEN
Definition: stm32f407xx.h:11491
I2S_DATAFORMAT_32B
#define I2S_DATAFORMAT_32B
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:218
__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
SPI_I2SCFGR_CKPOL
#define SPI_I2SCFGR_CKPOL
Definition: stm32f407xx.h:11573
__HAL_I2S_GET_FLAG
#define __HAL_I2S_GET_FLAG(__HANDLE__, __FLAG__)
Checks whether the specified I2S flag is set or not.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:404
I2S_InitTypeDef::CPOL
uint32_t CPOL
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:64
HAL_I2S_STATE_BUSY_TX_RX
@ HAL_I2S_STATE_BUSY_TX_RX
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:83
IS_I2S_FULLDUPLEX_MODE
#define IS_I2S_FULLDUPLEX_MODE(MODE)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:573
I2S_HandleTypeDef::pRxBuffPtr
uint16_t * pRxBuffPtr
Definition: stm32f7xx_hal_i2s.h:104
HAL_I2S_Receive
HAL_StatusTypeDef HAL_I2S_Receive(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size, uint32_t Timeout)
HAL_UNLOCKED
@ HAL_UNLOCKED
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:53
HAL_I2S_TxCpltCallback
void HAL_I2S_TxCpltCallback(I2S_HandleTypeDef *hi2s)
Tx Transfer completed callbacks.
Definition: stm32f4_discovery_audio.c:456
I2S_InitTypeDef::MCLKOutput
uint32_t MCLKOutput
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:58
HAL_I2S_STATE_BUSY_TX
@ HAL_I2S_STATE_BUSY_TX
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:81
I2S_MODE_SLAVE_TX
#define I2S_MODE_SLAVE_TX
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:192
IS_I2S_ALL_INSTANCE
#define IS_I2S_ALL_INSTANCE(INSTANCE)
Definition: stm32f407xx.h:15138
HAL_I2S_RxCpltCallback
void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s)
Rx Transfer completed callbacks.
Definition: stm32f4_discovery_audio.c:844
SPI_TypeDef::I2SPR
__IO uint32_t I2SPR
Definition: stm32f407xx.h:721
I2S_HandleTypeDef
I2S handle Structure definition.
Definition: stm32f7xx_hal_i2s.h:91
I2S_InitTypeDef::Standard
uint32_t Standard
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:52
I2S_HandleTypeDef::hdmatx
DMA_HandleTypeDef * hdmatx
Definition: stm32f7xx_hal_i2s.h:114
I2S_IT_RXNE
#define I2S_IT_RXNE
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:271
__DMA_HandleTypeDef::Init
DMA_InitTypeDef Init
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:143
RCC_PERIPHCLK_I2S
#define RCC_PERIPHCLK_I2S
Definition: stm32f7xx_hal_rcc_ex.h:237
HAL_I2S_STATE_BUSY
@ HAL_I2S_STATE_BUSY
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:80
HAL_ERROR
@ HAL_ERROR
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:43
HAL_I2SEx_TxRxHalfCpltCallback
void HAL_I2SEx_TxRxHalfCpltCallback(I2S_HandleTypeDef *hi2s)
IS_I2S_AUDIO_FREQ
#define IS_I2S_AUDIO_FREQ(__FREQ__)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:569
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
IS_I2S_STANDARD
#define IS_I2S_STANDARD(__STANDARD__)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:555
SPI_TypeDef::CR2
__IO uint32_t CR2
Definition: stm32f407xx.h:714
I2S_IT_ERR
#define I2S_IT_ERR
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:272
I2S_HandleTypeDef::TxXferSize
__IO uint16_t TxXferSize
Definition: stm32f7xx_hal_i2s.h:100
HAL_I2S_Transmit
HAL_StatusTypeDef HAL_I2S_Transmit(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size, uint32_t Timeout)
HAL_I2S_DMAPause
HAL_StatusTypeDef HAL_I2S_DMAPause(I2S_HandleTypeDef *hi2s)
I2S_HandleTypeDef::ErrorCode
__IO uint32_t ErrorCode
Definition: stm32f7xx_hal_i2s.h:122
I2S_HandleTypeDef::pTxBuffPtr
uint16_t * pTxBuffPtr
Definition: stm32f7xx_hal_i2s.h:98
HAL_I2S_GetError
uint32_t HAL_I2S_GetError(I2S_HandleTypeDef *hi2s)
I2S_FLAG_BSY
#define I2S_FLAG_BSY
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:288
I2S_HandleTypeDef::Instance
SPI_TypeDef * Instance
Definition: stm32f7xx_hal_i2s.h:94
HAL_I2S_STATE_BUSY_RX
@ HAL_I2S_STATE_BUSY_RX
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:82
HAL_OK
@ HAL_OK
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:42
I2S_STANDARD_PCM_SHORT
#define I2S_STANDARD_PCM_SHORT
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:206
HAL_I2S_Receive_DMA
HAL_StatusTypeDef HAL_I2S_Receive_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size)
HAL_I2S_ERROR_DMA
#define HAL_I2S_ERROR_DMA
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:179
HAL_I2S_RxHalfCpltCallback
void HAL_I2S_RxHalfCpltCallback(I2S_HandleTypeDef *hi2s)
Rx Half Transfer completed callbacks.
Definition: stm32f4_discovery_audio.c:854
UNUSED
#define UNUSED(x)
Definition: porcupine/demo/c/dr_libs/old/dr.h:92
HAL_I2S_DMAResume
HAL_StatusTypeDef HAL_I2S_DMAResume(I2S_HandleTypeDef *hi2s)
HAL_I2S_GetState
HAL_I2S_StateTypeDef HAL_I2S_GetState(I2S_HandleTypeDef *hi2s)
I2S_FULLDUPLEXMODE_ENABLE
#define I2S_FULLDUPLEXMODE_ENABLE
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:253
HAL_I2S_STATE_READY
@ HAL_I2S_STATE_READY
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:79
I2S_InitTypeDef::Mode
uint32_t Mode
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:49
HAL_I2S_Transmit_IT
HAL_StatusTypeDef HAL_I2S_Transmit_IT(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size)
HAL_I2S_Init
HAL_StatusTypeDef HAL_I2S_Init(I2S_HandleTypeDef *hi2s)
__HAL_LOCK
#define __HAL_LOCK(__HANDLE__)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:93
__HAL_I2S_GET_IT_SOURCE
#define __HAL_I2S_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__)
Checks if the specified I2S interrupt source is enabled or disabled.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:388
IS_I2S_DATA_FORMAT
#define IS_I2S_DATA_FORMAT(__FORMAT__)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:561
I2S_IT_TXE
#define I2S_IT_TXE
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:270
MODIFY_REG
#define MODIFY_REG(REG, CLEARMASK, SETMASK)
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:224
HAL_I2S_ERROR_NONE
#define HAL_I2S_ERROR_NONE
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:175
RESET
@ RESET
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:187
HAL_I2S_ErrorCallback
void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s)
I2S error callbacks.
Definition: stm32f4_discovery_audio.c:1110
HAL_I2S_IRQHandler
void HAL_I2S_IRQHandler(I2S_HandleTypeDef *hi2s)
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)
SPI_I2SCFGR_DATLEN
#define SPI_I2SCFGR_DATLEN
Definition: stm32f407xx.h:11567
I2S_MCLKOUTPUT_ENABLE
#define I2S_MCLKOUTPUT_ENABLE
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:226
HAL_I2SEx_TxRxCpltCallback
void HAL_I2SEx_TxRxCpltCallback(I2S_HandleTypeDef *hi2s)
I2S_HandleTypeDef::RxXferSize
__IO uint16_t RxXferSize
Definition: stm32f7xx_hal_i2s.h:106
__HAL_I2S_CLEAR_UDRFLAG
#define __HAL_I2S_CLEAR_UDRFLAG(__HANDLE__)
Clears the I2S UDR pending flag.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:420
__HAL_UNLOCK
#define __HAL_UNLOCK(__HANDLE__)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:105
HAL_I2S_ERROR_UDR
#define HAL_I2S_ERROR_UDR
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:178
HAL_MAX_DELAY
#define HAL_MAX_DELAY
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:61
SPI_TypeDef::I2SCFGR
__IO uint32_t I2SCFGR
Definition: stm32f407xx.h:720
HAL_DMA_Abort
HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma)
I2S_FLAG_OVR
#define I2S_FLAG_OVR
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:284
IS_I2S_MCLK_OUTPUT
#define IS_I2S_MCLK_OUTPUT(__OUTPUT__)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:566
IS_I2S_CPOL
#define IS_I2S_CPOL(__CPOL__)
Checks if I2S Serial clock steady state parameter is in allowed range.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:581
SPI_I2SCFGR_I2SMOD
#define SPI_I2SCFGR_I2SMOD
Definition: stm32f407xx.h:11596
I2S_FLAG_TXE
#define I2S_FLAG_TXE
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:280
I2S_HandleTypeDef::State
__IO HAL_I2S_StateTypeDef State
Definition: stm32f7xx_hal_i2s.h:120
I2S_HandleTypeDef::hdmarx
DMA_HandleTypeDef * hdmarx
Definition: stm32f7xx_hal_i2s.h:116
I2S_DATAFORMAT_24B
#define I2S_DATAFORMAT_24B
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:217
HAL_I2S_ERROR_BUSY_LINE_RX
#define HAL_I2S_ERROR_BUSY_LINE_RX
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:184
HAL_TIMEOUT
@ HAL_TIMEOUT
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:45
__I2C_HandleTypeDef::State
__IO HAL_I2C_StateTypeDef State
Definition: stm32f7xx_hal_i2c.h:211
I2S_HandleTypeDef::Init
I2S_InitTypeDef Init
Definition: stm32f7xx_hal_i2s.h:96
I2S_InitTypeDef::DataFormat
uint32_t DataFormat
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:55
DMA_NORMAL
#define DMA_NORMAL
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:281
I2S_FLAG_RXNE
#define I2S_FLAG_RXNE
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:281
SPI_I2SCFGR_PCMSYNC
#define SPI_I2SCFGR_PCMSYNC
Definition: stm32f407xx.h:11583
__DMA_HandleTypeDef::XferCpltCallback
void(* XferCpltCallback)(struct __DMA_HandleTypeDef *hdma)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:151
__HAL_I2S_ENABLE_IT
#define __HAL_I2S_ENABLE_IT(__HANDLE__, __INTERRUPT__)
Enable the specified I2S interrupts.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:365
I2S_HandleTypeDef::RxXferCount
__IO uint16_t RxXferCount
Definition: stm32f7xx_hal_i2s.h:108
HAL_I2S_ERROR_PRESCALER
#define HAL_I2S_ERROR_PRESCALER
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:180
SET
@ SET
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:188
HAL_I2S_STATE_RESET
@ HAL_I2S_STATE_RESET
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:78
FlagStatus
FlagStatus
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:185
SPI_CR2_TXDMAEN
#define SPI_CR2_TXDMAEN
Definition: stm32f407xx.h:11494
I2S_HandleTypeDef::TxXferCount
__IO uint16_t TxXferCount
Definition: stm32f7xx_hal_i2s.h:102
HAL_I2S_DMAStop
HAL_StatusTypeDef HAL_I2S_DMAStop(I2S_HandleTypeDef *hi2s)
IS_I2S_CLOCKSOURCE
#define IS_I2S_CLOCKSOURCE(CLOCK)
Definition: stm32f7xx_hal_i2s.h:540
I2S_AUDIOFREQ_DEFAULT
#define I2S_AUDIOFREQ_DEFAULT
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:244
HAL_I2S_StateTypeDef
HAL_I2S_StateTypeDef
HAL State structures definition.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:76
WRITE_REG
#define WRITE_REG(REG, VAL)
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:220
HAL_I2S_MspInit
void HAL_I2S_MspInit(I2S_HandleTypeDef *hi2s)
I2S_InitTypeDef::ClockSource
uint32_t ClockSource
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:67
I2S_InitTypeDef::FullDuplexMode
uint32_t FullDuplexMode
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:69
SPI_I2SCFGR_I2SCFG
#define SPI_I2SCFGR_I2SCFG
Definition: stm32f407xx.h:11587
DMA_InitTypeDef::Mode
uint32_t Mode
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:70
I2S_MODE_SLAVE_RX
#define I2S_MODE_SLAVE_RX
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:193
READ_REG
#define READ_REG(REG)
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:222
SPI_TypeDef::SR
__IO uint32_t SR
Definition: stm32f407xx.h:715
SET_BIT
#define SET_BIT(REG, BIT)
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:212
HAL_I2S_ERROR_OVR
#define HAL_I2S_ERROR_OVR
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:177
__HAL_I2S_DISABLE
#define __HAL_I2S_DISABLE(__HANDLE__)
Disable the specified SPI peripheral (in I2S mode).
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:354
HAL_I2S_DeInit
HAL_StatusTypeDef HAL_I2S_DeInit(I2S_HandleTypeDef *hi2s)
I2S_HandleTypeDef::Lock
__IO HAL_LockTypeDef Lock
Definition: stm32f7xx_hal_i2s.h:118
I2S_DATAFORMAT_16B
#define I2S_DATAFORMAT_16B
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:215
I2S_STANDARD_PCM_LONG
#define I2S_STANDARD_PCM_LONG
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:207
HAL_I2S_Transmit_DMA
HAL_StatusTypeDef HAL_I2S_Transmit_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size)
IS_I2S_MODE
#define IS_I2S_MODE(__MODE__)
Checks if I2S Mode parameter is in allowed range.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:550
HAL_I2S_Receive_IT
HAL_StatusTypeDef HAL_I2S_Receive_IT(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size)
I2S_FLAG_UDR
#define I2S_FLAG_UDR
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:283
__DMA_HandleTypeDef::XferErrorCallback
void(* XferErrorCallback)(struct __DMA_HandleTypeDef *hdma)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:159
I2S_InitTypeDef::AudioFreq
uint32_t AudioFreq
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:61
I2S_MODE_MASTER_RX
#define I2S_MODE_MASTER_RX
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2s.h:195
SPI_I2SCFGR_I2SSTD
#define SPI_I2SCFGR_I2SSTD
Definition: stm32f407xx.h:11577


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