discoverpixy
Modules | Classes | Macros | Functions

SAI driver modules. More...

Collaboration diagram for SAI:

Modules

 SAI_Exported_Constants
 
 SAI_Private_Functions
 

Classes

struct  SAI_InitTypeDef
 SAI Block Init structure definition. More...
 
struct  SAI_FrameInitTypeDef
 SAI Block Frame Init structure definition. More...
 
struct  SAI_SlotInitTypeDef
 SAI Block Slot Init Structure definition. More...
 

Macros

#define CR1_CLEAR_MASK   ((uint32_t)0xFF07C010)
 
#define FRCR_CLEAR_MASK   ((uint32_t)0xFFF88000)
 
#define SLOTR_CLEAR_MASK   ((uint32_t)0x0000F020)
 

Functions

void SAI_DeInit (SAI_TypeDef *SAIx)
 Deinitialize the SAIx peripheral registers to their default reset values. More...
 
void SAI_Init (SAI_Block_TypeDef *SAI_Block_x, SAI_InitTypeDef *SAI_InitStruct)
 Initializes the SAI Block x peripheral according to the specified parameters in the SAI_InitStruct. More...
 
void SAI_FrameInit (SAI_Block_TypeDef *SAI_Block_x, SAI_FrameInitTypeDef *SAI_FrameInitStruct)
 Initializes the SAI Block Audio frame according to the specified parameters in the SAI_FrameInitStruct. More...
 
void SAI_SlotInit (SAI_Block_TypeDef *SAI_Block_x, SAI_SlotInitTypeDef *SAI_SlotInitStruct)
 Initializes the SAI Block audio Slot according to the specified parameters in the SAI_SlotInitStruct. More...
 
void SAI_StructInit (SAI_InitTypeDef *SAI_InitStruct)
 Fills each SAI_InitStruct member with its default value. More...
 
void SAI_FrameStructInit (SAI_FrameInitTypeDef *SAI_FrameInitStruct)
 Fills each SAI_FrameInitStruct member with its default value. More...
 
void SAI_SlotStructInit (SAI_SlotInitTypeDef *SAI_SlotInitStruct)
 Fills each SAI_SlotInitStruct member with its default value. More...
 
void SAI_Cmd (SAI_Block_TypeDef *SAI_Block_x, FunctionalState NewState)
 Enables or disables the specified SAI Block peripheral. More...
 
void SAI_MonoModeConfig (SAI_Block_TypeDef *SAI_Block_x, uint32_t SAI_Mono_StreoMode)
 Configures the mono mode for the selected SAI block. More...
 
void SAI_TRIStateConfig (SAI_Block_TypeDef *SAI_Block_x, uint32_t SAI_TRIState)
 Configures the TRIState managment on data line for the selected SAI block. More...
 
void SAI_CompandingModeConfig (SAI_Block_TypeDef *SAI_Block_x, uint32_t SAI_CompandingMode)
 Configures the companding mode for the selected SAI block. More...
 
void SAI_MuteModeCmd (SAI_Block_TypeDef *SAI_Block_x, FunctionalState NewState)
 Enables or disables the Mute mode for the selected SAI block. More...
 
void SAI_MuteValueConfig (SAI_Block_TypeDef *SAI_Block_x, uint32_t SAI_MuteValue)
 Configure the mute value for the selected SAI block. More...
 
void SAI_MuteFrameCounterConfig (SAI_Block_TypeDef *SAI_Block_x, uint32_t SAI_MuteCounter)
 Enables or disables the Mute mode for the selected SAI block. More...
 
void SAI_FlushFIFO (SAI_Block_TypeDef *SAI_Block_x)
 Reinitialize the FIFO pointer. More...
 
void SAI_SendData (SAI_Block_TypeDef *SAI_Block_x, uint32_t Data)
 Transmits a Data through the SAI block x peripheral. More...
 
uint32_t SAI_ReceiveData (SAI_Block_TypeDef *SAI_Block_x)
 Returns the most recent received data by the SAI block x peripheral. More...
 
void SAI_DMACmd (SAI_Block_TypeDef *SAI_Block_x, FunctionalState NewState)
 Enables or disables the SAI Block x DMA interface. More...
 
void SAI_ITConfig (SAI_Block_TypeDef *SAI_Block_x, uint32_t SAI_IT, FunctionalState NewState)
 Enables or disables the specified SAI Block interrupts. More...
 
FlagStatus SAI_GetFlagStatus (SAI_Block_TypeDef *SAI_Block_x, uint32_t SAI_FLAG)
 Checks whether the specified SAI block x flag is set or not. More...
 
void SAI_ClearFlag (SAI_Block_TypeDef *SAI_Block_x, uint32_t SAI_FLAG)
 Clears the specified SAI Block x flag. More...
 
ITStatus SAI_GetITStatus (SAI_Block_TypeDef *SAI_Block_x, uint32_t SAI_IT)
 Checks whether the specified SAI Block x interrupt has occurred or not. More...
 
void SAI_ClearITPendingBit (SAI_Block_TypeDef *SAI_Block_x, uint32_t SAI_IT)
 Clears the SAI Block x interrupt pending bit. More...
 
FunctionalState SAI_GetCmdStatus (SAI_Block_TypeDef *SAI_Block_x)
 Returns the status of EN bit for the specified SAI Block x. More...
 
uint32_t SAI_GetFIFOStatus (SAI_Block_TypeDef *SAI_Block_x)
 Returns the current SAI Block x FIFO filled level. More...
 

Detailed Description

SAI driver modules.

Function Documentation

void SAI_ClearFlag ( SAI_Block_TypeDef SAI_Block_x,
uint32_t  SAI_FLAG 
)

Clears the specified SAI Block x flag.

Parameters
SAI_Block_xwhere x can be A or B to select the SAI Block peripheral.
SAI_FLAGspecifies the SAI block flag to check. This parameter can be one of the following values:
  • SAI_FLAG_MUTEDET: MUTE detection flag.
  • SAI_FLAG_OVRUDR: overrun/underrun flag.
  • SAI_FLAG_WCKCFG: wrong clock configuration flag.
  • SAI_FLAG_CNRDY: codec not ready flag.
  • SAI_FLAG_AFSDET: anticipated frame synchronization detection flag.
  • SAI_FLAG_LFSDET: late frame synchronization detection flag.
Note
FREQ (FIFO Request) flag is cleared :
  • When the audio block is transmitter and the FIFO is full or the FIFO has one data (one buffer mode) depending the bit FTH in the SAI_xCR2 register.
  • When the audio block is receiver and the FIFO is not empty
Return values
None
void SAI_ClearITPendingBit ( SAI_Block_TypeDef SAI_Block_x,
uint32_t  SAI_IT 
)

Clears the SAI Block x interrupt pending bit.

Parameters
SAI_Block_xwhere x can be A or B to select the SAI Block peripheral.
SAI_ITspecifies the SAI Block interrupt pending bit to clear. This parameter can be one of the following values:
  • SAI_IT_MUTEDET: MUTE detection interrupt.
  • SAI_IT_OVRUDR: overrun/underrun interrupt.
  • SAI_IT_WCKCFG: wrong clock configuration interrupt.
  • SAI_IT_CNRDY: codec not ready interrupt.
  • SAI_IT_AFSDET: anticipated frame synchronization detection interrupt.
  • SAI_IT_LFSDET: late frame synchronization detection interrupt.
Note
FREQ (FIFO Request) flag is cleared :
  • When the audio block is transmitter and the FIFO is full or the FIFO has one data (one buffer mode) depending the bit FTH in the SAI_xCR2 register.
  • When the audio block is receiver and the FIFO is not empty
Return values
None
void SAI_Cmd ( SAI_Block_TypeDef SAI_Block_x,
FunctionalState  NewState 
)

Enables or disables the specified SAI Block peripheral.

Parameters
SAI_Block_xwhere x can be A or B to select the SAI Block peripheral.
NewStatenew state of the SAI_Block_x peripheral. This parameter can be: ENABLE or DISABLE.
Return values
None
void SAI_CompandingModeConfig ( SAI_Block_TypeDef SAI_Block_x,
uint32_t  SAI_CompandingMode 
)

Configures the companding mode for the selected SAI block.

Note
The data expansion or data compression are determined by the state of SAI block selected (transmitter or receiver).
Parameters
SAI_Block_xwhere x can be A or B to select the SAI Block peripheral.
SAI_CompandingModespecifies the SAI block companding mode. This parameter can be one of the following values:
  • SAI_NoCompanding : no companding algorithm set
  • SAI_ULaw_1CPL_Companding : Set U law (algorithm 1's complement representation)
  • SAI_ALaw_1CPL_Companding : Set A law (algorithm 1's complement repesentation)
  • SAI_ULaw_2CPL_Companding : Set U law (algorithm 2's complement representation)
  • SAI_ALaw_2CPL_Companding : Set A law (algorithm 2's complement repesentation)
Return values
None
void SAI_DeInit ( SAI_TypeDef SAIx)

Deinitialize the SAIx peripheral registers to their default reset values.

Parameters
SAIxTo select the SAIx peripheral, where x can be the different instances
Return values
None

Here is the call graph for this function:

void SAI_DMACmd ( SAI_Block_TypeDef SAI_Block_x,
FunctionalState  NewState 
)

Enables or disables the SAI Block x DMA interface.

Parameters
SAI_Block_xwhere x can be A or B to select the SAI Block peripheral.
NewStatenew state of the selected SAI block DMA transfer request. This parameter can be: ENABLE or DISABLE.
Return values
None
void SAI_FlushFIFO ( SAI_Block_TypeDef SAI_Block_x)

Reinitialize the FIFO pointer.

Note
The FIFO pointers can be reinitialized at anytime The data present into the FIFO, if it is not empty, will be lost.
Parameters
SAI_Block_xwhere x can be A or B to select the SAI Block peripheral.
NewStatenew state of the selected SAI TI communication mode. This parameter can be: ENABLE or DISABLE.
Return values
None
void SAI_FrameInit ( SAI_Block_TypeDef SAI_Block_x,
SAI_FrameInitTypeDef SAI_FrameInitStruct 
)

Initializes the SAI Block Audio frame according to the specified parameters in the SAI_FrameInitStruct.

Note
this function has no meaning if the AC'97 or SPDIF audio protocol are selected.
Parameters
SAI_Block_xwhere x can be A or B to select the SAI Block peripheral.
SAI_FrameInitStructpointer to an SAI_FrameInitTypeDef structure that contains the configuration of audio frame for a specified SAI Block
Return values
None
void SAI_FrameStructInit ( SAI_FrameInitTypeDef SAI_FrameInitStruct)

Fills each SAI_FrameInitStruct member with its default value.

Parameters
SAI_FrameInitStructpointer to a SAI_FrameInitTypeDef structure which will be initialized.
Return values
None
FunctionalState SAI_GetCmdStatus ( SAI_Block_TypeDef SAI_Block_x)

Returns the status of EN bit for the specified SAI Block x.

Parameters
SAI_Block_xwhere x can be A or B to select the SAI Block peripheral.
Note
After disabling a SAI Block, it is recommended to check (or wait until) the SAI Block is effectively disabled. If a Block is disabled while an audio frame transfer is ongoing, the current frame will be transferred and the block will be effectively disabled only at the end of audio frame.
Return values
Currentstate of the DMAy Streamx (ENABLE or DISABLE).
uint32_t SAI_GetFIFOStatus ( SAI_Block_TypeDef SAI_Block_x)

Returns the current SAI Block x FIFO filled level.

Parameters
SAI_Block_xwhere x can be A or B to select the SAI Block peripheral.
Return values
TheFIFO filling state.
  • SAI_FIFOStatus_Empty: when FIFO is empty
  • SAI_FIFOStatus_Less1QuarterFull: when FIFO is less than 1 quarter-full and not empty.
  • SAI_FIFOStatus_1QuarterFull: if more than 1 quarter-full.
  • SAI_FIFOStatus_HalfFull: if more than 1 half-full.
  • SAI_FIFOStatus_3QuartersFull: if more than 3 quarters-full.
  • SAI_FIFOStatus_Full: when FIFO is full
FlagStatus SAI_GetFlagStatus ( SAI_Block_TypeDef SAI_Block_x,
uint32_t  SAI_FLAG 
)

Checks whether the specified SAI block x flag is set or not.

Parameters
SAI_Block_xwhere x can be A or B to select the SAI Block peripheral.
SAI_FLAGspecifies the SAI block flag to check. This parameter can be one of the following values:
  • SAI_FLAG_FREQ: FIFO Request flag.
  • SAI_FLAG_MUTEDET: MUTE detection flag.
  • SAI_FLAG_OVRUDR: overrun/underrun flag.
  • SAI_FLAG_WCKCFG: wrong clock configuration flag.
  • SAI_FLAG_CNRDY: codec not ready flag.
  • SAI_FLAG_AFSDET: anticipated frame synchronization detection flag.
  • SAI_FLAG_LFSDET: late frame synchronization detection flag.
Return values
Thenew state of SAI_FLAG (SET or RESET).
ITStatus SAI_GetITStatus ( SAI_Block_TypeDef SAI_Block_x,
uint32_t  SAI_IT 
)

Checks whether the specified SAI Block x interrupt has occurred or not.

Parameters
SAI_Block_xwhere x can be A or B to select the SAI Block peripheral.
SAI_ITspecifies the SAI interrupt source to be enabled or disabled. This parameter can be one of the following values:
  • SAI_IT_FREQ: FIFO Request interrupt
  • SAI_IT_MUTEDET: MUTE detection interrupt
  • SAI_IT_OVRUDR: overrun/underrun interrupt
  • SAI_IT_AFSDET: anticipated frame synchronization detection interrupt
  • SAI_IT_LFSDET: late frame synchronization detection interrupt
  • SAI_IT_CNRDY: codec not ready interrupt
  • SAI_IT_WCKCFG: wrong clock configuration interrupt
Return values
Thenew state of SAI_IT (SET or RESET).
void SAI_Init ( SAI_Block_TypeDef SAI_Block_x,
SAI_InitTypeDef SAI_InitStruct 
)

Initializes the SAI Block x peripheral according to the specified parameters in the SAI_InitStruct.

Note
SAI clock is generated from a specific output of the PLLSAI or a specific output of the PLLI2S or from an alternate function bypassing the PLL I2S.
Parameters
SAI_Block_xwhere x can be A or B to select the SAI Block peripheral.
SAI_InitStructpointer to a SAI_InitTypeDef structure that contains the configuration information for the specified SAI Block peripheral.
Return values
None
void SAI_ITConfig ( SAI_Block_TypeDef SAI_Block_x,
uint32_t  SAI_IT,
FunctionalState  NewState 
)

Enables or disables the specified SAI Block interrupts.

Parameters
SAI_Block_xwhere x can be A or B to select the SAI Block peripheral.
SAI_ITspecifies the SAI interrupt source to be enabled or disabled. This parameter can be one of the following values:
  • SAI_IT_FREQ: FIFO Request interrupt mask
  • SAI_IT_MUTEDET: MUTE detection interrupt mask
  • SAI_IT_OVRUDR: overrun/underrun interrupt mask
  • SAI_IT_AFSDET: anticipated frame synchronization detection interrupt mask
  • SAI_IT_LFSDET: late frame synchronization detection interrupt mask
  • SAI_IT_CNRDY: codec not ready interrupt mask
  • SAI_IT_WCKCFG: wrong clock configuration interrupt mask
NewStatenew state of the specified SAI interrupt. This parameter can be: ENABLE or DISABLE.
Return values
None
void SAI_MonoModeConfig ( SAI_Block_TypeDef SAI_Block_x,
uint32_t  SAI_Mono_StreoMode 
)

Configures the mono mode for the selected SAI block.

Note
This function has a meaning only when the number of slot is equal to 2.
Parameters
SAI_Block_xwhere x can be A or B to select the SAI Block peripheral.
SAI_MonoModespecifies the SAI block mono mode. This parameter can be one of the following values:
  • SAI_MonoMode : Set mono audio mode
  • SAI_StreoMode : Set streo audio mode
Return values
None
void SAI_MuteFrameCounterConfig ( SAI_Block_TypeDef SAI_Block_x,
uint32_t  SAI_MuteCounter 
)

Enables or disables the Mute mode for the selected SAI block.

Note
This function has a meaning only when the audio block is Receiver
Parameters
SAI_Block_xwhere x can be A or B to select the SAI Block peripheral.
SAI_MuteCounterspecifies the SAI block mute value. This parameter can be a number between 0 and 63.
Return values
None
void SAI_MuteModeCmd ( SAI_Block_TypeDef SAI_Block_x,
FunctionalState  NewState 
)

Enables or disables the Mute mode for the selected SAI block.

Note
This function has a meaning only when the audio block is transmitter
Mute mode is applied for an entire frame for all the valid slot It becomes active at the end of an audio frame when set somewhere in a frame. Mute mode exit occurs at the end of the frame in which the bit MUTE has been set.
Parameters
SAI_Block_xwhere x can be A or B to select the SAI Block peripheral.
NewStatenew state of the SAIx block. This parameter can be: ENABLE or DISABLE.
Return values
None
void SAI_MuteValueConfig ( SAI_Block_TypeDef SAI_Block_x,
uint32_t  SAI_MuteValue 
)

Configure the mute value for the selected SAI block.

Note
This function has a meaning only when the audio block is transmitter
the configuration last value sent during mute mode has only a meaning when the number of slot is lower or equal to 2 and if the MUTE bit is set.
Parameters
SAI_Block_xwhere x can be A or B to select the SAI Block peripheral.
SAI_MuteValuespecifies the SAI block mute value. This parameter can be one of the following values:
  • SAI_ZeroValue : bit value 0 is sent during Mute Mode
  • SAI_LastSentValue : Last value is sent during Mute Mode
Return values
None
uint32_t SAI_ReceiveData ( SAI_Block_TypeDef SAI_Block_x)

Returns the most recent received data by the SAI block x peripheral.

Parameters
SAI_Block_xwhere x can be A or B to select the SAI Block peripheral.
Return values
Thevalue of the received data.
void SAI_SendData ( SAI_Block_TypeDef SAI_Block_x,
uint32_t  Data 
)

Transmits a Data through the SAI block x peripheral.

Parameters
SAI_Block_xwhere x can be A or B to select the SAI Block peripheral.
DataData to be transmitted.
Return values
None
void SAI_SlotInit ( SAI_Block_TypeDef SAI_Block_x,
SAI_SlotInitTypeDef SAI_SlotInitStruct 
)

Initializes the SAI Block audio Slot according to the specified parameters in the SAI_SlotInitStruct.

Note
this function has no meaning if the AC'97 or SPDIF audio protocol are selected.
Parameters
SAI_Block_xwhere x can be A or B to select the SAI Block peripheral.
SAI_SlotInitStructpointer to an SAI_SlotInitTypeDef structure that contains the configuration of audio slot for a specified SAI Block
Return values
None
void SAI_SlotStructInit ( SAI_SlotInitTypeDef SAI_SlotInitStruct)

Fills each SAI_SlotInitStruct member with its default value.

Parameters
SAI_SlotInitStructpointer to a SAI_SlotInitTypeDef structure which will be initialized.
Return values
None
void SAI_StructInit ( SAI_InitTypeDef SAI_InitStruct)

Fills each SAI_InitStruct member with its default value.

Parameters
SAI_InitStructpointer to a SAI_InitTypeDef structure which will be initialized.
Return values
None
void SAI_TRIStateConfig ( SAI_Block_TypeDef SAI_Block_x,
uint32_t  SAI_TRIState 
)

Configures the TRIState managment on data line for the selected SAI block.

Note
This function has a meaning only when the SAI block is configured in transmitter
Parameters
SAI_Block_xwhere x can be A or B to select the SAI Block peripheral.
SAI_TRIStatespecifies the SAI block TRIState management. This parameter can be one of the following values:
  • SAI_Output_NotReleased : SD output line is still drived by the SAI.
  • SAI_Output_Released : SD output line is released (HI-Z)
Return values
None