Functions

Interrupts and flags management functions. More...

Collaboration diagram for Interrupts and flags management functions:

Functions

uint16_t SPI_GetReceptionFIFOStatus (SPI_TypeDef *SPIx)
 Returns the current SPIx Reception FIFO filled level. More...
 
uint16_t SPI_GetTransmissionFIFOStatus (SPI_TypeDef *SPIx)
 Returns the current SPIx Transmission FIFO filled level. More...
 
void SPI_I2S_ClearFlag (SPI_TypeDef *SPIx, uint16_t SPI_I2S_FLAG)
 Clears the SPIx CRC Error (CRCERR) flag. More...
 
void SPI_I2S_ClearITPendingBit (SPI_TypeDef *SPIx, uint8_t SPI_I2S_IT)
 Clears the SPIx CRC Error (CRCERR) interrupt pending bit. More...
 
FlagStatus SPI_I2S_GetFlagStatus (SPI_TypeDef *SPIx, uint16_t SPI_I2S_FLAG)
 Checks whether the specified SPIx/I2Sx flag is set or not. More...
 
ITStatus SPI_I2S_GetITStatus (SPI_TypeDef *SPIx, uint8_t SPI_I2S_IT)
 Checks whether the specified SPIx/I2Sx interrupt has occurred or not. More...
 
void SPI_I2S_ITConfig (SPI_TypeDef *SPIx, uint8_t SPI_I2S_IT, FunctionalState NewState)
 Enables or disables the specified SPI/I2S interrupts. More...
 

Detailed Description

Interrupts and flags management functions.

 ===============================================================================
            ##### Interrupts and flags management functions #####
 ===============================================================================  
 
 [..] This section provides a set of functions allowing to configure the SPI 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 SPI/I2S communication can be managed by 9 flags:
  (#) SPI_I2S_FLAG_TXE : to indicate the status of the transmit buffer register
  (#) SPI_I2S_FLAG_RXNE : to indicate the status of the receive buffer register
  (#) SPI_I2S_FLAG_BSY : to indicate the state of the communication layer of the SPI.
  (#) SPI_FLAG_CRCERR : to indicate if a CRC Calculation error occur              
  (#) SPI_FLAG_MODF : to indicate if a Mode Fault error occur
  (#) SPI_I2S_FLAG_OVR : to indicate if an Overrun error occur
  (#) I2S_FLAG_TIFRFE: to indicate a Frame Format error occurs.
  (#) I2S_FLAG_UDR: to indicate an Underrun error occurs.
  (#) I2S_FLAG_CHSIDE: to indicate Channel Side.

  (@) Do not use the BSY flag to handle each data transmission or reception. It is
      better to use the TXE and RXNE flags instead.

 [..] In this Mode it is advised to use the following functions:
   (+) FlagStatus SPI_I2S_GetFlagStatus(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG);
   (+) void SPI_I2S_ClearFlag(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG);

 *** Interrupt Mode ***
 ======================
 [..] In Interrupt Mode, the SPI communication can be managed by 3 interrupt sources
      and 7 pending bits: 
   (+) Pending Bits:
       (##) SPI_I2S_IT_TXE : to indicate the status of the transmit buffer register
       (##) SPI_I2S_IT_RXNE : to indicate the status of the receive buffer register
       (##) SPI_IT_CRCERR : to indicate if a CRC Calculation error occur (available in SPI mode only)            
       (##) SPI_IT_MODF : to indicate if a Mode Fault error occur (available in SPI mode only)
       (##) SPI_I2S_IT_OVR : to indicate if an Overrun error occur
       (##) I2S_IT_UDR : to indicate an Underrun Error occurs (available in I2S mode only).
       (##) I2S_FLAG_TIFRFE : to indicate a Frame Format error occurs (available in TI mode only).

   (+) Interrupt Source:
       (##) SPI_I2S_IT_TXE: specifies the interrupt source for the Tx buffer empty 
            interrupt.  
       (##) SPI_I2S_IT_RXNE : specifies the interrupt source for the Rx buffer not 
            empty interrupt.
       (##) SPI_I2S_IT_ERR : specifies the interrupt source for the errors interrupt.

 [..] In this Mode it is advised to use the following functions:
   (+) void SPI_I2S_ITConfig(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT, FunctionalState NewState);
   (+) ITStatus SPI_I2S_GetITStatus(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT);
   (+) void SPI_I2S_ClearITPendingBit(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT);

 *** DMA Mode ***
 ================
 [..] In DMA Mode, the SPI communication can be managed by 2 DMA Channel requests:
   (#) SPI_I2S_DMAReq_Tx: specifies the Tx buffer DMA transfer request
   (#) SPI_I2S_DMAReq_Rx: specifies the Rx buffer DMA transfer request

 [..] In this Mode it is advised to use the following function:
   (+) void SPI_I2S_DMACmd(SPI_TypeDef* SPIx, uint16_t SPI_I2S_DMAReq, FunctionalState 
       NewState);
 ===============================================================================
              ##### Interrupts and flags management functions #####
 ===============================================================================  
    [..] This section provides a set of functions allowing to configure the SPI/I2S 
         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 SPI/I2S communication can be managed by 9 flags:
         (#) SPI_I2S_FLAG_TXE : to indicate the status of the transmit buffer register.
         (#) SPI_I2S_FLAG_RXNE : to indicate the status of the receive buffer register.
         (#) SPI_I2S_FLAG_BSY : to indicate the state of the communication layer of the SPI.
         (#) SPI_FLAG_CRCERR : to indicate if a CRC Calculation error occur.              
         (#) SPI_FLAG_MODF : to indicate if a Mode Fault error occur.
         (#) SPI_I2S_FLAG_OVR : to indicate if an Overrun error occur.
         (#) SPI_I2S_FLAG_FRE: to indicate a Frame Format error occurs.
         (#) I2S_FLAG_UDR: to indicate an Underrun error occurs.
         (#) I2S_FLAG_CHSIDE: to indicate Channel Side.
    [..]
         (@) Do not use the BSY flag to handle each data transmission or reception.
             It is better to use the TXE and RXNE flags instead.
    [..] In this Mode it is advised to use the following functions:
         (+) FlagStatus SPI_I2S_GetFlagStatus(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG);
         (+) void SPI_I2S_ClearFlag(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG);

  *** Interrupt Mode ***
  ======================
    [..] In Interrupt Mode, the SPI/I2S communication can be managed by 3 interrupt sources
         and 5 pending bits: 
    [..] Pending Bits:
         (#) SPI_I2S_IT_TXE : to indicate the status of the transmit buffer register.
         (#) SPI_I2S_IT_RXNE : to indicate the status of the receive buffer register.
         (#) SPI_I2S_IT_OVR : to indicate if an Overrun error occur.
         (#) I2S_IT_UDR : to indicate an Underrun Error occurs.
         (#) SPI_I2S_FLAG_FRE : to indicate a Frame Format error occurs.
    [..] Interrupt Source:
         (#) SPI_I2S_IT_TXE: specifies the interrupt source for the Tx buffer empty 
             interrupt.  
         (#) SPI_I2S_IT_RXNE : specifies the interrupt source for the Rx buffer not 
             empty interrupt.
         (#) SPI_I2S_IT_ERR : specifies the interrupt source for the errors interrupt.
    [..] In this Mode it is advised to use the following functions:
         (+) void SPI_I2S_ITConfig(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT, FunctionalState NewState);
         (+) ITStatus SPI_I2S_GetITStatus(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT);

  *** FIFO Status ***
  ===================
    [..] It is possible to monitor the FIFO status when a transfer is ongoing using the
         following function:
         (+) uint32_t SPI_GetFIFOStatus(uint8_t SPI_FIFO_Direction); 

  *** DMA Mode ***
  ================
    [..] In DMA Mode, the SPI communication can be managed by 2 DMA Channel requests:
         (#) SPI_I2S_DMAReq_Tx: specifies the Tx buffer DMA transfer request.
         (#) SPI_I2S_DMAReq_Rx: specifies the Rx buffer DMA transfer request.
    [..] In this Mode it is advised to use the following function:
         (+) void SPI_I2S_DMACmd(SPI_TypeDef* SPIx, uint16_t SPI_I2S_DMAReq, FunctionalState NewState);

Function Documentation

uint16_t SPI_GetReceptionFIFOStatus ( SPI_TypeDef SPIx)

Returns the current SPIx Reception FIFO filled level.

Parameters
SPIxwhere x can be 1, 2 or 3 to select the SPI peripheral.
Return values
TheReception FIFO filling state.
  • SPI_ReceptionFIFOStatus_Empty: when FIFO is empty
  • SPI_ReceptionFIFOStatus_1QuarterFull: if more than 1 quarter-full.
  • SPI_ReceptionFIFOStatus_HalfFull: if more than 1 half-full.
  • SPI_ReceptionFIFOStatus_Full: when FIFO is full.

Definition at line 1275 of file stm32f30x_spi.c.

uint16_t SPI_GetTransmissionFIFOStatus ( SPI_TypeDef SPIx)

Returns the current SPIx Transmission FIFO filled level.

Parameters
SPIxwhere x can be 1, 2 or 3 to select the SPI peripheral.
Return values
TheTransmission FIFO filling state.
  • SPI_TransmissionFIFOStatus_Empty: when FIFO is empty
  • SPI_TransmissionFIFOStatus_1QuarterFull: if more than 1 quarter-full.
  • SPI_TransmissionFIFOStatus_HalfFull: if more than 1 half-full.
  • SPI_TransmissionFIFOStatus_Full: when FIFO is full.

Definition at line 1260 of file stm32f30x_spi.c.

void SPI_I2S_ClearFlag ( SPI_TypeDef SPIx,
uint16_t  SPI_I2S_FLAG 
)

Clears the SPIx CRC Error (CRCERR) flag.

Parameters
SPIxTo select the SPIx/I2Sx peripheral, where x can be: 1, 2, 3, 4, 5 or 6 in SPI mode or 2 or 3 in I2S mode or I2Sxext for I2S full duplex mode.
SPI_I2S_FLAGspecifies the SPI flag to clear. This function clears only CRCERR flag.
  • SPI_FLAG_CRCERR: CRC Error flag.
Note
OVR (OverRun error) flag is cleared by software sequence: a read operation to SPI_DR register (SPI_I2S_ReceiveData()) followed by a read operation to SPI_SR register (SPI_I2S_GetFlagStatus()).
UDR (UnderRun error) flag is cleared by a read operation to SPI_SR register (SPI_I2S_GetFlagStatus()).
MODF (Mode Fault) flag is cleared by software sequence: a read/write operation to SPI_SR register (SPI_I2S_GetFlagStatus()) followed by a write operation to SPI_CR1 register (SPI_Cmd() to enable the SPI).
Return values
None
Parameters
SPIxTo select the SPIx/I2Sx peripheral, where x can be: 1, 2 or 3 in SPI mode or 2 or 3 in I2S mode or I2Sxext for I2S full duplex mode.
SPI_I2S_FLAGspecifies the SPI flag to clear. This function clears only CRCERR flag.
Note
OVR (OverRun error) flag is cleared by software sequence: a read operation to SPI_DR register (SPI_I2S_ReceiveData()) followed by a read operation to SPI_SR register (SPI_I2S_GetFlagStatus()).
MODF (Mode Fault) flag is cleared by software sequence: a read/write operation to SPI_SR register (SPI_I2S_GetFlagStatus()) followed by a write operation to SPI_CR1 register (SPI_Cmd() to enable the SPI).
Return values
None

Definition at line 1202 of file stm32f4xx_spi.c.

void SPI_I2S_ClearITPendingBit ( SPI_TypeDef SPIx,
uint8_t  SPI_I2S_IT 
)

Clears the SPIx CRC Error (CRCERR) interrupt pending bit.

Parameters
SPIxTo select the SPIx/I2Sx peripheral, where x can be: 1, 2, 3, 4, 5 or 6 in SPI mode or 2 or 3 in I2S mode or I2Sxext for I2S full duplex mode.
SPI_I2S_ITspecifies the SPI interrupt pending bit to clear. This function clears only CRCERR interrupt pending bit.
  • SPI_IT_CRCERR: CRC Error interrupt.
Note
OVR (OverRun Error) interrupt pending bit is cleared by software sequence: a read operation to SPI_DR register (SPI_I2S_ReceiveData()) followed by a read operation to SPI_SR register (SPI_I2S_GetITStatus()).
UDR (UnderRun Error) interrupt pending bit is cleared by a read operation to SPI_SR register (SPI_I2S_GetITStatus()).
MODF (Mode Fault) interrupt pending bit is cleared by software sequence: a read/write operation to SPI_SR register (SPI_I2S_GetITStatus()) followed by a write operation to SPI_CR1 register (SPI_Cmd() to enable the SPI).
Return values
None

Definition at line 1282 of file stm32f4xx_spi.c.

FlagStatus SPI_I2S_GetFlagStatus ( SPI_TypeDef SPIx,
uint16_t  SPI_I2S_FLAG 
)

Checks whether the specified SPIx/I2Sx flag is set or not.

Checks whether the specified SPI flag is set or not.

Parameters
SPIxTo select the SPIx/I2Sx peripheral, where x can be: 1, 2, 3, 4, 5 or 6 in SPI mode or 2 or 3 in I2S mode or I2Sxext for I2S full duplex mode.
SPI_I2S_FLAGspecifies the SPI flag to check. This parameter can be one of the following values:
  • SPI_I2S_FLAG_TXE: Transmit buffer empty flag.
  • SPI_I2S_FLAG_RXNE: Receive buffer not empty flag.
  • SPI_I2S_FLAG_BSY: Busy flag.
  • SPI_I2S_FLAG_OVR: Overrun flag.
  • SPI_FLAG_MODF: Mode Fault flag.
  • SPI_FLAG_CRCERR: CRC Error flag.
  • SPI_I2S_FLAG_TIFRFE: Format Error.
  • I2S_FLAG_UDR: Underrun Error flag.
  • I2S_FLAG_CHSIDE: Channel Side flag.
Return values
Thenew state of SPI_I2S_FLAG (SET or RESET).
Parameters
SPIxTo select the SPIx/I2Sx peripheral, where x can be: 1, 2 or 3 in SPI mode or 2 or 3 in I2S mode or I2Sxext for I2S full duplex mode.
SPI_I2S_FLAGspecifies the SPI flag to check. This parameter can be one of the following values:
  • SPI_I2S_FLAG_TXE: Transmit buffer empty flag.
  • SPI_I2S_FLAG_RXNE: Receive buffer not empty flag.
  • SPI_I2S_FLAG_BSY: Busy flag.
  • SPI_I2S_FLAG_OVR: Overrun flag.
  • SPI_I2S_FLAG_MODF: Mode Fault flag.
  • SPI_I2S_FLAG_CRCERR: CRC Error flag.
  • SPI_I2S_FLAG_FRE: TI frame format error flag.
  • I2S_FLAG_UDR: Underrun Error flag.
  • I2S_FLAG_CHSIDE: Channel Side flag.
Return values
Thenew state of SPI_I2S_FLAG (SET or RESET).

Definition at line 1161 of file stm32f4xx_spi.c.

ITStatus SPI_I2S_GetITStatus ( SPI_TypeDef SPIx,
uint8_t  SPI_I2S_IT 
)

Checks whether the specified SPIx/I2Sx interrupt has occurred or not.

Checks whether the specified SPI/I2S interrupt has occurred or not.

Parameters
SPIxTo select the SPIx/I2Sx peripheral, where x can be: 1, 2, 3, 4, 5 or 6 in SPI mode or 2 or 3 in I2S mode or I2Sxext for I2S full duplex mode.
SPI_I2S_ITspecifies the SPI interrupt source to check. This parameter can be one of the following values:
  • SPI_I2S_IT_TXE: Transmit buffer empty interrupt.
  • SPI_I2S_IT_RXNE: Receive buffer not empty interrupt.
  • SPI_I2S_IT_OVR: Overrun interrupt.
  • SPI_IT_MODF: Mode Fault interrupt.
  • SPI_IT_CRCERR: CRC Error interrupt.
  • I2S_IT_UDR: Underrun interrupt.
  • SPI_I2S_IT_TIFRFE: Format Error interrupt.
Return values
Thenew state of SPI_I2S_IT (SET or RESET).
Parameters
SPIxTo select the SPIx/I2Sx peripheral, where x can be: 1, 2 or 3 in SPI mode or 2 or 3 in I2S mode or I2Sxext for I2S full duplex mode.
SPI_I2S_ITspecifies the SPI interrupt source to check. This parameter can be one of the following values:
  • SPI_I2S_IT_TXE: Transmit buffer empty interrupt.
  • SPI_I2S_IT_RXNE: Receive buffer not empty interrupt.
  • SPI_IT_MODF: Mode Fault interrupt.
  • SPI_I2S_IT_OVR: Overrun interrupt.
  • I2S_IT_UDR: Underrun interrupt.
  • SPI_I2S_IT_FRE: Format Error interrupt.
Return values
Thenew state of SPI_I2S_IT (SET or RESET).

Definition at line 1227 of file stm32f4xx_spi.c.

void SPI_I2S_ITConfig ( SPI_TypeDef SPIx,
uint8_t  SPI_I2S_IT,
FunctionalState  NewState 
)

Enables or disables the specified SPI/I2S interrupts.

Parameters
SPIxTo select the SPIx/I2Sx peripheral, where x can be: 1, 2, 3, 4, 5 or 6 in SPI mode or 2 or 3 in I2S mode or I2Sxext for I2S full duplex mode.
SPI_I2S_ITspecifies the SPI interrupt source to be enabled or disabled. This parameter can be one of the following values:
  • SPI_I2S_IT_TXE: Tx buffer empty interrupt mask
  • SPI_I2S_IT_RXNE: Rx buffer not empty interrupt mask
  • SPI_I2S_IT_ERR: Error interrupt mask
NewStatenew state of the specified SPI interrupt. This parameter can be: ENABLE or DISABLE.
Return values
None
Parameters
SPIxTo select the SPIx/I2Sx peripheral, where x can be: 1, 2 or 3 in SPI mode or 2 or 3 in I2S mode or I2Sxext for I2S full duplex mode.
SPI_I2S_ITspecifies the SPI interrupt source to be enabled or disabled. This parameter can be one of the following values:
  • SPI_I2S_IT_TXE: Tx buffer empty interrupt mask
  • SPI_I2S_IT_RXNE: Rx buffer not empty interrupt mask
  • SPI_I2S_IT_ERR: Error interrupt mask
NewStatenew state of the specified SPI interrupt. This parameter can be: ENABLE or DISABLE.
Return values
None

Definition at line 1117 of file stm32f4xx_spi.c.



rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Thu Sep 3 2020 03:22:22