Lines Matching refs:hi2s
216 static void I2S_Transmit_16Bit_IT(I2S_HandleTypeDef *hi2s);
217 static void I2S_Transmit_32Bit_IT(I2S_HandleTypeDef *hi2s);
218 static void I2S_Receive_16Bit_IT(I2S_HandleTypeDef *hi2s);
219 static void I2S_Receive_32Bit_IT(I2S_HandleTypeDef *hi2s);
220 static HAL_StatusTypeDef I2S_WaitFlagStateUntilTimeout(I2S_HandleTypeDef *hi2s, uint32_t Flag, Fla…
267 HAL_StatusTypeDef HAL_I2S_Init(I2S_HandleTypeDef *hi2s) in HAL_I2S_Init() argument
277 if (hi2s == NULL) in HAL_I2S_Init()
283 assert_param(IS_I2S_ALL_INSTANCE(hi2s->Instance)); in HAL_I2S_Init()
284 assert_param(IS_I2S_MODE(hi2s->Init.Mode)); in HAL_I2S_Init()
285 assert_param(IS_I2S_STANDARD(hi2s->Init.Standard)); in HAL_I2S_Init()
286 assert_param(IS_I2S_DATA_FORMAT(hi2s->Init.DataFormat)); in HAL_I2S_Init()
287 assert_param(IS_I2S_MCLK_OUTPUT(hi2s->Init.MCLKOutput)); in HAL_I2S_Init()
288 assert_param(IS_I2S_AUDIO_FREQ(hi2s->Init.AudioFreq)); in HAL_I2S_Init()
289 assert_param(IS_I2S_CPOL(hi2s->Init.CPOL)); in HAL_I2S_Init()
290 assert_param(IS_I2S_FIRST_BIT(hi2s->Init.FirstBit)); in HAL_I2S_Init()
291 assert_param(IS_I2S_WS_INVERSION(hi2s->Init.WSInversion)); in HAL_I2S_Init()
292 assert_param(IS_I2S_DATA_24BIT_ALIGNMENT(hi2s->Init.Data24BitAlignment)); in HAL_I2S_Init()
293 assert_param(IS_I2S_MASTER_KEEP_IO_STATE(hi2s->Init.MasterKeepIOState)); in HAL_I2S_Init()
295 if (hi2s->State == HAL_I2S_STATE_RESET) in HAL_I2S_Init()
298 hi2s->Lock = HAL_UNLOCKED; in HAL_I2S_Init()
302 …hi2s->TxCpltCallback = HAL_I2S_TxCpltCallback; /* Legacy weak TxCpltCallback … in HAL_I2S_Init()
303 …hi2s->RxCpltCallback = HAL_I2S_RxCpltCallback; /* Legacy weak RxCpltCallback … in HAL_I2S_Init()
304 …hi2s->TxRxCpltCallback = HAL_I2SEx_TxRxCpltCallback; /* Legacy weak TxRxCpltCallback … in HAL_I2S_Init()
305 …hi2s->TxHalfCpltCallback = HAL_I2S_TxHalfCpltCallback; /* Legacy weak TxHalfCpltCallback … in HAL_I2S_Init()
306 …hi2s->RxHalfCpltCallback = HAL_I2S_RxHalfCpltCallback; /* Legacy weak RxHalfCpltCallback … in HAL_I2S_Init()
307 …hi2s->TxRxHalfCpltCallback = HAL_I2SEx_TxRxHalfCpltCallback; /* Legacy weak TxRxHalfCpltCallback … in HAL_I2S_Init()
308 …hi2s->ErrorCallback = HAL_I2S_ErrorCallback; /* Legacy weak ErrorCallback … in HAL_I2S_Init()
310 if (hi2s->MspInitCallback == NULL) in HAL_I2S_Init()
312 hi2s->MspInitCallback = HAL_I2S_MspInit; /* Legacy weak MspInit */ in HAL_I2S_Init()
316 hi2s->MspInitCallback(hi2s); in HAL_I2S_Init()
319 HAL_I2S_MspInit(hi2s); in HAL_I2S_Init()
323 hi2s->State = HAL_I2S_STATE_BUSY; in HAL_I2S_Init()
326 if ((hi2s->Instance->CR1 & SPI_CR1_SPE) == SPI_CR1_SPE) in HAL_I2S_Init()
329 __HAL_I2S_DISABLE(hi2s); in HAL_I2S_Init()
333 CLEAR_REG(hi2s->Instance->I2SCFGR); in HAL_I2S_Init()
335 if (IS_I2S_MASTER(hi2s->Init.Mode)) in HAL_I2S_Init()
339 if (hi2s->Init.AudioFreq != I2S_AUDIOFREQ_DEFAULT) in HAL_I2S_Init()
342 if (hi2s->Init.DataFormat != I2S_DATAFORMAT_16B) in HAL_I2S_Init()
354 if ((hi2s->Init.Standard == I2S_STANDARD_PCM_SHORT) || in HAL_I2S_Init()
355 (hi2s->Init.Standard == I2S_STANDARD_PCM_LONG)) in HAL_I2S_Init()
366 if (hi2s->Instance == SPI6) in HAL_I2S_Init()
382 if (hi2s->Init.MCLKOutput == I2S_MCLKOUTPUT_ENABLE) in HAL_I2S_Init()
385 tmp = (uint32_t)((((i2sclk / (256UL >> ispcm)) * 10UL) / hi2s->Init.AudioFreq) + 5UL); in HAL_I2S_Init()
390 …tmp = (uint32_t)((((i2sclk / ((32UL >> ispcm) * packetlength)) * 10UL) / hi2s->Init.AudioFreq) + 5… in HAL_I2S_Init()
413 SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_PRESCALER); in HAL_I2S_Init()
423 MODIFY_REG(hi2s->Instance->I2SCFGR, (SPI_I2SCFGR_I2SDIV | SPI_I2SCFGR_ODD), in HAL_I2S_Init()
430 MODIFY_REG(hi2s->Instance->I2SCFGR, (SPI_I2SCFGR_I2SMOD | SPI_I2SCFGR_I2SCFG | \ in HAL_I2S_Init()
435 (SPI_I2SCFGR_I2SMOD | hi2s->Init.Mode | \ in HAL_I2S_Init()
436 hi2s->Init.Standard | hi2s->Init.DataFormat | \ in HAL_I2S_Init()
437 hi2s->Init.CPOL | hi2s->Init.WSInversion | \ in HAL_I2S_Init()
438 hi2s->Init.Data24BitAlignment | hi2s->Init.MCLKOutput)); in HAL_I2S_Init()
440 WRITE_REG(hi2s->Instance->IFCR, 0x0FF8); in HAL_I2S_Init()
445 CLEAR_BIT(hi2s->Instance->CR1, SPI_CR1_IOLOCK); in HAL_I2S_Init()
447 MODIFY_REG(hi2s->Instance->CFG2, SPI_CFG2_LSBFRST, hi2s->Init.FirstBit); in HAL_I2S_Init()
450 if (IS_I2S_MASTER(hi2s->Init.Mode)) in HAL_I2S_Init()
453 MODIFY_REG(hi2s->Instance->CFG2, SPI_CFG2_AFCNTR, (hi2s->Init.MasterKeepIOState)); in HAL_I2S_Init()
456 hi2s->ErrorCode = HAL_I2S_ERROR_NONE; in HAL_I2S_Init()
457 hi2s->State = HAL_I2S_STATE_READY; in HAL_I2S_Init()
468 HAL_StatusTypeDef HAL_I2S_DeInit(I2S_HandleTypeDef *hi2s) in HAL_I2S_DeInit() argument
471 if (hi2s == NULL) in HAL_I2S_DeInit()
477 assert_param(IS_I2S_ALL_INSTANCE(hi2s->Instance)); in HAL_I2S_DeInit()
479 hi2s->State = HAL_I2S_STATE_BUSY; in HAL_I2S_DeInit()
482 __HAL_I2S_DISABLE(hi2s); in HAL_I2S_DeInit()
485 if (hi2s->MspDeInitCallback == NULL) in HAL_I2S_DeInit()
487 hi2s->MspDeInitCallback = HAL_I2S_MspDeInit; /* Legacy weak MspDeInit */ in HAL_I2S_DeInit()
491 hi2s->MspDeInitCallback(hi2s); in HAL_I2S_DeInit()
494 HAL_I2S_MspDeInit(hi2s); in HAL_I2S_DeInit()
497 hi2s->ErrorCode = HAL_I2S_ERROR_NONE; in HAL_I2S_DeInit()
498 hi2s->State = HAL_I2S_STATE_RESET; in HAL_I2S_DeInit()
501 __HAL_UNLOCK(hi2s); in HAL_I2S_DeInit()
512 __weak void HAL_I2S_MspInit(I2S_HandleTypeDef *hi2s) in HAL_I2S_MspInit() argument
515 UNUSED(hi2s); in HAL_I2S_MspInit()
528 __weak void HAL_I2S_MspDeInit(I2S_HandleTypeDef *hi2s) in HAL_I2S_MspDeInit() argument
531 UNUSED(hi2s); in HAL_I2S_MspDeInit()
550 HAL_StatusTypeDef HAL_I2S_RegisterCallback(I2S_HandleTypeDef *hi2s, HAL_I2S_CallbackIDTypeDef Callb… in HAL_I2S_RegisterCallback() argument
558 hi2s->ErrorCode |= HAL_I2S_ERROR_INVALID_CALLBACK; in HAL_I2S_RegisterCallback()
563 if (HAL_I2S_STATE_READY == hi2s->State) in HAL_I2S_RegisterCallback()
568 hi2s->TxCpltCallback = pCallback; in HAL_I2S_RegisterCallback()
572 hi2s->RxCpltCallback = pCallback; in HAL_I2S_RegisterCallback()
576 hi2s->TxRxCpltCallback = pCallback; in HAL_I2S_RegisterCallback()
580 hi2s->TxHalfCpltCallback = pCallback; in HAL_I2S_RegisterCallback()
584 hi2s->RxHalfCpltCallback = pCallback; in HAL_I2S_RegisterCallback()
589 hi2s->TxRxHalfCpltCallback = pCallback; in HAL_I2S_RegisterCallback()
593 hi2s->ErrorCallback = pCallback; in HAL_I2S_RegisterCallback()
597 hi2s->MspInitCallback = pCallback; in HAL_I2S_RegisterCallback()
601 hi2s->MspDeInitCallback = pCallback; in HAL_I2S_RegisterCallback()
606 SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_INVALID_CALLBACK); in HAL_I2S_RegisterCallback()
613 else if (HAL_I2S_STATE_RESET == hi2s->State) in HAL_I2S_RegisterCallback()
618 hi2s->MspInitCallback = pCallback; in HAL_I2S_RegisterCallback()
622 hi2s->MspDeInitCallback = pCallback; in HAL_I2S_RegisterCallback()
627 SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_INVALID_CALLBACK); in HAL_I2S_RegisterCallback()
637 SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_INVALID_CALLBACK); in HAL_I2S_RegisterCallback()
656 HAL_StatusTypeDef HAL_I2S_UnRegisterCallback(I2S_HandleTypeDef *hi2s, HAL_I2S_CallbackIDTypeDef Cal… in HAL_I2S_UnRegisterCallback() argument
660 if (HAL_I2S_STATE_READY == hi2s->State) in HAL_I2S_UnRegisterCallback()
665 …hi2s->TxCpltCallback = HAL_I2S_TxCpltCallback; /* Legacy weak TxCpltCallback … in HAL_I2S_UnRegisterCallback()
669 …hi2s->RxCpltCallback = HAL_I2S_RxCpltCallback; /* Legacy weak RxCpltCallback … in HAL_I2S_UnRegisterCallback()
673 …hi2s->TxRxCpltCallback = HAL_I2SEx_TxRxCpltCallback; /* Legacy weak TxRxCpltCallback … in HAL_I2S_UnRegisterCallback()
677 …hi2s->TxHalfCpltCallback = HAL_I2S_TxHalfCpltCallback; /* Legacy weak TxHalfCpltCallback … in HAL_I2S_UnRegisterCallback()
681 …hi2s->RxHalfCpltCallback = HAL_I2S_RxHalfCpltCallback; /* Legacy weak RxHalfCpltCallback … in HAL_I2S_UnRegisterCallback()
685 …hi2s->TxRxHalfCpltCallback = HAL_I2SEx_TxRxHalfCpltCallback; /* Legacy weak TxRxHalfCpltCallback … in HAL_I2S_UnRegisterCallback()
689 …hi2s->ErrorCallback = HAL_I2S_ErrorCallback; /* Legacy weak ErrorCallback … in HAL_I2S_UnRegisterCallback()
693 …hi2s->MspInitCallback = HAL_I2S_MspInit; /* Legacy weak MspInit … in HAL_I2S_UnRegisterCallback()
697 …hi2s->MspDeInitCallback = HAL_I2S_MspDeInit; /* Legacy weak MspDeInit … in HAL_I2S_UnRegisterCallback()
702 SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_INVALID_CALLBACK); in HAL_I2S_UnRegisterCallback()
709 else if (HAL_I2S_STATE_RESET == hi2s->State) in HAL_I2S_UnRegisterCallback()
714 …hi2s->MspInitCallback = HAL_I2S_MspInit; /* Legacy weak MspInit … in HAL_I2S_UnRegisterCallback()
718 …hi2s->MspDeInitCallback = HAL_I2S_MspDeInit; /* Legacy weak MspDeInit … in HAL_I2S_UnRegisterCallback()
723 SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_INVALID_CALLBACK); in HAL_I2S_UnRegisterCallback()
733 SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_INVALID_CALLBACK); in HAL_I2S_UnRegisterCallback()
807 HAL_StatusTypeDef HAL_I2S_Transmit(I2S_HandleTypeDef *hi2s, const uint16_t *pData, uint16_t Size, u… in HAL_I2S_Transmit() argument
810 __IO uint16_t *ptxdr_16bits = (__IO uint16_t *)(&(hi2s->Instance->TXDR)); in HAL_I2S_Transmit()
819 if (hi2s->State != HAL_I2S_STATE_READY) in HAL_I2S_Transmit()
825 __HAL_LOCK(hi2s); in HAL_I2S_Transmit()
831 hi2s->State = HAL_I2S_STATE_BUSY_TX; in HAL_I2S_Transmit()
832 hi2s->ErrorCode = HAL_I2S_ERROR_NONE; in HAL_I2S_Transmit()
833 hi2s->pTxBuffPtr = (const uint16_t *)pData; in HAL_I2S_Transmit()
834 hi2s->TxXferSize = Size; in HAL_I2S_Transmit()
835 hi2s->TxXferCount = Size; in HAL_I2S_Transmit()
838 hi2s->pRxBuffPtr = NULL; in HAL_I2S_Transmit()
839 hi2s->RxXferSize = (uint16_t) 0UL; in HAL_I2S_Transmit()
840 hi2s->RxXferCount = (uint16_t) 0UL; in HAL_I2S_Transmit()
843 if ((hi2s->Instance->CR1 & SPI_CR1_SPE) != SPI_CR1_SPE) in HAL_I2S_Transmit()
846 __HAL_I2S_ENABLE(hi2s); in HAL_I2S_Transmit()
850 SET_BIT(hi2s->Instance->CR1, SPI_CR1_CSTART); in HAL_I2S_Transmit()
854 if (I2S_WaitFlagStateUntilTimeout(hi2s, I2S_FLAG_TXP, SET, tickstart, Timeout) != HAL_OK) in HAL_I2S_Transmit()
857 SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_TIMEOUT); in HAL_I2S_Transmit()
858 hi2s->State = HAL_I2S_STATE_READY; in HAL_I2S_Transmit()
859 __HAL_UNLOCK(hi2s); in HAL_I2S_Transmit()
863 while (hi2s->TxXferCount > 0UL) in HAL_I2S_Transmit()
865 …if ((hi2s->Init.DataFormat == I2S_DATAFORMAT_24B) || (hi2s->Init.DataFormat == I2S_DATAFORMAT_32B)) in HAL_I2S_Transmit()
868 hi2s->Instance->TXDR = *((const uint32_t *)hi2s->pTxBuffPtr); in HAL_I2S_Transmit()
869 hi2s->pTxBuffPtr += 2; in HAL_I2S_Transmit()
870 hi2s->TxXferCount--; in HAL_I2S_Transmit()
876 *ptxdr_16bits = *((const uint16_t *)hi2s->pTxBuffPtr); in HAL_I2S_Transmit()
878 *((__IO uint16_t *)&hi2s->Instance->TXDR) = *((const uint16_t *)hi2s->pTxBuffPtr); in HAL_I2S_Transmit()
881 hi2s->pTxBuffPtr++; in HAL_I2S_Transmit()
882 hi2s->TxXferCount--; in HAL_I2S_Transmit()
886 if (I2S_WaitFlagStateUntilTimeout(hi2s, I2S_FLAG_TXP, SET, tickstart, Timeout) != HAL_OK) in HAL_I2S_Transmit()
889 SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_TIMEOUT); in HAL_I2S_Transmit()
890 hi2s->State = HAL_I2S_STATE_READY; in HAL_I2S_Transmit()
891 __HAL_UNLOCK(hi2s); in HAL_I2S_Transmit()
896 if (__HAL_I2S_GET_FLAG(hi2s, I2S_FLAG_UDR) == SET) in HAL_I2S_Transmit()
899 __HAL_I2S_CLEAR_UDRFLAG(hi2s); in HAL_I2S_Transmit()
902 SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_UDR); in HAL_I2S_Transmit()
906 hi2s->State = HAL_I2S_STATE_READY; in HAL_I2S_Transmit()
907 __HAL_UNLOCK(hi2s); in HAL_I2S_Transmit()
928 HAL_StatusTypeDef HAL_I2S_Receive(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size, uint32_t… in HAL_I2S_Receive() argument
931 __IO uint16_t *prxdr_16bits = (__IO uint16_t *)(&(hi2s->Instance->RXDR)); in HAL_I2S_Receive()
940 if (hi2s->State != HAL_I2S_STATE_READY) in HAL_I2S_Receive()
946 __HAL_LOCK(hi2s); in HAL_I2S_Receive()
952 hi2s->State = HAL_I2S_STATE_BUSY_RX; in HAL_I2S_Receive()
953 hi2s->ErrorCode = HAL_I2S_ERROR_NONE; in HAL_I2S_Receive()
954 hi2s->pRxBuffPtr = pData; in HAL_I2S_Receive()
955 hi2s->RxXferSize = Size; in HAL_I2S_Receive()
956 hi2s->RxXferCount = Size; in HAL_I2S_Receive()
959 hi2s->pTxBuffPtr = NULL; in HAL_I2S_Receive()
960 hi2s->TxXferSize = (uint16_t) 0UL; in HAL_I2S_Receive()
961 hi2s->TxXferCount = (uint16_t) 0UL; in HAL_I2S_Receive()
964 if ((hi2s->Instance->CR1 & SPI_CR1_SPE) != SPI_CR1_SPE) in HAL_I2S_Receive()
967 __HAL_I2S_ENABLE(hi2s); in HAL_I2S_Receive()
971 SET_BIT(hi2s->Instance->CR1, SPI_CR1_CSTART); in HAL_I2S_Receive()
974 while (hi2s->RxXferCount > 0UL) in HAL_I2S_Receive()
977 if (I2S_WaitFlagStateUntilTimeout(hi2s, I2S_FLAG_RXP, SET, tickstart, Timeout) != HAL_OK) in HAL_I2S_Receive()
980 SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_TIMEOUT); in HAL_I2S_Receive()
981 hi2s->State = HAL_I2S_STATE_READY; in HAL_I2S_Receive()
982 __HAL_UNLOCK(hi2s); in HAL_I2S_Receive()
986 …if ((hi2s->Init.DataFormat == I2S_DATAFORMAT_24B) || (hi2s->Init.DataFormat == I2S_DATAFORMAT_32B)) in HAL_I2S_Receive()
989 *((uint32_t *)hi2s->pRxBuffPtr) = hi2s->Instance->RXDR; in HAL_I2S_Receive()
990 hi2s->pRxBuffPtr += 2; in HAL_I2S_Receive()
991 hi2s->RxXferCount--; in HAL_I2S_Receive()
997 *((uint16_t *)hi2s->pRxBuffPtr) = *prxdr_16bits; in HAL_I2S_Receive()
999 *((uint16_t *)hi2s->pRxBuffPtr) = *((__IO uint16_t *)&hi2s->Instance->RXDR); in HAL_I2S_Receive()
1001 hi2s->pRxBuffPtr++; in HAL_I2S_Receive()
1002 hi2s->RxXferCount--; in HAL_I2S_Receive()
1006 if (__HAL_I2S_GET_FLAG(hi2s, I2S_FLAG_OVR) == SET) in HAL_I2S_Receive()
1009 __HAL_I2S_CLEAR_OVRFLAG(hi2s); in HAL_I2S_Receive()
1012 SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_OVR); in HAL_I2S_Receive()
1016 hi2s->State = HAL_I2S_STATE_READY; in HAL_I2S_Receive()
1017 __HAL_UNLOCK(hi2s); in HAL_I2S_Receive()
1038 HAL_StatusTypeDef HAL_I2SEx_TransmitReceive(I2S_HandleTypeDef *hi2s, const uint16_t *pTxData, uint1… in HAL_I2SEx_TransmitReceive() argument
1046 __IO uint16_t *ptxdr_16bits = (__IO uint16_t *)(&(hi2s->Instance->TXDR)); in HAL_I2SEx_TransmitReceive()
1047 __IO uint16_t *prxdr_16bits = (__IO uint16_t *)(&(hi2s->Instance->RXDR)); in HAL_I2SEx_TransmitReceive()
1055 if (hi2s->State != HAL_I2S_STATE_READY) in HAL_I2SEx_TransmitReceive()
1061 __HAL_LOCK(hi2s); in HAL_I2SEx_TransmitReceive()
1066 hi2s->TxXferSize = Size; in HAL_I2SEx_TransmitReceive()
1067 hi2s->TxXferCount = Size; in HAL_I2SEx_TransmitReceive()
1068 hi2s->pTxBuffPtr = (const uint16_t *)pTxData; in HAL_I2SEx_TransmitReceive()
1069 hi2s->RxXferSize = Size; in HAL_I2SEx_TransmitReceive()
1070 hi2s->RxXferCount = Size; in HAL_I2SEx_TransmitReceive()
1071 hi2s->pRxBuffPtr = pRxData; in HAL_I2SEx_TransmitReceive()
1073 tmp_TxXferCount = hi2s->TxXferCount; in HAL_I2SEx_TransmitReceive()
1074 tmp_RxXferCount = hi2s->RxXferCount; in HAL_I2SEx_TransmitReceive()
1077 hi2s->ErrorCode = HAL_I2S_ERROR_NONE; in HAL_I2SEx_TransmitReceive()
1078 hi2s->State = HAL_I2S_STATE_BUSY_TX_RX; in HAL_I2SEx_TransmitReceive()
1081 if ((hi2s->Instance->CR1 & SPI_CR1_SPE) != SPI_CR1_SPE) in HAL_I2SEx_TransmitReceive()
1084 __HAL_I2S_ENABLE(hi2s); in HAL_I2SEx_TransmitReceive()
1088 SET_BIT(hi2s->Instance->CR1, SPI_CR1_CSTART); in HAL_I2SEx_TransmitReceive()
1092 if ((__HAL_I2S_GET_FLAG(hi2s, I2S_FLAG_TXP) == SET) && (tmp_TxXferCount != 0UL)) in HAL_I2SEx_TransmitReceive()
1094 …if ((hi2s->Init.DataFormat == I2S_DATAFORMAT_24B) || (hi2s->Init.DataFormat == I2S_DATAFORMAT_32B)) in HAL_I2SEx_TransmitReceive()
1097 hi2s->Instance->TXDR = *((const uint32_t *)hi2s->pTxBuffPtr); in HAL_I2SEx_TransmitReceive()
1098 hi2s->pTxBuffPtr += 2; in HAL_I2SEx_TransmitReceive()
1105 *ptxdr_16bits = *((const uint16_t *)hi2s->pTxBuffPtr); in HAL_I2SEx_TransmitReceive()
1107 *((__IO uint16_t *)&hi2s->Instance->TXDR) = *((const uint16_t *)hi2s->pTxBuffPtr); in HAL_I2SEx_TransmitReceive()
1110 hi2s->pTxBuffPtr++; in HAL_I2SEx_TransmitReceive()
1115 if (__HAL_I2S_GET_FLAG(hi2s, I2S_FLAG_UDR) == SET) in HAL_I2SEx_TransmitReceive()
1118 __HAL_I2S_CLEAR_UDRFLAG(hi2s); in HAL_I2SEx_TransmitReceive()
1121 SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_UDR); in HAL_I2SEx_TransmitReceive()
1125 if ((__HAL_I2S_GET_FLAG(hi2s, I2S_FLAG_RXP) == SET) && (tmp_RxXferCount != 0UL)) in HAL_I2SEx_TransmitReceive()
1127 …if ((hi2s->Init.DataFormat == I2S_DATAFORMAT_24B) || (hi2s->Init.DataFormat == I2S_DATAFORMAT_32B)) in HAL_I2SEx_TransmitReceive()
1130 *((uint32_t *)hi2s->pRxBuffPtr) = hi2s->Instance->RXDR; in HAL_I2SEx_TransmitReceive()
1131 hi2s->pRxBuffPtr += 2; in HAL_I2SEx_TransmitReceive()
1138 *((uint16_t *)hi2s->pRxBuffPtr) = *prxdr_16bits; in HAL_I2SEx_TransmitReceive()
1140 *((uint16_t *)hi2s->pRxBuffPtr) = *((__IO uint16_t *)&hi2s->Instance->RXDR); in HAL_I2SEx_TransmitReceive()
1142 hi2s->pRxBuffPtr++; in HAL_I2SEx_TransmitReceive()
1147 if (__HAL_I2S_GET_FLAG(hi2s, I2S_FLAG_OVR) == SET) in HAL_I2SEx_TransmitReceive()
1150 __HAL_I2S_CLEAR_OVRFLAG(hi2s); in HAL_I2SEx_TransmitReceive()
1153 SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_OVR); in HAL_I2SEx_TransmitReceive()
1161 SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_TIMEOUT); in HAL_I2SEx_TransmitReceive()
1162 hi2s->State = HAL_I2S_STATE_READY; in HAL_I2SEx_TransmitReceive()
1163 __HAL_UNLOCK(hi2s); in HAL_I2SEx_TransmitReceive()
1168 hi2s->State = HAL_I2S_STATE_READY; in HAL_I2SEx_TransmitReceive()
1169 __HAL_UNLOCK(hi2s); in HAL_I2SEx_TransmitReceive()
1187 HAL_StatusTypeDef HAL_I2S_Transmit_IT(I2S_HandleTypeDef *hi2s, const uint16_t *pData, uint16_t Size) in HAL_I2S_Transmit_IT() argument
1194 if (hi2s->State != HAL_I2S_STATE_READY) in HAL_I2S_Transmit_IT()
1200 __HAL_LOCK(hi2s); in HAL_I2S_Transmit_IT()
1203 hi2s->State = HAL_I2S_STATE_BUSY_TX; in HAL_I2S_Transmit_IT()
1204 hi2s->ErrorCode = HAL_I2S_ERROR_NONE; in HAL_I2S_Transmit_IT()
1205 hi2s->pTxBuffPtr = (const uint16_t *)pData; in HAL_I2S_Transmit_IT()
1206 hi2s->TxXferSize = Size; in HAL_I2S_Transmit_IT()
1207 hi2s->TxXferCount = Size; in HAL_I2S_Transmit_IT()
1210 hi2s->pRxBuffPtr = NULL; in HAL_I2S_Transmit_IT()
1211 hi2s->RxXferSize = (uint16_t) 0UL; in HAL_I2S_Transmit_IT()
1212 hi2s->RxXferCount = (uint16_t) 0UL; in HAL_I2S_Transmit_IT()
1215 …if ((hi2s->Init.DataFormat == I2S_DATAFORMAT_24B) || (hi2s->Init.DataFormat == I2S_DATAFORMAT_32B)) in HAL_I2S_Transmit_IT()
1217 hi2s->TxISR = I2S_Transmit_32Bit_IT; in HAL_I2S_Transmit_IT()
1221 hi2s->TxISR = I2S_Transmit_16Bit_IT; in HAL_I2S_Transmit_IT()
1225 if ((hi2s->Instance->CR1 & SPI_CR1_SPE) != SPI_CR1_SPE) in HAL_I2S_Transmit_IT()
1228 __HAL_I2S_ENABLE(hi2s); in HAL_I2S_Transmit_IT()
1232 __HAL_I2S_ENABLE_IT(hi2s, (I2S_IT_TXP | I2S_IT_UDR)); in HAL_I2S_Transmit_IT()
1235 if (hi2s->Init.Mode == I2S_MODE_SLAVE_TX) in HAL_I2S_Transmit_IT()
1237 __HAL_I2S_ENABLE_IT(hi2s, I2S_IT_FRE); in HAL_I2S_Transmit_IT()
1241 SET_BIT(hi2s->Instance->CR1, SPI_CR1_CSTART); in HAL_I2S_Transmit_IT()
1243 __HAL_UNLOCK(hi2s); in HAL_I2S_Transmit_IT()
1263 HAL_StatusTypeDef HAL_I2S_Receive_IT(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size) in HAL_I2S_Receive_IT() argument
1270 if (hi2s->State != HAL_I2S_STATE_READY) in HAL_I2S_Receive_IT()
1276 __HAL_LOCK(hi2s); in HAL_I2S_Receive_IT()
1279 hi2s->State = HAL_I2S_STATE_BUSY_RX; in HAL_I2S_Receive_IT()
1280 hi2s->ErrorCode = HAL_I2S_ERROR_NONE; in HAL_I2S_Receive_IT()
1281 hi2s->pRxBuffPtr = pData; in HAL_I2S_Receive_IT()
1282 hi2s->RxXferSize = Size; in HAL_I2S_Receive_IT()
1283 hi2s->RxXferCount = Size; in HAL_I2S_Receive_IT()
1286 hi2s->pTxBuffPtr = NULL; in HAL_I2S_Receive_IT()
1287 hi2s->TxXferSize = (uint16_t) 0UL; in HAL_I2S_Receive_IT()
1288 hi2s->TxXferCount = (uint16_t) 0UL; in HAL_I2S_Receive_IT()
1291 …if ((hi2s->Init.DataFormat == I2S_DATAFORMAT_24B) || (hi2s->Init.DataFormat == I2S_DATAFORMAT_32B)) in HAL_I2S_Receive_IT()
1293 hi2s->RxISR = I2S_Receive_32Bit_IT; in HAL_I2S_Receive_IT()
1297 hi2s->RxISR = I2S_Receive_16Bit_IT; in HAL_I2S_Receive_IT()
1301 if ((hi2s->Instance->CR1 & SPI_CR1_SPE) != SPI_CR1_SPE) in HAL_I2S_Receive_IT()
1304 __HAL_I2S_ENABLE(hi2s); in HAL_I2S_Receive_IT()
1307 __HAL_I2S_ENABLE_IT(hi2s, (I2S_IT_RXP | I2S_IT_OVR)); in HAL_I2S_Receive_IT()
1310 if (hi2s->Init.Mode == I2S_MODE_SLAVE_RX) in HAL_I2S_Receive_IT()
1312 __HAL_I2S_ENABLE_IT(hi2s, I2S_IT_FRE); in HAL_I2S_Receive_IT()
1316 SET_BIT(hi2s->Instance->CR1, SPI_CR1_CSTART); in HAL_I2S_Receive_IT()
1318 __HAL_UNLOCK(hi2s); in HAL_I2S_Receive_IT()
1337 HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_IT(I2S_HandleTypeDef *hi2s, const uint16_t *pTxData, ui… in HAL_I2SEx_TransmitReceive_IT() argument
1345 if (hi2s->State != HAL_I2S_STATE_READY) in HAL_I2SEx_TransmitReceive_IT()
1351 __HAL_LOCK(hi2s); in HAL_I2SEx_TransmitReceive_IT()
1353 hi2s->pTxBuffPtr = (const uint16_t *)pTxData; in HAL_I2SEx_TransmitReceive_IT()
1354 hi2s->pRxBuffPtr = pRxData; in HAL_I2SEx_TransmitReceive_IT()
1356 hi2s->TxXferSize = Size; in HAL_I2SEx_TransmitReceive_IT()
1357 hi2s->TxXferCount = Size; in HAL_I2SEx_TransmitReceive_IT()
1358 hi2s->RxXferSize = Size; in HAL_I2SEx_TransmitReceive_IT()
1359 hi2s->RxXferCount = Size; in HAL_I2SEx_TransmitReceive_IT()
1361 hi2s->ErrorCode = HAL_I2S_ERROR_NONE; in HAL_I2SEx_TransmitReceive_IT()
1362 hi2s->State = HAL_I2S_STATE_BUSY_TX_RX; in HAL_I2SEx_TransmitReceive_IT()
1366 …if ((hi2s->Init.DataFormat == I2S_DATAFORMAT_24B) || (hi2s->Init.DataFormat == I2S_DATAFORMAT_32B)) in HAL_I2SEx_TransmitReceive_IT()
1368 hi2s->TxISR = I2S_Transmit_32Bit_IT; in HAL_I2SEx_TransmitReceive_IT()
1369 hi2s->RxISR = I2S_Receive_32Bit_IT; in HAL_I2SEx_TransmitReceive_IT()
1373 hi2s->TxISR = I2S_Transmit_16Bit_IT; in HAL_I2SEx_TransmitReceive_IT()
1374 hi2s->RxISR = I2S_Receive_16Bit_IT; in HAL_I2SEx_TransmitReceive_IT()
1378 if ((hi2s->Instance->CR1 & SPI_CR1_SPE) != SPI_CR1_SPE) in HAL_I2SEx_TransmitReceive_IT()
1381 __HAL_I2S_ENABLE(hi2s); in HAL_I2SEx_TransmitReceive_IT()
1385 __HAL_I2S_ENABLE_IT(hi2s, (I2S_IT_TXP | I2S_IT_RXP | I2S_IT_DXP | I2S_IT_UDR | I2S_IT_OVR)); in HAL_I2SEx_TransmitReceive_IT()
1388 if (hi2s->Init.Mode == I2S_MODE_SLAVE_FULLDUPLEX) in HAL_I2SEx_TransmitReceive_IT()
1390 __HAL_I2S_ENABLE_IT(hi2s, I2S_IT_FRE); in HAL_I2SEx_TransmitReceive_IT()
1394 SET_BIT(hi2s->Instance->CR1, SPI_CR1_CSTART); in HAL_I2SEx_TransmitReceive_IT()
1396 __HAL_UNLOCK(hi2s); in HAL_I2SEx_TransmitReceive_IT()
1415 HAL_StatusTypeDef HAL_I2S_Transmit_DMA(I2S_HandleTypeDef *hi2s, const uint16_t *pData, uint16_t Siz… in HAL_I2S_Transmit_DMA() argument
1424 if (hi2s->State != HAL_I2S_STATE_READY) in HAL_I2S_Transmit_DMA()
1430 __HAL_LOCK(hi2s); in HAL_I2S_Transmit_DMA()
1433 hi2s->State = HAL_I2S_STATE_BUSY_TX; in HAL_I2S_Transmit_DMA()
1434 hi2s->ErrorCode = HAL_I2S_ERROR_NONE; in HAL_I2S_Transmit_DMA()
1435 hi2s->pTxBuffPtr = (const uint16_t *)pData; in HAL_I2S_Transmit_DMA()
1436 hi2s->TxXferSize = Size; in HAL_I2S_Transmit_DMA()
1437 hi2s->TxXferCount = Size; in HAL_I2S_Transmit_DMA()
1440 hi2s->pRxBuffPtr = NULL; in HAL_I2S_Transmit_DMA()
1441 hi2s->RxXferSize = (uint16_t)0UL; in HAL_I2S_Transmit_DMA()
1442 hi2s->RxXferCount = (uint16_t)0UL; in HAL_I2S_Transmit_DMA()
1445 hi2s->hdmatx->XferHalfCpltCallback = I2S_DMATxHalfCplt; in HAL_I2S_Transmit_DMA()
1448 hi2s->hdmatx->XferCpltCallback = I2S_DMATxCplt; in HAL_I2S_Transmit_DMA()
1451 hi2s->hdmatx->XferErrorCallback = I2S_DMAError; in HAL_I2S_Transmit_DMA()
1454 …if (HAL_OK != HAL_DMA_Start_IT(hi2s->hdmatx, (uint32_t)hi2s->pTxBuffPtr, (uint32_t)&hi2s->Instance… in HAL_I2S_Transmit_DMA()
1455 hi2s->TxXferCount)) in HAL_I2S_Transmit_DMA()
1458 SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_DMA); in HAL_I2S_Transmit_DMA()
1459 hi2s->State = HAL_I2S_STATE_READY; in HAL_I2S_Transmit_DMA()
1461 __HAL_UNLOCK(hi2s); in HAL_I2S_Transmit_DMA()
1467 if (HAL_IS_BIT_CLR(hi2s->Instance->CFG1, SPI_CFG1_TXDMAEN)) in HAL_I2S_Transmit_DMA()
1470 SET_BIT(hi2s->Instance->CFG1, SPI_CFG1_TXDMAEN); in HAL_I2S_Transmit_DMA()
1474 if (HAL_IS_BIT_CLR(hi2s->Instance->CR1, SPI_CR1_SPE)) in HAL_I2S_Transmit_DMA()
1477 __HAL_I2S_ENABLE(hi2s); in HAL_I2S_Transmit_DMA()
1481 SET_BIT(hi2s->Instance->CR1, SPI_CR1_CSTART); in HAL_I2S_Transmit_DMA()
1483 __HAL_UNLOCK(hi2s); in HAL_I2S_Transmit_DMA()
1501 HAL_StatusTypeDef HAL_I2S_Receive_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size) in HAL_I2S_Receive_DMA() argument
1510 if (hi2s->State != HAL_I2S_STATE_READY) in HAL_I2S_Receive_DMA()
1516 __HAL_LOCK(hi2s); in HAL_I2S_Receive_DMA()
1519 hi2s->State = HAL_I2S_STATE_BUSY_RX; in HAL_I2S_Receive_DMA()
1520 hi2s->ErrorCode = HAL_I2S_ERROR_NONE; in HAL_I2S_Receive_DMA()
1521 hi2s->pRxBuffPtr = pData; in HAL_I2S_Receive_DMA()
1522 hi2s->RxXferSize = Size; in HAL_I2S_Receive_DMA()
1523 hi2s->RxXferCount = Size; in HAL_I2S_Receive_DMA()
1526 hi2s->pTxBuffPtr = NULL; in HAL_I2S_Receive_DMA()
1527 hi2s->TxXferSize = (uint16_t)0UL; in HAL_I2S_Receive_DMA()
1528 hi2s->TxXferCount = (uint16_t)0UL; in HAL_I2S_Receive_DMA()
1532 hi2s->hdmarx->XferHalfCpltCallback = I2S_DMARxHalfCplt; in HAL_I2S_Receive_DMA()
1535 hi2s->hdmarx->XferCpltCallback = I2S_DMARxCplt; in HAL_I2S_Receive_DMA()
1538 hi2s->hdmarx->XferErrorCallback = I2S_DMAError; in HAL_I2S_Receive_DMA()
1541 …if (HAL_OK != HAL_DMA_Start_IT(hi2s->hdmarx, (uint32_t)&hi2s->Instance->RXDR, (uint32_t)hi2s->pRxB… in HAL_I2S_Receive_DMA()
1542 hi2s->RxXferCount)) in HAL_I2S_Receive_DMA()
1545 SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_DMA); in HAL_I2S_Receive_DMA()
1546 hi2s->State = HAL_I2S_STATE_READY; in HAL_I2S_Receive_DMA()
1548 __HAL_UNLOCK(hi2s); in HAL_I2S_Receive_DMA()
1553 if (HAL_IS_BIT_CLR(hi2s->Instance->CFG1, SPI_CFG1_RXDMAEN)) in HAL_I2S_Receive_DMA()
1556 SET_BIT(hi2s->Instance->CFG1, SPI_CFG1_RXDMAEN); in HAL_I2S_Receive_DMA()
1560 if (HAL_IS_BIT_CLR(hi2s->Instance->CR1, SPI_CR1_SPE)) in HAL_I2S_Receive_DMA()
1563 __HAL_I2S_ENABLE(hi2s); in HAL_I2S_Receive_DMA()
1567 SET_BIT(hi2s->Instance->CR1, SPI_CR1_CSTART); in HAL_I2S_Receive_DMA()
1569 __HAL_UNLOCK(hi2s); in HAL_I2S_Receive_DMA()
1588 HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_DMA(I2S_HandleTypeDef *hi2s, const uint16_t *pTxData, u… in HAL_I2SEx_TransmitReceive_DMA() argument
1599 if (hi2s->State != HAL_I2S_STATE_READY) in HAL_I2SEx_TransmitReceive_DMA()
1605 __HAL_LOCK(hi2s); in HAL_I2SEx_TransmitReceive_DMA()
1607 hi2s->pTxBuffPtr = (const uint16_t *)pTxData; in HAL_I2SEx_TransmitReceive_DMA()
1608 hi2s->pRxBuffPtr = pRxData; in HAL_I2SEx_TransmitReceive_DMA()
1610 hi2s->TxXferSize = Size; in HAL_I2SEx_TransmitReceive_DMA()
1611 hi2s->TxXferCount = Size; in HAL_I2SEx_TransmitReceive_DMA()
1612 hi2s->RxXferSize = Size; in HAL_I2SEx_TransmitReceive_DMA()
1613 hi2s->RxXferCount = Size; in HAL_I2SEx_TransmitReceive_DMA()
1615 hi2s->ErrorCode = HAL_I2S_ERROR_NONE; in HAL_I2SEx_TransmitReceive_DMA()
1616 hi2s->State = HAL_I2S_STATE_BUSY_TX_RX; in HAL_I2SEx_TransmitReceive_DMA()
1619 CLEAR_BIT(hi2s->Instance->CFG1, SPI_CFG1_TXDMAEN | SPI_CFG1_RXDMAEN); in HAL_I2SEx_TransmitReceive_DMA()
1622 hi2s->hdmarx->XferHalfCpltCallback = I2SEx_DMATxRxHalfCplt; in HAL_I2SEx_TransmitReceive_DMA()
1625 hi2s->hdmarx->XferCpltCallback = I2SEx_DMATxRxCplt; in HAL_I2SEx_TransmitReceive_DMA()
1628 hi2s->hdmarx->XferErrorCallback = I2S_DMAError; in HAL_I2SEx_TransmitReceive_DMA()
1630 …if (HAL_OK != HAL_DMA_Start_IT(hi2s->hdmatx, (uint32_t)hi2s->pTxBuffPtr, (uint32_t)&hi2s->Instance… in HAL_I2SEx_TransmitReceive_DMA()
1631 hi2s->TxXferCount)) in HAL_I2SEx_TransmitReceive_DMA()
1634 SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_DMA); in HAL_I2SEx_TransmitReceive_DMA()
1635 hi2s->State = HAL_I2S_STATE_READY; in HAL_I2SEx_TransmitReceive_DMA()
1637 __HAL_UNLOCK(hi2s); in HAL_I2SEx_TransmitReceive_DMA()
1643 if (HAL_IS_BIT_CLR(hi2s->Instance->CFG1, SPI_CFG1_TXDMAEN)) in HAL_I2SEx_TransmitReceive_DMA()
1646 SET_BIT(hi2s->Instance->CFG1, SPI_CFG1_TXDMAEN); in HAL_I2SEx_TransmitReceive_DMA()
1650 …if (HAL_OK != HAL_DMA_Start_IT(hi2s->hdmarx, (uint32_t)&hi2s->Instance->RXDR, (uint32_t)hi2s->pRxB… in HAL_I2SEx_TransmitReceive_DMA()
1651 hi2s->RxXferCount)) in HAL_I2SEx_TransmitReceive_DMA()
1654 SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_DMA); in HAL_I2SEx_TransmitReceive_DMA()
1655 hi2s->State = HAL_I2S_STATE_READY; in HAL_I2SEx_TransmitReceive_DMA()
1657 __HAL_UNLOCK(hi2s); in HAL_I2SEx_TransmitReceive_DMA()
1662 if (HAL_IS_BIT_CLR(hi2s->Instance->CFG1, SPI_CFG1_RXDMAEN)) in HAL_I2SEx_TransmitReceive_DMA()
1665 SET_BIT(hi2s->Instance->CFG1, SPI_CFG1_RXDMAEN); in HAL_I2SEx_TransmitReceive_DMA()
1669 if (HAL_IS_BIT_CLR(hi2s->Instance->CR1, SPI_CR1_SPE)) in HAL_I2SEx_TransmitReceive_DMA()
1672 __HAL_I2S_ENABLE(hi2s); in HAL_I2SEx_TransmitReceive_DMA()
1676 SET_BIT(hi2s->Instance->CR1, SPI_CR1_CSTART); in HAL_I2SEx_TransmitReceive_DMA()
1678 __HAL_UNLOCK(hi2s); in HAL_I2SEx_TransmitReceive_DMA()
1688 HAL_StatusTypeDef HAL_I2S_DMAPause(I2S_HandleTypeDef *hi2s) in HAL_I2S_DMAPause() argument
1691 __HAL_LOCK(hi2s); in HAL_I2S_DMAPause()
1700 if (IS_I2S_MASTER(hi2s->Init.Mode)) in HAL_I2S_DMAPause()
1703 if (HAL_IS_BIT_SET(hi2s->Instance->CR1, SPI_CR1_CSTART) == 0UL) in HAL_I2S_DMAPause()
1706 SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_NO_OGT); in HAL_I2S_DMAPause()
1707 hi2s->State = HAL_I2S_STATE_READY; in HAL_I2S_DMAPause()
1709 __HAL_UNLOCK(hi2s); in HAL_I2S_DMAPause()
1713 SET_BIT(hi2s->Instance->CR1, SPI_CR1_CSUSP); in HAL_I2S_DMAPause()
1715 while (HAL_IS_BIT_SET(hi2s->Instance->CR1, SPI_CR1_CSTART) != 0UL) in HAL_I2S_DMAPause()
1720 hi2s->State = HAL_I2S_STATE_READY; in HAL_I2S_DMAPause()
1723 __HAL_UNLOCK(hi2s); in HAL_I2S_DMAPause()
1725 SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_TIMEOUT); in HAL_I2S_DMAPause()
1726 hi2s->State = HAL_I2S_STATE_READY; in HAL_I2S_DMAPause()
1732 __HAL_I2S_DISABLE(hi2s); in HAL_I2S_DMAPause()
1734 hi2s->State = HAL_I2S_STATE_READY; in HAL_I2S_DMAPause()
1737 __HAL_UNLOCK(hi2s); in HAL_I2S_DMAPause()
1744 SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_NOT_SUPPORTED); in HAL_I2S_DMAPause()
1745 hi2s->State = HAL_I2S_STATE_READY; in HAL_I2S_DMAPause()
1748 __HAL_UNLOCK(hi2s); in HAL_I2S_DMAPause()
1760 HAL_StatusTypeDef HAL_I2S_DMAResume(I2S_HandleTypeDef *hi2s) in HAL_I2S_DMAResume() argument
1763 __HAL_LOCK(hi2s); in HAL_I2S_DMAResume()
1765 if (hi2s->State != HAL_I2S_STATE_READY) in HAL_I2S_DMAResume()
1767 hi2s->State = HAL_I2S_STATE_READY; in HAL_I2S_DMAResume()
1769 __HAL_UNLOCK(hi2s); in HAL_I2S_DMAResume()
1774 hi2s->State = HAL_I2S_STATE_BUSY; in HAL_I2S_DMAResume()
1775 hi2s->ErrorCode = HAL_I2S_ERROR_NONE; in HAL_I2S_DMAResume()
1778 __HAL_I2S_ENABLE(hi2s); in HAL_I2S_DMAResume()
1781 SET_BIT(hi2s->Instance->CR1, SPI_CR1_CSTART); in HAL_I2S_DMAResume()
1784 __HAL_UNLOCK(hi2s); in HAL_I2S_DMAResume()
1795 HAL_StatusTypeDef HAL_I2S_DMAStop(I2S_HandleTypeDef *hi2s) in HAL_I2S_DMAStop() argument
1805 CLEAR_BIT(hi2s->Instance->CFG1, SPI_CFG1_TXDMAEN); in HAL_I2S_DMAStop()
1806 CLEAR_BIT(hi2s->Instance->CFG1, SPI_CFG1_RXDMAEN); in HAL_I2S_DMAStop()
1809 if (hi2s->hdmatx != NULL) in HAL_I2S_DMAStop()
1812 if (HAL_OK != HAL_DMA_Abort(hi2s->hdmatx)) in HAL_I2S_DMAStop()
1814 SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_DMA); in HAL_I2S_DMAStop()
1820 if (hi2s->hdmarx != NULL) in HAL_I2S_DMAStop()
1823 if (HAL_OK != HAL_DMA_Abort(hi2s->hdmarx)) in HAL_I2S_DMAStop()
1825 SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_DMA); in HAL_I2S_DMAStop()
1831 __HAL_I2S_DISABLE(hi2s); in HAL_I2S_DMAStop()
1833 hi2s->State = HAL_I2S_STATE_READY; in HAL_I2S_DMAStop()
1847 HAL_StatusTypeDef HAL_I2S_EnableIOSwap(I2S_HandleTypeDef *hi2s) in HAL_I2S_EnableIOSwap() argument
1850 if (hi2s == NULL) in HAL_I2S_EnableIOSwap()
1856 if (hi2s->State != HAL_I2S_STATE_READY) in HAL_I2S_EnableIOSwap()
1862 if (READ_BIT(hi2s->Instance->CR1, SPI_CR1_IOLOCK) == (SPI_CR1_IOLOCK)) in HAL_I2S_EnableIOSwap()
1868 if ((hi2s->Instance->CR1 & SPI_CR1_SPE) == SPI_CR1_SPE) in HAL_I2S_EnableIOSwap()
1871 __HAL_I2S_DISABLE(hi2s); in HAL_I2S_EnableIOSwap()
1875 SET_BIT(hi2s->Instance->CFG2, SPI_CFG2_IOSWP); in HAL_I2S_EnableIOSwap()
1889 HAL_StatusTypeDef HAL_I2S_DisableIOSwap(I2S_HandleTypeDef *hi2s) in HAL_I2S_DisableIOSwap() argument
1892 if (hi2s == NULL) in HAL_I2S_DisableIOSwap()
1898 if (hi2s->State != HAL_I2S_STATE_READY) in HAL_I2S_DisableIOSwap()
1904 if (READ_BIT(hi2s->Instance->CR1, SPI_CR1_IOLOCK) == (SPI_CR1_IOLOCK)) in HAL_I2S_DisableIOSwap()
1910 if ((hi2s->Instance->CR1 & SPI_CR1_SPE) == SPI_CR1_SPE) in HAL_I2S_DisableIOSwap()
1913 __HAL_I2S_DISABLE(hi2s); in HAL_I2S_DisableIOSwap()
1917 CLEAR_BIT(hi2s->Instance->CFG2, SPI_CFG2_IOSWP); in HAL_I2S_DisableIOSwap()
1928 uint32_t HAL_I2S_IsEnabledIOSwap(const I2S_HandleTypeDef *hi2s) in HAL_I2S_IsEnabledIOSwap() argument
1931 if (hi2s == NULL) in HAL_I2S_IsEnabledIOSwap()
1936 return ((READ_BIT(hi2s->Instance->CFG2, SPI_CFG2_IOSWP) == (SPI_CFG2_IOSWP)) ? 1UL : 0UL); in HAL_I2S_IsEnabledIOSwap()
1945 void HAL_I2S_IRQHandler(I2S_HandleTypeDef *hi2s) in HAL_I2S_IRQHandler() argument
1947 uint32_t i2sier = hi2s->Instance->IER; in HAL_I2S_IRQHandler()
1948 uint32_t i2ssr = hi2s->Instance->SR; in HAL_I2S_IRQHandler()
1951 if (hi2s->State == HAL_I2S_STATE_BUSY_RX) in HAL_I2S_IRQHandler()
1956 hi2s->RxISR(hi2s); in HAL_I2S_IRQHandler()
1963 __HAL_I2S_DISABLE_IT(hi2s, (I2S_IT_RXP | I2S_IT_ERR)); in HAL_I2S_IRQHandler()
1966 __HAL_I2S_CLEAR_OVRFLAG(hi2s); in HAL_I2S_IRQHandler()
1969 hi2s->State = HAL_I2S_STATE_READY; in HAL_I2S_IRQHandler()
1973 SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_OVR); in HAL_I2S_IRQHandler()
1976 hi2s->ErrorCallback(hi2s); in HAL_I2S_IRQHandler()
1978 HAL_I2S_ErrorCallback(hi2s); in HAL_I2S_IRQHandler()
1983 if (hi2s->State == HAL_I2S_STATE_BUSY_TX) in HAL_I2S_IRQHandler()
1988 hi2s->TxISR(hi2s); in HAL_I2S_IRQHandler()
1995 __HAL_I2S_DISABLE_IT(hi2s, (I2S_IT_TXP | I2S_IT_ERR)); in HAL_I2S_IRQHandler()
1998 __HAL_I2S_CLEAR_UDRFLAG(hi2s); in HAL_I2S_IRQHandler()
2001 hi2s->State = HAL_I2S_STATE_READY; in HAL_I2S_IRQHandler()
2004 SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_UDR); in HAL_I2S_IRQHandler()
2007 hi2s->ErrorCallback(hi2s); in HAL_I2S_IRQHandler()
2009 HAL_I2S_ErrorCallback(hi2s); in HAL_I2S_IRQHandler()
2013 if (hi2s->State == HAL_I2S_STATE_BUSY_TX_RX) in HAL_I2S_IRQHandler()
2018 hi2s->TxISR(hi2s); in HAL_I2S_IRQHandler()
2019 hi2s->RxISR(hi2s); in HAL_I2S_IRQHandler()
2024 hi2s->RxISR(hi2s); in HAL_I2S_IRQHandler()
2029 hi2s->TxISR(hi2s); in HAL_I2S_IRQHandler()
2036 __HAL_I2S_DISABLE_IT(hi2s, (I2S_IT_TXP | I2S_IT_RXP | I2S_IT_ERR)); in HAL_I2S_IRQHandler()
2039 __HAL_I2S_CLEAR_UDRFLAG(hi2s); in HAL_I2S_IRQHandler()
2042 hi2s->State = HAL_I2S_STATE_READY; in HAL_I2S_IRQHandler()
2045 SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_UDR); in HAL_I2S_IRQHandler()
2048 hi2s->ErrorCallback(hi2s); in HAL_I2S_IRQHandler()
2050 HAL_I2S_ErrorCallback(hi2s); in HAL_I2S_IRQHandler()
2058 __HAL_I2S_DISABLE_IT(hi2s, (I2S_IT_TXP | I2S_IT_RXP | I2S_IT_ERR)); in HAL_I2S_IRQHandler()
2061 __HAL_I2S_CLEAR_OVRFLAG(hi2s); in HAL_I2S_IRQHandler()
2064 hi2s->State = HAL_I2S_STATE_READY; in HAL_I2S_IRQHandler()
2068 SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_OVR); in HAL_I2S_IRQHandler()
2072 hi2s->ErrorCallback(hi2s); in HAL_I2S_IRQHandler()
2074 HAL_I2S_ErrorCallback(hi2s); in HAL_I2S_IRQHandler()
2086 __weak void HAL_I2S_TxHalfCpltCallback(I2S_HandleTypeDef *hi2s) in HAL_I2S_TxHalfCpltCallback() argument
2089 UNUSED(hi2s); in HAL_I2S_TxHalfCpltCallback()
2102 __weak void HAL_I2S_TxCpltCallback(I2S_HandleTypeDef *hi2s) in HAL_I2S_TxCpltCallback() argument
2105 UNUSED(hi2s); in HAL_I2S_TxCpltCallback()
2118 __weak void HAL_I2S_RxHalfCpltCallback(I2S_HandleTypeDef *hi2s) in HAL_I2S_RxHalfCpltCallback() argument
2121 UNUSED(hi2s); in HAL_I2S_RxHalfCpltCallback()
2134 __weak void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s) in HAL_I2S_RxCpltCallback() argument
2137 UNUSED(hi2s); in HAL_I2S_RxCpltCallback()
2150 __weak void HAL_I2SEx_TxRxHalfCpltCallback(I2S_HandleTypeDef *hi2s) in HAL_I2SEx_TxRxHalfCpltCallback() argument
2153 UNUSED(hi2s); in HAL_I2SEx_TxRxHalfCpltCallback()
2166 __weak void HAL_I2SEx_TxRxCpltCallback(I2S_HandleTypeDef *hi2s) in HAL_I2SEx_TxRxCpltCallback() argument
2169 UNUSED(hi2s); in HAL_I2SEx_TxRxCpltCallback()
2182 __weak void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s) in HAL_I2S_ErrorCallback() argument
2185 UNUSED(hi2s); in HAL_I2S_ErrorCallback()
2217 HAL_I2S_StateTypeDef HAL_I2S_GetState(const I2S_HandleTypeDef *hi2s) in HAL_I2S_GetState() argument
2219 return hi2s->State; in HAL_I2S_GetState()
2228 uint32_t HAL_I2S_GetError(const I2S_HandleTypeDef *hi2s) in HAL_I2S_GetError() argument
2230 return hi2s->ErrorCode; in HAL_I2S_GetError()
2252 I2S_HandleTypeDef *hi2s = (I2S_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent; in I2S_DMATxCplt() local
2258 CLEAR_BIT(hi2s->Instance->CFG1, SPI_CFG1_TXDMAEN); in I2S_DMATxCplt()
2260 hi2s->TxXferCount = (uint16_t) 0UL; in I2S_DMATxCplt()
2261 hi2s->State = HAL_I2S_STATE_READY; in I2S_DMATxCplt()
2265 hi2s->TxCpltCallback(hi2s); in I2S_DMATxCplt()
2267 HAL_I2S_TxCpltCallback(hi2s); in I2S_DMATxCplt()
2280 I2S_HandleTypeDef *hi2s = (I2S_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent; in I2S_DMATxHalfCplt() local
2284 hi2s->TxHalfCpltCallback(hi2s); in I2S_DMATxHalfCplt()
2286 HAL_I2S_TxHalfCpltCallback(hi2s); in I2S_DMATxHalfCplt()
2299 I2S_HandleTypeDef *hi2s = (I2S_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent; in I2S_DMARxCplt() local
2305 CLEAR_BIT(hi2s->Instance->CFG1, SPI_CFG1_RXDMAEN); in I2S_DMARxCplt()
2306 hi2s->RxXferCount = (uint16_t)0UL; in I2S_DMARxCplt()
2307 hi2s->State = HAL_I2S_STATE_READY; in I2S_DMARxCplt()
2311 hi2s->RxCpltCallback(hi2s); in I2S_DMARxCplt()
2313 HAL_I2S_RxCpltCallback(hi2s); in I2S_DMARxCplt()
2326 I2S_HandleTypeDef *hi2s = (I2S_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent; in I2S_DMARxHalfCplt() local
2330 hi2s->RxHalfCpltCallback(hi2s); in I2S_DMARxHalfCplt()
2332 HAL_I2S_RxHalfCpltCallback(hi2s); in I2S_DMARxHalfCplt()
2344 I2S_HandleTypeDef *hi2s = (I2S_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent; in I2SEx_DMATxRxCplt() local
2350 CLEAR_BIT(hi2s->Instance->CFG1, SPI_CFG1_TXDMAEN); in I2SEx_DMATxRxCplt()
2351 hi2s->TxXferCount = (uint16_t) 0UL; in I2SEx_DMATxRxCplt()
2354 CLEAR_BIT(hi2s->Instance->CFG1, SPI_CFG1_RXDMAEN); in I2SEx_DMATxRxCplt()
2355 hi2s->RxXferCount = (uint16_t)0UL; in I2SEx_DMATxRxCplt()
2358 hi2s->State = HAL_I2S_STATE_READY; in I2SEx_DMATxRxCplt()
2363 hi2s->TxRxCpltCallback(hi2s); in I2SEx_DMATxRxCplt()
2365 HAL_I2SEx_TxRxCpltCallback(hi2s); in I2SEx_DMATxRxCplt()
2377 I2S_HandleTypeDef *hi2s = (I2S_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent; in I2SEx_DMATxRxHalfCplt() local
2381 hi2s->TxRxHalfCpltCallback(hi2s); in I2SEx_DMATxRxHalfCplt()
2383 HAL_I2SEx_TxRxHalfCpltCallback(hi2s); in I2SEx_DMATxRxHalfCplt()
2396 I2S_HandleTypeDef *hi2s = (I2S_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent; in I2S_DMAError() local
2399 CLEAR_BIT(hi2s->Instance->CFG1, (SPI_CFG1_RXDMAEN | SPI_CFG1_TXDMAEN)); in I2S_DMAError()
2400 hi2s->TxXferCount = (uint16_t) 0UL; in I2S_DMAError()
2401 hi2s->RxXferCount = (uint16_t) 0UL; in I2S_DMAError()
2403 hi2s->State = HAL_I2S_STATE_READY; in I2S_DMAError()
2406 SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_DMA); in I2S_DMAError()
2409 hi2s->ErrorCallback(hi2s); in I2S_DMAError()
2411 HAL_I2S_ErrorCallback(hi2s); in I2S_DMAError()
2421 static void I2S_Transmit_16Bit_IT(I2S_HandleTypeDef *hi2s) in I2S_Transmit_16Bit_IT() argument
2425 __IO uint16_t *ptxdr_16bits = (__IO uint16_t *)(&(hi2s->Instance->TXDR)); in I2S_Transmit_16Bit_IT()
2427 *ptxdr_16bits = *((const uint16_t *)hi2s->pTxBuffPtr); in I2S_Transmit_16Bit_IT()
2429 *((__IO uint16_t *)&hi2s->Instance->TXDR) = *((const uint16_t *)hi2s->pTxBuffPtr); in I2S_Transmit_16Bit_IT()
2431 hi2s->pTxBuffPtr++; in I2S_Transmit_16Bit_IT()
2432 hi2s->TxXferCount--; in I2S_Transmit_16Bit_IT()
2434 if (hi2s->TxXferCount == 0UL) in I2S_Transmit_16Bit_IT()
2437 __HAL_I2S_DISABLE_IT(hi2s, (I2S_IT_TXP | I2S_IT_ERR)); in I2S_Transmit_16Bit_IT()
2439 if ((hi2s->Init.Mode == I2S_MODE_SLAVE_TX) || (hi2s->Init.Mode == I2S_MODE_MASTER_TX)) in I2S_Transmit_16Bit_IT()
2441 hi2s->State = HAL_I2S_STATE_READY; in I2S_Transmit_16Bit_IT()
2445 hi2s->TxCpltCallback(hi2s); in I2S_Transmit_16Bit_IT()
2447 HAL_I2S_TxCpltCallback(hi2s); in I2S_Transmit_16Bit_IT()
2459 static void I2S_Transmit_32Bit_IT(I2S_HandleTypeDef *hi2s) in I2S_Transmit_32Bit_IT() argument
2462 hi2s->Instance->TXDR = *((const uint32_t *)hi2s->pTxBuffPtr); in I2S_Transmit_32Bit_IT()
2463 hi2s->pTxBuffPtr += 2; in I2S_Transmit_32Bit_IT()
2464 hi2s->TxXferCount--; in I2S_Transmit_32Bit_IT()
2466 if (hi2s->TxXferCount == 0UL) in I2S_Transmit_32Bit_IT()
2469 __HAL_I2S_DISABLE_IT(hi2s, (I2S_IT_TXP | I2S_IT_ERR)); in I2S_Transmit_32Bit_IT()
2471 if ((hi2s->Init.Mode == I2S_MODE_SLAVE_TX) || (hi2s->Init.Mode == I2S_MODE_MASTER_TX)) in I2S_Transmit_32Bit_IT()
2473 hi2s->State = HAL_I2S_STATE_READY; in I2S_Transmit_32Bit_IT()
2477 hi2s->TxCpltCallback(hi2s); in I2S_Transmit_32Bit_IT()
2479 HAL_I2S_TxCpltCallback(hi2s); in I2S_Transmit_32Bit_IT()
2491 static void I2S_Receive_16Bit_IT(I2S_HandleTypeDef *hi2s) in I2S_Receive_16Bit_IT() argument
2495 __IO uint16_t *prxdr_16bits = (__IO uint16_t *)(&(hi2s->Instance->RXDR)); in I2S_Receive_16Bit_IT()
2497 *((uint16_t *)hi2s->pRxBuffPtr) = *prxdr_16bits; in I2S_Receive_16Bit_IT()
2499 *((uint16_t *)hi2s->pRxBuffPtr) = *((__IO uint16_t *)&hi2s->Instance->RXDR); in I2S_Receive_16Bit_IT()
2501 hi2s->pRxBuffPtr++; in I2S_Receive_16Bit_IT()
2502 hi2s->RxXferCount--; in I2S_Receive_16Bit_IT()
2504 if (hi2s->RxXferCount == 0UL) in I2S_Receive_16Bit_IT()
2506 if (IS_I2S_FULLDUPLEX(hi2s->Init.Mode)) in I2S_Receive_16Bit_IT()
2509 __HAL_I2S_DISABLE_IT(hi2s, (I2S_IT_TXP | I2S_IT_RXP | I2S_IT_DXP | I2S_IT_ERR)); in I2S_Receive_16Bit_IT()
2514 __HAL_I2S_DISABLE_IT(hi2s, (I2S_IT_RXP | I2S_IT_ERR)); in I2S_Receive_16Bit_IT()
2517 hi2s->State = HAL_I2S_STATE_READY; in I2S_Receive_16Bit_IT()
2520 if (IS_I2S_FULLDUPLEX(hi2s->Init.Mode)) in I2S_Receive_16Bit_IT()
2522 hi2s->TxRxCpltCallback(hi2s); in I2S_Receive_16Bit_IT()
2526 hi2s->RxCpltCallback(hi2s); in I2S_Receive_16Bit_IT()
2529 if (IS_I2S_FULLDUPLEX(hi2s->Init.Mode)) in I2S_Receive_16Bit_IT()
2531 HAL_I2SEx_TxRxCpltCallback(hi2s); in I2S_Receive_16Bit_IT()
2535 HAL_I2S_RxCpltCallback(hi2s); in I2S_Receive_16Bit_IT()
2547 static void I2S_Receive_32Bit_IT(I2S_HandleTypeDef *hi2s) in I2S_Receive_32Bit_IT() argument
2550 *((uint32_t *)hi2s->pRxBuffPtr) = hi2s->Instance->RXDR; in I2S_Receive_32Bit_IT()
2551 hi2s->pRxBuffPtr += 2; in I2S_Receive_32Bit_IT()
2552 hi2s->RxXferCount--; in I2S_Receive_32Bit_IT()
2554 if (hi2s->RxXferCount == 0UL) in I2S_Receive_32Bit_IT()
2556 if (IS_I2S_FULLDUPLEX(hi2s->Init.Mode)) in I2S_Receive_32Bit_IT()
2559 __HAL_I2S_DISABLE_IT(hi2s, (I2S_IT_TXP | I2S_IT_RXP | I2S_IT_DXP | I2S_IT_ERR)); in I2S_Receive_32Bit_IT()
2564 __HAL_I2S_DISABLE_IT(hi2s, (I2S_IT_RXP | I2S_IT_ERR)); in I2S_Receive_32Bit_IT()
2567 hi2s->State = HAL_I2S_STATE_READY; in I2S_Receive_32Bit_IT()
2570 if (IS_I2S_FULLDUPLEX(hi2s->Init.Mode)) in I2S_Receive_32Bit_IT()
2572 hi2s->TxRxCpltCallback(hi2s); in I2S_Receive_32Bit_IT()
2576 hi2s->RxCpltCallback(hi2s); in I2S_Receive_32Bit_IT()
2579 if (IS_I2S_FULLDUPLEX(hi2s->Init.Mode)) in I2S_Receive_32Bit_IT()
2581 HAL_I2SEx_TxRxCpltCallback(hi2s); in I2S_Receive_32Bit_IT()
2585 HAL_I2S_RxCpltCallback(hi2s); in I2S_Receive_32Bit_IT()
2601 static HAL_StatusTypeDef I2S_WaitFlagStateUntilTimeout(I2S_HandleTypeDef *hi2s, uint32_t Flag, Flag… in I2S_WaitFlagStateUntilTimeout() argument
2605 while (((__HAL_I2S_GET_FLAG(hi2s, Flag)) ? SET : RESET) != State) in I2S_WaitFlagStateUntilTimeout()
2612 hi2s->State = HAL_I2S_STATE_READY; in I2S_WaitFlagStateUntilTimeout()
2615 __HAL_UNLOCK(hi2s); in I2S_WaitFlagStateUntilTimeout()