Martin Johnson / STM32F3-Discovery

Dependents:   Space_Invaders_Demo neopixels gpio_test_stm32f3_discovery gpio_test_systimer ... more

Embed: (wiki syntax)

« Back to documentation index

Interrupts and flags management functions

Interrupts and flags management functions
[SPI_Private_Functions]

Interrupts and flags management functions. More...

Functions

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

Detailed Description

Interrupts and flags management functions.

 ===============================================================================
              ##### 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:
SPIx,:where x can be 1, 2, 3 or 4 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 1282 of file stm32f30x_spi.c.

uint16_t SPI_GetTransmissionFIFOStatus ( SPI_TypeDef *  SPIx )

Returns the current SPIx Transmission FIFO filled level.

Parameters:
SPIx,:where x can be 1, 2, 3 or 4 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 1267 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:
SPIx,:To select the SPIx/I2Sx peripheral, where x can be: 1, 2, 3 or 4 in SPI mode or 2 or 3 in I2S mode or I2Sxext for I2S full duplex mode.
SPI_I2S_FLAG,:specifies 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 1341 of file stm32f30x_spi.c.

FlagStatus SPI_I2S_GetFlagStatus ( SPI_TypeDef *  SPIx,
uint16_t  SPI_I2S_FLAG 
)

Checks whether the specified SPI flag is set or not.

Parameters:
SPIx,:To select the SPIx/I2Sx peripheral, where x can be: 1, 2, 3 or 4 in SPI mode or 2 or 3 in I2S mode or I2Sxext for I2S full duplex mode.
SPI_I2S_FLAG,:specifies 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 1305 of file stm32f30x_spi.c.

ITStatus SPI_I2S_GetITStatus ( SPI_TypeDef *  SPIx,
uint8_t  SPI_I2S_IT 
)

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

Parameters:
SPIx,:To select the SPIx/I2Sx peripheral, where x can be: 1, 2, 3 or 4 in SPI mode or 2 or 3 in I2S mode or I2Sxext for I2S full duplex mode.
SPI_I2S_IT,:specifies 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 1365 of file stm32f30x_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:
SPIx,:To select the SPIx/I2Sx peripheral, where x can be: 1, 2, 3 or 4 in SPI mode or 2 or 3 in I2S mode or I2Sxext for I2S full duplex mode.
SPI_I2S_IT,:specifies 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
NewState,:new state of the specified SPI interrupt. This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 1231 of file stm32f30x_spi.c.