discoverpixy
Functions
Interrupts and flags management functions

Interrupts and flags management functions. More...

Collaboration diagram for Interrupts and flags management functions:

Functions

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

Interrupts and flags management functions.

 ===============================================================================
            ##### Interrupts and flags management functions #####
 ===============================================================================  
  [..]
  This section provides a set of functions allowing to configure the SAI Interrupts 
  sources and check or clear the flags or pending bits status.
  The user should identify which mode will be used in his application to manage 
  the communication: Polling mode, Interrupt mode or DMA mode. 
    
  *** Polling Mode ***
  ====================
  [..]
  In Polling Mode, the SAI communication can be managed by 7 flags:
     (#) SAI_FLAG_FREQ : to indicate if there is a FIFO Request to write or to read.
     (#) SAI_FLAG_MUTEDET : to indicate if a MUTE frame detected
     (#) SAI_FLAG_OVRUDR : to indicate if an Overrun or Underrun error occur
     (#) SAI_FLAG_AFSDET : to indicate if there is the detection of a audio frame 
                          synchronisation (FS) earlier than expected
     (#) SAI_FLAG_LFSDET : to indicate if there is the detection of a audio frame 
                          synchronisation (FS) later than expected              
     (#) SAI_FLAG_CNRDY : to indicate if  the codec is not ready to communicate during 
                         the reception of the TAG 0 (slot0) of the AC97 audio frame 
     (#) SAI_FLAG_WCKCFG: to indicate if wrong clock configuration in master mode 
                         error occurs.
  [..]
  In this Mode it is advised to use the following functions:
     (+) FlagStatus SAI_GetFlagStatus(SAI_Block_TypeDef* SAI_Block_x, uint32_t SAI_FLAG);
     (+) void SAI_ClearFlag(SAI_Block_TypeDef* SAI_Block_x, uint32_t SAI_FLAG);

  *** Interrupt Mode ***
  ======================
  [..]
  In Interrupt Mode, the SAI communication can be managed by 7 interrupt sources
  and 7 pending bits: 
  (+) Pending Bits:
     (##) SAI_IT_FREQ : to indicate if there is a FIFO Request to write or to read.
     (##) SAI_IT_MUTEDET : to indicate if a MUTE frame detected.
     (##) SAI_IT_OVRUDR : to indicate if an Overrun or Underrun error occur.
     (##) SAI_IT_AFSDET : to indicate if there is the detection of a audio frame 
                          synchronisation (FS) earlier than expected.
     (##) SAI_IT_LFSDET : to indicate if there is the detection of a audio frame 
                          synchronisation (FS) later than expected.              
     (##) SAI_IT_CNRDY : to indicate if  the codec is not ready to communicate during 
                         the reception of the TAG 0 (slot0) of the AC97 audio frame. 
     (##) SAI_IT_WCKCFG: to indicate if wrong clock configuration in master mode 
                         error occurs.

  (+) Interrupt Source:
     (##) SAI_IT_FREQ : specifies the interrupt source for FIFO Request.
     (##) SAI_IT_MUTEDET : specifies the interrupt source for MUTE frame detected.
     (##) SAI_IT_OVRUDR : specifies the interrupt source for overrun or underrun error.
     (##) SAI_IT_AFSDET : specifies the interrupt source for anticipated frame synchronization
                          detection interrupt.
     (##) SAI_IT_LFSDET : specifies the interrupt source for late frame synchronization
                          detection interrupt.             
     (##) SAI_IT_CNRDY : specifies the interrupt source for codec not ready interrupt
     (##) SAI_IT_WCKCFG: specifies the interrupt source for wrong clock configuration
                         interrupt.
  [..]                     
  In this Mode it is advised to use the following functions:
     (+) void SAI_ITConfig(SAI_Block_TypeDef* SAI_Block_x, uint32_t SAI_IT, FunctionalState NewState);
     (+) ITStatus SAI_GetITStatus(SAI_Block_TypeDef* SAI_Block_x, uint32_t SAI_IT);
     (+) void SAI_ClearITPendingBit(SAI_Block_TypeDef* SAI_Block_x, uint32_t SAI_IT);

  *** DMA Mode ***
  ================
  [..]
  In DMA Mode, each SAI audio block has an independent DMA interface in order to 
  read or to write into the SAI_xDR register (to hit the internal FIFO). 
  There is one DMA channel by audio block following basic DMA request/acknowledge 
  protocol.
  [..]
  In this Mode it is advised to use the following function:
    (+) void SAI_DMACmd(SAI_Block_TypeDef* SAI_Block_x, FunctionalState NewState);
  [..]
  This section provides also functions allowing to
   (+) Check the SAI Block enable status
   (+)Check the FIFO status 
   
  *** SAI Block Enable status ***
  ===============================
  [..]
  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. 
  To monitor this state it is possible to use the following function:
    (+) FunctionalState SAI_GetCmdStatus(SAI_Block_TypeDef* SAI_Block_x); 
 
  *** SAI Block FIFO status ***
  =============================
  [..]
  It is possible to monitor the FIFO status when a transfer is ongoing using the following 
  function:
    (+) uint32_t SAI_GetFIFOStatus(SAI_Block_TypeDef* SAI_Block_x);

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
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_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