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 USART_ClearFlag (USART_TypeDef *USARTx, USART_FLAG_TypeDef USART_FLAG)
 Clears the USARTx's pending flags.
void USART_ClearITPendingBit (USART_TypeDef *USARTx, USART_IT_TypeDef USART_IT)
 Clears the USARTx�s interrupt pending bits.
FlagStatus USART_GetFlagStatus (USART_TypeDef *USARTx, USART_FLAG_TypeDef USART_FLAG)
 Checks whether the specified USART flag is set or not.
ITStatus USART_GetITStatus (USART_TypeDef *USARTx, USART_IT_TypeDef USART_IT)
 Checks whether the specified USART interrupt has occurred or not.
void USART_ITConfig (USART_TypeDef *USARTx, USART_IT_TypeDef USART_IT, FunctionalState NewState)
 Enables or disables the specified USART interrupts.

Detailed Description

Interrupts and flags management functions.

 ===============================================================================
                   Interrupts and flags management functions
 ===============================================================================  

  This subsection provides a set of functions allowing to configure the USART 
  Interrupts sources, DMA channels requests 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 USART communication can be managed by 9 flags:
     1. USART_FLAG_TXE: to indicate the status of the transmit buffer register
     2. USART_FLAG_RXNE: to indicate the status of the receive buffer register
     3. USART_FLAG_TC: to indicate the status of the transmit operation
     4. USART_FLAG_IDLE: to indicate the status of the Idle Line             
     5. USART_FLAG_SBK: to indicate the status of the Send Break characters
     6. USART_FLAG_NE: to indicate if a noise error occur
     7. USART_FLAG_FE: to indicate if a frame error occur
     8. USART_FLAG_PE: to indicate if a parity error occur
     9. USART_FLAG_ORE: to indicate if an Overrun error occur

  In this Mode it is advised to use the following functions:
      - FlagStatus USART_GetFlagStatus(USART_TypeDef* USARTx, USART_FLAG_TypeDef USART_FLAG);
      - void USART_ClearFlag(USART_TypeDef* USARTx, USART_FLAG_TypeDef USART_FLAG);

  Interrupt Mode
  ===============
  In Interrupt Mode, the USART communication can be managed by 7 interrupt sources
  and 6 pending bits: 

  Pending Bits:
  ------------- 
     1. USART_IT_TXE: to indicate the status of the transmit buffer register
     2. USART_IT_RXNE: to indicate the status of the receive buffer register
     3. USART_IT_TC: to indicate the status of the transmit operation
     4. USART_IT_IDLE: to indicate the status of the Idle Line             
     5. USART_IT_PE: to indicate if a parity error occur
     6. USART_IT_OR: to indicate if an Noise flag, overrun error and framing error in
											multibuffer communication error occur

  Interrupt Source:
  -----------------
     1. USART_IT_TXE: specifies the interrupt source for the Tx buffer empty 
                       interrupt. 
     2. USART_IT_RXNE: specifies the interrupt source for the Rx buffer not 
                        empty interrupt.
     3. USART_IT_TC: specifies the interrupt source for the Transmit complete 
											interrupt. 
     4. USART_IT_IDLE: specifies the interrupt source for the Idle Line interrupt.
     5. USART_IT_PE: specifies the interrupt source for the parity error interrupt. 
     6. USART_IT_ERR:  specifies the interrupt source for the errors interrupt.
		 7. USART_IT_OR: specifies the interrupt source for the overrun error interrupt.

    Note: Some parameters are coded in order to use them as interrupt source or 
    ----  as pending bits.

  In this Mode it is advised to use the following functions:
     - void USART_ITConfig(USART_TypeDef* USARTx, USART_IT_TypeDef USART_IT, FunctionalState
                      		 NewState);
     - ITStatus USART_GetITStatus(USART_TypeDef* USARTx, USART_IT_TypeDef USART_IT);
     - void USART_ClearITPendingBit(USART_TypeDef* USARTx, USART_IT_TypeDef USART_IT);

  DMA Mode
  ========
  In DMA Mode, the USART communication can be managed by 2 DMA Channel requests:
     1. USART_DMAReq_Tx: specifies the Tx buffer DMA transfer request
     2. USART_DMAReq_Rx: specifies the Rx buffer DMA transfer request

  In this Mode it is advised to use the following function:
     - void USART_DMACmd(USART_TypeDef* USARTx, uint16_t USART_DMAReq, FunctionalState NewState);


Function Documentation

void USART_ClearFlag ( USART_TypeDef USARTx,
USART_FLAG_TypeDef  USART_FLAG 
)

Clears the USARTx's pending flags.

Parameters:
USARTx,:where x can be 1 to select the specified USART peripheral.
USART_FLAG,:specifies the flag to clear. This parameter can be any combination of the following values:
  • USART_FLAG_TC: Transmission Complete flag.
  • USART_FLAG_RXNE: Receive data register not empty flag.
Note:
PE (Parity error), FE (Framing error), NE (Noise error), OR (OverRun error) and IDLE (Idle line detected) flags are cleared by software sequence: a read operation to USART_SR register (USART_GetFlagStatus())followed by a read operation to USART_DR register(USART_ReceiveData8() or USART_ReceiveData9()).
RXNE flag can be also cleared by a read to the USART_DR register (USART_ReceiveData8()or USART_ReceiveData9()).
TC flag can be also cleared by software sequence: a read operation to USART_SR register (USART_GetFlagStatus()) followed by a write operation to USART_DR register (USART_SendData8() or USART_SendData9()).
TXE flag is cleared only by a write to the USART_DR register (USART_SendData8() or USART_SendData9()).
SBK flag is cleared during the stop bit of break.
Return values:
None

Definition at line 1054 of file stm8l15x_usart.c.

References IS_USART_CLEAR_FLAG, and USART_struct::SR.

void USART_ClearITPendingBit ( USART_TypeDef USARTx,
USART_IT_TypeDef  USART_IT 
)

Clears the USARTx�s interrupt pending bits.

Parameters:
USARTx,:where x can be 1 to select the specified USART peripheral.
USART_IT,:specifies the interrupt pending bit to clear. This parameter can be one of the following values:
  • USART_IT_RXNE: Receive Data register not empty interrupt.
  • USART_IT_TC: Transmission complete interrupt.
Note:
PE (Parity error), FE (Framing error), NE (Noise error), OR (OverRun error) and IDLE (Idle line detected) pending bits are cleared by software sequence: a read operation to USART_SR register (USART_GetITStatus()) followed by a read operation to USART_DR register (USART_ReceiveData8() or USART_ReceiveData9()).
RXNE pending bit can be also cleared by a read to the USART_DR register (USART_ReceiveData8() or USART_ReceiveData9()).
TC (Transmit complete) pending bit can be also cleared by software sequence: a read operation to USART_SR register (USART_GetITStatus()) followed by a write operation to USART_DR register (USART_SendData8() or USART_SendData9()).
TXE pending bit is cleared only by a write to the USART_DR register (USART_SendData8() or USART_SendData9()).
Return values:
None

Definition at line 1178 of file stm8l15x_usart.c.

References IS_USART_CLEAR_IT, and USART_struct::SR.

FlagStatus USART_GetFlagStatus ( USART_TypeDef USARTx,
USART_FLAG_TypeDef  USART_FLAG 
)

Checks whether the specified USART flag is set or not.

Parameters:
USARTx,:Select the USARTx peripheral.
USART_FLAGspecifies the flag to check. This parameter can be one of the following values:
  • USART_FLAG_TXE: Transmit Data Register empty
  • USART_FLAG_TC: Transmission Complete
  • USART_FLAG_RXNE: Read Data Register Not Empty
  • USART_FLAG_IDLE: Idle line detected
  • USART_FLAG_OR: OverRun error
  • USART_FLAG_NF: Noise error
  • USART_FLAG_FE: Framing Error
  • USART_FLAG_PE: Parity Error
  • USART_FLAG_SBK: Send Break characters
Return values:
FlagStatus(SET or RESET)

Definition at line 996 of file stm8l15x_usart.c.

References USART_struct::CR2, IS_USART_FLAG, RESET, SET, USART_struct::SR, and USART_FLAG_SBK.

ITStatus USART_GetITStatus ( USART_TypeDef USARTx,
USART_IT_TypeDef  USART_IT 
)

Checks whether the specified USART interrupt has occurred or not.

Parameters:
USARTx,:where x can be 1 to select the specified USART peripheral.
USART_IT,:Specifies the USART interrupt pending bit to check. This parameter can be one of the following values:
  • USART_IT_TXE: Transmit Data Register empty interrupt
  • USART_IT_TC: Transmission complete interrupt
  • USART_IT_RXNE: Receive Data register not empty interrupt
  • USART_IT_IDLE: Idle line detection interrupt
  • USART_IT_OR: OverRun Error interrupt
  • USART_IT_PE: Parity Error interrupt
  • USART_IT_FE: Frame Error interrupt
  • USART_IT_NF: Noise Flag Error interrupt
Return values:
ITStatusThe new state of USART_IT (SET or RESET).

Definition at line 1077 of file stm8l15x_usart.c.

References USART_struct::CR1, USART_struct::CR2, USART_struct::CR5, IS_USART_GET_IT, RESET, SET, USART_struct::SR, USART_CR5_EIE, USART_IT_OR, and USART_IT_PE.

void USART_ITConfig ( USART_TypeDef USARTx,
USART_IT_TypeDef  USART_IT,
FunctionalState  NewState 
)

Enables or disables the specified USART interrupts.

Parameters:
USARTx,:where x can be 1 to select the specified USART peripheral.
USART_ITspecifies the USART interrupt sources to be enabled or disabled. This parameter can be one of the following values:
  • USART_IT_TXE: Transmit Data Register empty interrupt
  • USART_IT_TC: Transmission complete interrupt
  • USART_IT_RXNE: Receive Data register not empty interrupt
  • USART_IT_OR: Overrun error interrupt
  • USART_IT_IDLE: Idle line detection interrupt
  • USART_IT_ERR: Error interrupt
NewStatenew state of the specified USART interrupts. This parameter can be: ENABLE or DISABLE.
Return values:
None

< Enable the Interrupt bits according to USART_IT mask

< Disable the interrupt bits according to USART_IT mask

Definition at line 933 of file stm8l15x_usart.c.

References USART_struct::CR1, USART_struct::CR2, USART_struct::CR5, DISABLE, IS_FUNCTIONAL_STATE, and IS_USART_CONFIG_IT.

STM8S Firmware Library: Overview

 

 

 

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