Go to the documentation of this file.
219 #ifdef HAL_SAI_MODULE_ENABLED
238 #define SAI_DEFAULT_TIMEOUT 4
335 status = SAI_InitI2S(hsai, protocol, datasize, nbslot);
339 status = SAI_InitPCM(hsai, protocol, datasize, nbslot);
363 uint32_t tmpregisterGCR = 0;
364 uint32_t ckstr_bits = 0;
365 uint32_t syncen_bits = 0;
410 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
419 if (hsai->MspInitCallback ==
NULL)
423 hsai->MspInitCallback(hsai);
481 SAI1->GCR = tmpregisterGCR;
485 SAI2->GCR = tmpregisterGCR;
511 if((tmpval % 10) > 8)
538 ckstr_bits | syncen_bits | \
540 hsai->Init.NoDivider | (hsai->
Init.
Mckdiv << 20));
602 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
603 if (hsai->MspDeInitCallback ==
NULL)
607 hsai->MspDeInitCallback(hsai);
656 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
674 HAL_SAI_CallbackIDTypeDef CallbackID,
675 pSAI_CallbackTypeDef pCallback)
679 if (pCallback ==
NULL)
682 hsai->
ErrorCode |= HAL_SAI_ERROR_INVALID_CALLBACK;
692 case HAL_SAI_RX_COMPLETE_CB_ID :
693 hsai->RxCpltCallback = pCallback;
695 case HAL_SAI_RX_HALFCOMPLETE_CB_ID :
696 hsai->RxHalfCpltCallback = pCallback;
698 case HAL_SAI_TX_COMPLETE_CB_ID :
699 hsai->TxCpltCallback = pCallback;
701 case HAL_SAI_TX_HALFCOMPLETE_CB_ID :
702 hsai->TxHalfCpltCallback = pCallback;
704 case HAL_SAI_ERROR_CB_ID :
705 hsai->ErrorCallback = pCallback;
707 case HAL_SAI_MSPINIT_CB_ID :
708 hsai->MspInitCallback = pCallback;
710 case HAL_SAI_MSPDEINIT_CB_ID :
711 hsai->MspDeInitCallback = pCallback;
715 hsai->
ErrorCode |= HAL_SAI_ERROR_INVALID_CALLBACK;
725 case HAL_SAI_MSPINIT_CB_ID :
726 hsai->MspInitCallback = pCallback;
728 case HAL_SAI_MSPDEINIT_CB_ID :
729 hsai->MspDeInitCallback = pCallback;
733 hsai->
ErrorCode |= HAL_SAI_ERROR_INVALID_CALLBACK;
742 hsai->
ErrorCode |= HAL_SAI_ERROR_INVALID_CALLBACK;
766 HAL_SAI_CallbackIDTypeDef CallbackID)
774 case HAL_SAI_RX_COMPLETE_CB_ID :
777 case HAL_SAI_RX_HALFCOMPLETE_CB_ID :
780 case HAL_SAI_TX_COMPLETE_CB_ID :
783 case HAL_SAI_TX_HALFCOMPLETE_CB_ID :
786 case HAL_SAI_ERROR_CB_ID :
789 case HAL_SAI_MSPINIT_CB_ID :
792 case HAL_SAI_MSPDEINIT_CB_ID :
797 hsai->
ErrorCode |= HAL_SAI_ERROR_INVALID_CALLBACK;
807 case HAL_SAI_MSPINIT_CB_ID :
810 case HAL_SAI_MSPDEINIT_CB_ID :
815 hsai->
ErrorCode |= HAL_SAI_ERROR_INVALID_CALLBACK;
824 hsai->
ErrorCode |= HAL_SAI_ERROR_INVALID_CALLBACK;
891 if((pData ==
NULL ) || (Size == 0))
991 if((pData ==
NULL ) || (Size == 0))
1086 if((pData ==
NULL) || (Size == 0))
1148 if((pData ==
NULL) || (Size == 0))
1380 if((pData ==
NULL) || (Size == 0))
1450 if((pData ==
NULL) || (Size == 0))
1619 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
1620 hsai->ErrorCallback(hsai);
1668 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
1669 hsai->ErrorCallback(hsai);
1706 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
1707 hsai->ErrorCallback(hsai);
1747 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
1748 hsai->ErrorCallback(hsai);
1762 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
1763 hsai->ErrorCallback(hsai);
1940 if((nbslot & 0x1) != 0 )
2115 if(mode == SAI_MODE_IT)
2181 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
2182 hsai->TxCpltCallback(hsai);
2209 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
2210 hsai->TxCpltCallback(hsai);
2238 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
2239 hsai->TxCpltCallback(hsai);
2275 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
2276 hsai->RxCpltCallback(hsai);
2306 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
2307 hsai->RxCpltCallback(hsai);
2337 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
2338 hsai->RxCpltCallback(hsai);
2367 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
2368 hsai->TxCpltCallback(hsai);
2384 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
2385 hsai->TxHalfCpltCallback(hsai);
2412 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
2413 hsai->RxCpltCallback(hsai);
2429 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
2430 hsai->RxHalfCpltCallback(hsai);
2464 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
2465 hsai->ErrorCallback(hsai);
2503 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
2504 hsai->ErrorCallback(hsai);
HAL_StatusTypeDef HAL_SAI_DisableRxMuteMode(SAI_HandleTypeDef *hsai)
#define IS_SAI_BLOCK_PROTOCOL(PROTOCOL)
#define SAI_FS_STARTFRAME
#define SAI_PROTOCOL_DATASIZE_24BIT
#define assert_param(expr)
Include module's header file.
HAL_StatusTypeDef HAL_SAI_DisableTxMuteMode(SAI_HandleTypeDef *hsai)
HAL_StatusTypeDef
HAL Status structures definition
#define IS_SAI_BLOCK_MUTE_COUNTER(COUNTER)
#define SAI_FREE_PROTOCOL
void HAL_SAI_MspInit(SAI_HandleTypeDef *hsai)
HAL_StatusTypeDef HAL_SAI_DMAStop(SAI_HandleTypeDef *hsai)
#define SAI_CLOCKSTROBING_FALLINGEDGE
uint32_t HAL_RCCEx_GetPeriphCLKFreq(uint32_t PeriphClk)
void(* XferHalfCpltCallback)(struct __DMA_HandleTypeDef *hdma)
uint32_t ActiveFrameLength
DMA handle Structure definition.
DMA_HandleTypeDef * hdmatx
HAL_StatusTypeDef HAL_SAI_DMAPause(SAI_HandleTypeDef *hsai)
#define SAI_GCR_SYNCOUT_1
#define IS_SAI_BLOCK_COMPANDING_MODE(MODE)
#define SAI_xCR1_SYNCEN_0
#define IS_SAI_BLOCK_FRAME_LENGTH(LENGTH)
#define SAI_FIFOSTATUS_FULL
HAL_StatusTypeDef HAL_DMA_Abort_IT(DMA_HandleTypeDef *hdma)
HAL_StatusTypeDef HAL_SAI_DeInit(SAI_HandleTypeDef *hsai)
#define IS_SAI_BLOCK_SLOT_SIZE(SIZE)
#define HAL_SAI_ERROR_WCKCFG
#define HAL_SAI_ERROR_TIMEOUT
#define IS_SAI_SLOT_ACTIVE(ACTIVE)
#define SAI_xCR2_MUTECNT_Pos
#define IS_SAI_AUDIO_FREQUENCY(AUDIO)
#define SAI_SYNCEXT_DISABLE
void(* XferAbortCallback)(struct __DMA_HandleTypeDef *hdma)
#define HAL_DMA_ERROR_NO_XFER
HAL_SAI_StateTypeDef HAL_SAI_GetState(SAI_HandleTypeDef *hsai)
#define SAI_FS_CHANNEL_IDENTIFICATION
__IO HAL_SAI_StateTypeDef State
#define CLEAR_BIT(REG, BIT)
uint32_t HAL_GetTick(void)
Provides a tick value in millisecond.
HAL_StatusTypeDef HAL_SAI_Receive(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size, uint32_t Timeout)
#define HAL_SAI_ERROR_AFSDET
void HAL_SAI_IRQHandler(SAI_HandleTypeDef *hsai)
#define IS_SAI_BLOCK_FIRST_BIT(BIT)
DMA_HandleTypeDef * hdmarx
SAI_Block_TypeDef * Instance
#define IS_SAI_ALL_INSTANCE(PERIPH)
#define SAI_MODEMASTER_RX
#define HAL_SAI_ERROR_DMA
#define IS_SAI_BLOCK_NODIVIDER(NODIVIDER)
#define IS_SAI_BLOCK_MUTE_VALUE(VALUE)
#define HAL_SAI_ERROR_UDR
#define __HAL_SAI_CLEAR_FLAG(__HANDLE__, __FLAG__)
Clear the specified SAI pending flag.
#define IS_SAI_BLOCK_SYNCEXT(STATE)
HAL_StatusTypeDef HAL_SAI_InitProtocol(SAI_HandleTypeDef *hsai, uint32_t protocol, uint32_t datasize, uint32_t nbslot)
#define IS_SAI_BLOCK_FIFO_THRESHOLD(THRESHOLD)
#define SAI_AC97_PROTOCOL
#define IS_SAI_PROTOCOL_DATASIZE(DATASIZE)
void HAL_SAI_RxHalfCpltCallback(SAI_HandleTypeDef *hsai)
Half reception complete callback.
#define HAL_SAI_ERROR_LFSDET
#define IS_SAI_BLOCK_CLOCK_STROBING(CLOCK)
#define __HAL_LOCK(__HANDLE__)
#define HAL_SAI_ERROR_OVR
uint32_t HAL_SAI_GetError(SAI_HandleTypeDef *hsai)
#define SAI_AUDIO_FREQUENCY_MCKDIV
HAL_StatusTypeDef HAL_SAI_DMAResume(SAI_HandleTypeDef *hsai)
void HAL_SAI_RxCpltCallback(SAI_HandleTypeDef *hsai)
Reception complete callback.
#define IS_SAI_BLOCK_FIRSTBIT_OFFSET(OFFSET)
#define SAI_I2S_MSBJUSTIFIED
HAL_StatusTypeDef HAL_SAI_Transmit_IT(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size)
#define SAI_SLOTACTIVE_ALL
void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai)
SAI error callbacks.
HAL_StatusTypeDef HAL_DMA_Start_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength)
#define IS_SAI_BLOCK_FS_DEFINITION(DEFINITION)
void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai)
Tx Half Transfer completed callbacks.
HAL_StatusTypeDef HAL_SAI_EnableTxMuteMode(SAI_HandleTypeDef *hsai, uint16_t val)
#define RCC_PERIPHCLK_SAI2
#define __HAL_UNLOCK(__HANDLE__)
#define IS_SAI_BLOCK_MASTER_DIVIDER(DIVIDER)
#define __HAL_SAI_ENABLE_IT(__HANDLE__, __INTERRUPT__)
Enable or disable the specified SAI interrupts.
#define __HAL_SAI_DISABLE(__HANDLE__)
#define SAI_MODEMASTER_TX
HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma)
void(* InterruptServiceRoutine)(struct __SAI_HandleTypeDef *hsai)
#define IS_SAI_BLOCK_FS_OFFSET(OFFSET)
#define SAI_I2S_LSBJUSTIFIED
#define IS_SAI_BLOCK_MODE(MODE)
HAL_StatusTypeDef HAL_SAI_Transmit(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size, uint32_t Timeout)
#define IS_SAI_SUPPORTED_PROTOCOL(PROTOCOL)
#define SAI_SYNCHRONOUS_EXT_SAI2
#define SAI_SYNCEXT_OUTBLOCKA_ENABLE
void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai)
Tx Transfer completed callbacks.
#define __HAL_SAI_ENABLE(__HANDLE__)
HAL_StatusTypeDef HAL_SAI_Receive_DMA(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size)
#define RCC_PERIPHCLK_SAI1
#define SAI_FIFOSTATUS_EMPTY
void(* XferCpltCallback)(struct __DMA_HandleTypeDef *hdma)
#define IS_SAI_BLOCK_DATASIZE(DATASIZE)
HAL_SAI_StateTypeDef
HAL State structures definition.
#define IS_SAI_BLOCK_ACTIVE_FRAME(LENGTH)
#define SAI_FS_ACTIVE_LOW
#define HAL_SAI_ERROR_CNREADY
HAL_StatusTypeDef HAL_SAI_Init(SAI_HandleTypeDef *hsai)
#define SAI_PROTOCOL_DATASIZE_32BIT
#define IS_SAI_MONO_STEREO_MODE(MODE)
#define SAI_xCR1_SYNCEN_1
#define SAI_PROTOCOL_DATASIZE_16BITEXTENDED
HAL_StatusTypeDef HAL_SAI_Receive_IT(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size)
#define IS_SAI_BLOCK_SYNCHRO(SYNCHRO)
#define SET_BIT(REG, BIT)
#define IS_SAI_BLOCK_TRISTATE_MANAGEMENT(STATE)
#define IS_SAI_BLOCK_FS_POLARITY(POLARITY)
#define SAI_SYNCHRONOUS_EXT_SAI1
#define IS_SAI_BLOCK_OUTPUT_DRIVE(DRIVE)
#define SAI_CLOCKSTROBING_RISINGEDGE
#define __HAL_SAI_DISABLE_IT(__HANDLE__, __INTERRUPT__)
void(* SAIcallback)(void)
SAI Callback prototype.
void HAL_SAI_MspDeInit(SAI_HandleTypeDef *hsai)
HAL_StatusTypeDef HAL_SAI_Abort(SAI_HandleTypeDef *hsai)
#define SAI_xSLOTR_SLOTSZ
#define SAI_FS_ACTIVE_HIGH
SAI_SlotInitTypeDef SlotInit
#define IS_SAI_BLOCK_SLOT_NUMBER(NUMBER)
SAI_FrameInitTypeDef FrameInit
#define SAI_GCR_SYNCOUT_0
#define SAI_FS_BEFOREFIRSTBIT
#define HAL_SAI_ERROR_NONE
#define SAI_xSLOTR_SLOTEN
This file contains all the functions prototypes for the HAL module driver.
#define SAI_SYNCEXT_OUTBLOCKB_ENABLE
HAL_StatusTypeDef HAL_SAI_Transmit_DMA(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size)
void(* XferErrorCallback)(struct __DMA_HandleTypeDef *hdma)
HAL_StatusTypeDef HAL_SAI_EnableRxMuteMode(SAI_HandleTypeDef *hsai, SAIcallback callback, uint16_t counter)
#define SAI_PROTOCOL_DATASIZE_16BIT