STM32L486xx HAL User Manual
Functions
Initialization and de-initialization functions
SAI Exported Functions

Initialization and Configuration functions. More...

Functions

HAL_StatusTypeDef HAL_SAI_InitProtocol (SAI_HandleTypeDef *hsai, uint32_t protocol, uint32_t datasize, uint32_t nbslot)
 Initialize the structure FrameInit, SlotInit and the low part of Init according to the specified parameters and call the function HAL_SAI_Init to initialize the SAI block.
HAL_StatusTypeDef HAL_SAI_Init (SAI_HandleTypeDef *hsai)
 Initialize the SAI according to the specified parameters.
HAL_StatusTypeDef HAL_SAI_DeInit (SAI_HandleTypeDef *hsai)
 DeInitialize the SAI peripheral.
__weak void HAL_SAI_MspInit (SAI_HandleTypeDef *hsai)
 Initialize the SAI MSP.
__weak void HAL_SAI_MspDeInit (SAI_HandleTypeDef *hsai)
 DeInitialize the SAI MSP.
HAL_StatusTypeDef HAL_SAI_RegisterCallback (SAI_HandleTypeDef *hsai, HAL_SAI_CallbackIDTypeDef CallbackID, pSAI_CallbackTypeDef pCallback)
 Register a user SAI callback to be used instead of the weak predefined callback.
HAL_StatusTypeDef HAL_SAI_UnRegisterCallback (SAI_HandleTypeDef *hsai, HAL_SAI_CallbackIDTypeDef CallbackID)
 Unregister a user SAI callback.

Detailed Description

Initialization and Configuration functions.

 ===============================================================================
             ##### Initialization and de-initialization functions #####
 ===============================================================================
  [..]  This subsection provides a set of functions allowing to initialize and
        de-initialize the SAIx peripheral:

      (+) User must implement HAL_SAI_MspInit() function in which he configures
          all related peripherals resources (CLOCK, GPIO, DMA, IT and NVIC ).

      (+) Call the function HAL_SAI_Init() to configure the selected device with
          the selected configuration:
        (++) Mode (Master/slave TX/RX)
        (++) Protocol
        (++) Data Size
        (++) MCLK Output
        (++) Audio frequency
        (++) FIFO Threshold
        (++) Frame Config
        (++) Slot Config
        (++) PDM Config (only for STM32L4Rx/STM32L4Sx devices)

      (+) Call the function HAL_SAI_DeInit() to restore the default configuration
          of the selected SAI peripheral.


Function Documentation

HAL_StatusTypeDef HAL_SAI_DeInit ( SAI_HandleTypeDef hsai)

DeInitialize the SAI peripheral.

Parameters:
hsaipointer to a SAI_HandleTypeDef structure that contains the configuration information for SAI module.
Return values:
HALstatus

Definition at line 700 of file stm32l4xx_hal_sai.c.

References __SAI_HandleTypeDef::ErrorCode, HAL_SAI_ERROR_NONE, HAL_SAI_MspDeInit(), HAL_SAI_STATE_BUSY, HAL_SAI_STATE_READY, HAL_SAI_STATE_RESET, __SAI_HandleTypeDef::Instance, __SAI_HandleTypeDef::MspDeInitCallback, SAI_Disable(), and __SAI_HandleTypeDef::State.

HAL_StatusTypeDef HAL_SAI_Init ( SAI_HandleTypeDef hsai)

Initialize the SAI according to the specified parameters.

in the SAI_InitTypeDef structure and initialize the associated handle.

Parameters:
hsaipointer to a SAI_HandleTypeDef structure that contains the configuration information for SAI module.
Return values:
HALstatus

Definition at line 378 of file stm32l4xx_hal_sai.c.

References SAI_FrameInitTypeDef::ActiveFrameLength, assert_param, SAI_InitTypeDef::AudioFrequency, SAI_InitTypeDef::AudioMode, SAI_InitTypeDef::ClockStrobing, SAI_InitTypeDef::CompandingMode, SAI_InitTypeDef::DataSize, __SAI_HandleTypeDef::ErrorCallback, __SAI_HandleTypeDef::ErrorCode, SAI_InitTypeDef::FIFOThreshold, SAI_InitTypeDef::FirstBit, SAI_SlotInitTypeDef::FirstBitOffset, __SAI_HandleTypeDef::FrameInit, SAI_FrameInitTypeDef::FrameLength, SAI_FrameInitTypeDef::FSDefinition, SAI_FrameInitTypeDef::FSOffset, SAI_FrameInitTypeDef::FSPolarity, HAL_RCCEx_GetPeriphCLKFreq(), HAL_SAI_ERROR_NONE, HAL_SAI_ErrorCallback(), HAL_SAI_MspInit(), HAL_SAI_RxCpltCallback(), HAL_SAI_RxHalfCpltCallback(), HAL_SAI_STATE_BUSY, HAL_SAI_STATE_READY, HAL_SAI_STATE_RESET, HAL_SAI_TxCpltCallback(), HAL_SAI_TxHalfCpltCallback(), __SAI_HandleTypeDef::Init, __SAI_HandleTypeDef::Instance, IS_SAI_AUDIO_FREQUENCY, IS_SAI_BLOCK_ACTIVE_FRAME, IS_SAI_BLOCK_CLOCK_STROBING, IS_SAI_BLOCK_COMPANDING_MODE, IS_SAI_BLOCK_DATASIZE, IS_SAI_BLOCK_FIFO_THRESHOLD, IS_SAI_BLOCK_FIRST_BIT, IS_SAI_BLOCK_FIRSTBIT_OFFSET, IS_SAI_BLOCK_FRAME_LENGTH, IS_SAI_BLOCK_FS_DEFINITION, IS_SAI_BLOCK_FS_OFFSET, IS_SAI_BLOCK_FS_POLARITY, IS_SAI_BLOCK_MODE, IS_SAI_BLOCK_NODIVIDER, IS_SAI_BLOCK_OUTPUT_DRIVE, IS_SAI_BLOCK_PROTOCOL, IS_SAI_BLOCK_SLOT_NUMBER, IS_SAI_BLOCK_SLOT_SIZE, IS_SAI_BLOCK_SYNCEXT, IS_SAI_BLOCK_SYNCHRO, IS_SAI_BLOCK_TRISTATE_MANAGEMENT, IS_SAI_MONO_STEREO_MODE, IS_SAI_SLOT_ACTIVE, __SAI_HandleTypeDef::Lock, SAI_InitTypeDef::Mckdiv, SAI_InitTypeDef::MonoStereoMode, __SAI_HandleTypeDef::MspInitCallback, SAI_InitTypeDef::NoDivider, SAI_InitTypeDef::OutputDrive, SAI_InitTypeDef::Protocol, RCC_PERIPHCLK_SAI1, RCC_PERIPHCLK_SAI2, __SAI_HandleTypeDef::RxCpltCallback, __SAI_HandleTypeDef::RxHalfCpltCallback, SAI_ASYNCHRONOUS, SAI_AUDIO_FREQUENCY_MCKDIV, SAI_CLOCKSTROBING_RISINGEDGE, SAI_Disable(), SAI_FREE_PROTOCOL, SAI_MASTERDIVIDER_DISABLE, SAI_MODEMASTER_RX, SAI_MODEMASTER_TX, SAI_MODESLAVE_TX, SAI_SYNCEXT_DISABLE, SAI_SYNCEXT_OUTBLOCKA_ENABLE, SAI_SYNCEXT_OUTBLOCKB_ENABLE, SAI_SYNCHRONOUS, SAI_SYNCHRONOUS_EXT_SAI1, SAI_SYNCHRONOUS_EXT_SAI2, SAI_SlotInitTypeDef::SlotActive, __SAI_HandleTypeDef::SlotInit, SAI_SlotInitTypeDef::SlotNumber, SAI_SlotInitTypeDef::SlotSize, __SAI_HandleTypeDef::State, SAI_InitTypeDef::Synchro, SAI_InitTypeDef::SynchroExt, SAI_InitTypeDef::TriState, __SAI_HandleTypeDef::TxCpltCallback, and __SAI_HandleTypeDef::TxHalfCpltCallback.

Referenced by HAL_SAI_InitProtocol().

HAL_StatusTypeDef HAL_SAI_InitProtocol ( SAI_HandleTypeDef hsai,
uint32_t  protocol,
uint32_t  datasize,
uint32_t  nbslot 
)

Initialize the structure FrameInit, SlotInit and the low part of Init according to the specified parameters and call the function HAL_SAI_Init to initialize the SAI block.

Parameters:
hsaipointer to a SAI_HandleTypeDef structure that contains the configuration information for SAI module.
protocolone of the supported protocol SAI Supported protocol
datasizeone of the supported datasize SAI protocol data size the configuration information for SAI module.
nbslotNumber of slot.
Return values:
HALstatus

Definition at line 339 of file stm32l4xx_hal_sai.c.

References assert_param, HAL_SAI_Init(), IS_SAI_PROTOCOL_DATASIZE, IS_SAI_SUPPORTED_PROTOCOL, SAI_I2S_LSBJUSTIFIED, SAI_I2S_MSBJUSTIFIED, SAI_I2S_STANDARD, SAI_InitI2S(), SAI_InitPCM(), SAI_PCM_LONG, and SAI_PCM_SHORT.

DeInitialize the SAI MSP.

Parameters:
hsaipointer to a SAI_HandleTypeDef structure that contains the configuration information for SAI module.
Return values:
None

Definition at line 786 of file stm32l4xx_hal_sai.c.

Referenced by HAL_SAI_DeInit(), and HAL_SAI_UnRegisterCallback().

Initialize the SAI MSP.

Parameters:
hsaipointer to a SAI_HandleTypeDef structure that contains the configuration information for SAI module.
Return values:
None

Definition at line 770 of file stm32l4xx_hal_sai.c.

Referenced by HAL_SAI_Init(), and HAL_SAI_UnRegisterCallback().

HAL_StatusTypeDef HAL_SAI_RegisterCallback ( SAI_HandleTypeDef hsai,
HAL_SAI_CallbackIDTypeDef  CallbackID,
pSAI_CallbackTypeDef  pCallback 
)

Register a user SAI callback to be used instead of the weak predefined callback.

Parameters:
hsaiSAI handle.
CallbackIDID of the callback to be registered. This parameter can be one of the following values:
pCallbackpointer to the callback function.
Return values:
HALstatus.

Definition at line 813 of file stm32l4xx_hal_sai.c.

References __SAI_HandleTypeDef::ErrorCallback, __SAI_HandleTypeDef::ErrorCode, HAL_SAI_ERROR_CB_ID, HAL_SAI_ERROR_INVALID_CALLBACK, HAL_SAI_MSPDEINIT_CB_ID, HAL_SAI_MSPINIT_CB_ID, HAL_SAI_RX_COMPLETE_CB_ID, HAL_SAI_RX_HALFCOMPLETE_CB_ID, HAL_SAI_STATE_READY, HAL_SAI_STATE_RESET, HAL_SAI_TX_COMPLETE_CB_ID, HAL_SAI_TX_HALFCOMPLETE_CB_ID, __SAI_HandleTypeDef::MspDeInitCallback, __SAI_HandleTypeDef::MspInitCallback, __SAI_HandleTypeDef::RxCpltCallback, __SAI_HandleTypeDef::RxHalfCpltCallback, __SAI_HandleTypeDef::State, __SAI_HandleTypeDef::TxCpltCallback, and __SAI_HandleTypeDef::TxHalfCpltCallback.

HAL_StatusTypeDef HAL_SAI_UnRegisterCallback ( SAI_HandleTypeDef hsai,
HAL_SAI_CallbackIDTypeDef  CallbackID 
)