STM8L15x Standard Peripherals Drivers: Interrupts and flags management functions

STM8L15x/16x Standard Peripherals Drivers

STM8L15x Standard Peripherals Drivers

Interrupts and flags management functions

Interrupts and flags management functions. More...

Functions

void SPI_ClearFlag (SPI_TypeDef *SPIx, SPI_FLAG_TypeDef SPI_FLAG)
 Clears the SPI flags.
void SPI_ClearITPendingBit (SPI_TypeDef *SPIx, SPI_IT_TypeDef SPI_IT)
 Clears the interrupt pending bits.
FlagStatus SPI_GetFlagStatus (SPI_TypeDef *SPIx, SPI_FLAG_TypeDef SPI_FLAG)
 Checks whether the specified SPI flag is set or not.
ITStatus SPI_GetITStatus (SPI_TypeDef *SPIx, SPI_IT_TypeDef SPI_IT)
 Checks whether the specified interrupt has occurred or not.
void SPI_ITConfig (SPI_TypeDef *SPIx, SPI_IT_TypeDef SPI_IT, FunctionalState NewState)
 Enables or disables the specified interrupts.

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 communication can be managed by 6 flags:
     1. SPI_FLAG_TXE: to indicate the status of the transmit buffer register
     2. SPI_FLAG_RXNE: to indicate the status of the receive buffer register
     3. SPI_FLAG_WKUP: to indicate the state of the Wakeup event.
     4. SPI_FLAG_CRCERR: to indicate if a CRC Calculation error occurs              
     5. SPI_FLAG_MODF: to indicate if a Mode Fault error occurs
     6. SPI_FLAG_OVR: to indicate if an Overrun error occurs

  In this Mode it is advised to use the following functions:
     - FlagStatus SPI_GetFlagStatus(SPI_TypeDef* SPIx, SPI_FLAG_TypeDef SPI_FLAG);
     - void SPI_ClearFlag(SPI_TypeDef* SPIx, SPI_FLAG_TypeDef SPI_FLAG);

  Interrupt Mode
  ===============
  In Interrupt Mode, the SPI communication can be managed by 4 interrupt sources
  and 6 pending bits: 
  Pending Bits:
  ------------- 
     1. SPI_IT_TXE: to indicate the status of the transmit buffer register
     2. SPI_IT_RXNE: to indicate the status of the receive buffer register
     3. SPI_IT_CRCERR: to indicate if a CRC Calculation error occurs              
     4. SPI_IT_MODF: to indicate if a Mode Fault error occurs
     5. SPI_IT_OVR: to indicate if an Overrun error occurs
     6. SPI_IT_WKUP: to indicate if an Wake_up event occurs
  Interrupt Source:
  -----------------
     1. SPI_IT_TXE: specifies the interrupt source for the Tx buffer empty 
                        interrupt.  
     2. SPI_IT_RXNE: specifies the interrupt source for the Rx buffer not 
                          empty interrupt.
     3. SPI_IT_ERR: specifies the interrupt source for the errors interrupt.
		 4. SPI_IT_WKUP: specifies the interrupt source for the Wake-up interrupt.

  In this Mode it is advised to use the following functions:
     - void SPI_ITConfig(SPI_TypeDef* SPIx, SPI_IT_TypeDef SPI_IT, FunctionalState NewState);
     - ITStatus SPI_GetITStatus(SPI_TypeDef* SPIx, SPI_IT_TypeDef SPI_IT);
     - void SPI_ClearITPendingBit(SPI_TypeDef* SPIx, SPI_IT_TypeDef SPI_IT);

  DMA Mode
  ========
  In DMA Mode, the SPI communication can be managed by 2 DMA Channel requests:
     1. SPI_DMAReq_Tx: specifies the Tx buffer DMA transfer request
     2. SPI_DMAReq_Rx: specifies the Rx buffer DMA transfer request

  In this Mode it is advised to use the following function:
    - void SPI_DMACmd(SPI_TypeDef* SPIx, SPI_DMAReq_TypeDef SPI_DMAReq, FunctionalState NewState);


Function Documentation

void SPI_ClearFlag ( SPI_TypeDef SPIx,
SPI_FLAG_TypeDef  SPI_FLAG 
)

Clears the SPI flags.

Parameters:
SPIx,:where x can be 1 to select the specified SPI peripheral.
SPI_FLAG,:Specifies the flag to clear. This parameter can be one of the following values:
  • SPI_FLAG_CRCERR
  • SPI_FLAG_WKUP
Note:
OVR (OverRun Error) interrupt pending bit is cleared by software sequence: a read operation to SPI_DR register (SPI_ReceiveData()) followed by a read operation to SPI_SR register (SPI_GetFlagStatus()).
MODF (Mode Fault) interrupt pending bit is cleared by software sequence: a read/write operation to SPI_SR register (SPI_GetFlagStatus()) followed by a write operation to SPI_CR1 register (SPI_Cmd() to enable the SPI).
Return values:
None

Definition at line 690 of file stm8l15x_spi.c.

References IS_SPI_CLEAR_FLAG, and SPI_struct::SR.

void SPI_ClearITPendingBit ( SPI_TypeDef SPIx,
SPI_IT_TypeDef  SPI_IT 
)

Clears the interrupt pending bits.

Parameters:
SPIx,:where x can be 1 to select the specified SPI peripheral.
SPI_IT,:Specifies the interrupt pending bit to clear. This parameter can be one of the following values:
  • SPI_IT_CRCERR
  • SPI_IT_WKUP
Note:
OVR (OverRun Error) interrupt pending bit is cleared by software sequence: a read operation to SPI_DR register (SPI_ReceiveData()) followed by a read operation to SPI_SR register (SPI_GetITStatus()).
MODF (Mode Fault) interrupt pending bit is cleared by software sequence: a read/write operation to SPI_SR register (SPI_GetITStatus()) followed by a write operation to SPI_CR1 register (SPI_Cmd() to enable the SPI).
Return values:
None

Definition at line 758 of file stm8l15x_spi.c.

References IS_SPI_CLEAR_IT, and SPI_struct::SR.

FlagStatus SPI_GetFlagStatus ( SPI_TypeDef SPIx,
SPI_FLAG_TypeDef  SPI_FLAG 
)

Checks whether the specified SPI flag is set or not.

Parameters:
SPIx,:where x can be 1 to select the specified SPI peripheral.
SPI_FLAG,:Specifies the flag to check. This parameter can be one of the following values:
  • SPI_FLAG_BSY: Busy
  • SPI_FLAG_OVR: Overrun
  • SPI_FLAG_MODF: Mode fault
  • SPI_FLAG_CRCERR: CRC error
  • SPI_FLAG_WKUP: Wake-up
  • SPI_FLAG_TXE: Transmit buffer empty
  • SPI_FLAG_RXNE: Receive buffer empty
Return values:
Indicatesthe state of SPI_FLAG. This parameter can be SET or RESET.

Definition at line 655 of file stm8l15x_spi.c.

References IS_SPI_FLAG, RESET, SET, and SPI_struct::SR.

ITStatus SPI_GetITStatus ( SPI_TypeDef SPIx,
SPI_IT_TypeDef  SPI_IT 
)

Checks whether the specified interrupt has occurred or not.

Parameters:
SPIx,:where x can be 1 to select the specified SPI peripheral.
SPI_IT,:Specifies the SPI interrupt pending bit to check. This parameter can be one of the following values:
  • SPI_IT_CRCERR
  • SPI_IT_WKUP
  • SPI_IT_OVR
  • SPI_IT_MODF
  • SPI_IT_RXNE
  • SPI_IT_TXE
Return values:
Indicatesthe state of the SPI_IT.

Definition at line 711 of file stm8l15x_spi.c.

References __IO, SPI_struct::CR3, IS_SPI_GET_IT, RESET, SET, and SPI_struct::SR.

void SPI_ITConfig ( SPI_TypeDef SPIx,
SPI_IT_TypeDef  SPI_IT,
FunctionalState  NewState 
)

Enables or disables the specified interrupts.

Parameters:
SPIx,:where x can be 1 to select the specified SPI peripheral.
SPI_ITSpecifies the SPI interrupts sources to be enabled or disabled. This parameter can be one of the following values:
  • SPI_IT_TXE: Transmit buffer empty
  • SPI_IT_RXNE: Receive buffer not empty
  • SPI_IT_ERR: Error
  • SPI_IT_WKUP: Wake-up
NewState,:The new state of the specified SPI interrupts. This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 620 of file stm8l15x_spi.c.

References SPI_struct::CR3, DISABLE, IS_FUNCTIONAL_STATE, and IS_SPI_CONFIG_IT.

STM8S Firmware Library: Overview

 

 

 

For complete documentation on STM8L15x 8-bit microcontrollers platform visit www.st.com