CARME-M4 BSP  V1.5
Interrupts and flags management functions

Interrupts and flags management functions. More...

+ Collaboration diagram for Interrupts and flags management functions:

Functions

void USART_ITConfig (USART_TypeDef *USARTx, uint16_t USART_IT, FunctionalState NewState)
 Enables or disables the specified USART interrupts. More...
 
FlagStatus USART_GetFlagStatus (USART_TypeDef *USARTx, uint16_t USART_FLAG)
 Checks whether the specified USART flag is set or not. More...
 
void USART_ClearFlag (USART_TypeDef *USARTx, uint16_t USART_FLAG)
 Clears the USARTx's pending flags. More...
 
ITStatus USART_GetITStatus (USART_TypeDef *USARTx, uint16_t USART_IT)
 Checks whether the specified USART interrupt has occurred or not. More...
 
void USART_ClearITPendingBit (USART_TypeDef *USARTx, uint16_t USART_IT)
 Clears the USARTx's interrupt pending bits. More...
 

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 SPI communication can be managed by 10 flags:
      (#) USART_FLAG_TXE : to indicate the status of the transmit buffer register
      (#) USART_FLAG_RXNE : to indicate the status of the receive buffer register
      (#) USART_FLAG_TC : to indicate the status of the transmit operation
      (#) USART_FLAG_IDLE : to indicate the status of the Idle Line             
      (#) USART_FLAG_CTS : to indicate the status of the nCTS input
      (#) USART_FLAG_LBD : to indicate the status of the LIN break detection
      (#) USART_FLAG_NE : to indicate if a noise error occur
      (#) USART_FLAG_FE : to indicate if a frame error occur
      (#) USART_FLAG_PE : to indicate if a parity error occur
      (#) 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, uint16_t USART_FLAG);
      (+) void USART_ClearFlag(USART_TypeDef* USARTx, uint16_t USART_FLAG);

    *** Interrupt Mode ***
    ======================
    [..]
    In Interrupt Mode, the USART communication can be managed by 8 interrupt sources
    and 10 pending bits: 

      (#) Pending Bits:

        (##) USART_IT_TXE : to indicate the status of the transmit buffer register
        (##) USART_IT_RXNE : to indicate the status of the receive buffer register
        (##) USART_IT_TC : to indicate the status of the transmit operation
        (##) USART_IT_IDLE : to indicate the status of the Idle Line             
        (##) USART_IT_CTS : to indicate the status of the nCTS input
        (##) USART_IT_LBD : to indicate the status of the LIN break detection
        (##) USART_IT_NE : to indicate if a noise error occur
        (##) USART_IT_FE : to indicate if a frame error occur
        (##) USART_IT_PE : to indicate if a parity error occur
        (##) USART_IT_ORE : to indicate if an Overrun error occur

      (#) Interrupt Source:

        (##) USART_IT_TXE : specifies the interrupt source for the Tx buffer empty 
                            interrupt. 
        (##) USART_IT_RXNE : specifies the interrupt source for the Rx buffer not 
                             empty interrupt.
        (##) USART_IT_TC : specifies the interrupt source for the Transmit complete 
                           interrupt. 
        (##) USART_IT_IDLE : specifies the interrupt source for the Idle Line interrupt.             
        (##) USART_IT_CTS : specifies the interrupt source for the CTS interrupt. 
        (##) USART_IT_LBD : specifies the interrupt source for the LIN break detection
                            interrupt. 
        (##) USART_IT_PE : specifies the interrupt source for the parity error interrupt. 
        (##) USART_IT_ERR :  specifies the interrupt source for the errors interrupt.

      -@@- 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, uint16_t USART_IT, FunctionalState NewState);
      (+) ITStatus USART_GetITStatus(USART_TypeDef* USARTx, uint16_t USART_IT);
      (+) void USART_ClearITPendingBit(USART_TypeDef* USARTx, uint16_t USART_IT);

    *** DMA Mode ***
    ================
    [..]
    In DMA Mode, the USART communication can be managed by 2 DMA Channel requests:
      (#) USART_DMAReq_Tx: specifies the Tx buffer DMA transfer request
      (#) 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,
uint16_t  USART_FLAG 
)

Clears the USARTx's pending flags.

Parameters
USARTxwhere x can be 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or UART peripheral.
USART_FLAGspecifies the flag to clear. This parameter can be any combination of the following values:
  • USART_FLAG_CTS: CTS Change flag (not available for UART4 and UART5).
  • USART_FLAG_LBD: LIN Break detection flag.
  • 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), ORE (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_ReceiveData()).
RXNE flag can be also cleared by a read to the USART_DR register (USART_ReceiveData()).
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_SendData()).
TXE flag is cleared only by a write to the USART_DR register (USART_SendData()).
Return values
None

Definition at line 1344 of file stm32f4xx_usart.c.

void USART_ClearITPendingBit ( USART_TypeDef *  USARTx,
uint16_t  USART_IT 
)

Clears the USARTx's interrupt pending bits.

Parameters
USARTxwhere x can be 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or UART peripheral.
USART_ITspecifies the interrupt pending bit to clear. This parameter can be one of the following values:
  • USART_IT_CTS: CTS change interrupt (not available for UART4 and UART5)
  • USART_IT_LBD: LIN Break detection interrupt
  • USART_IT_TC: Transmission complete interrupt.
  • USART_IT_RXNE: Receive Data register not empty interrupt.
Note
PE (Parity error), FE (Framing error), NE (Noise error), ORE (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_ReceiveData()).
RXNE pending bit can be also cleared by a read to the USART_DR register (USART_ReceiveData()).
TC 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_SendData()).
TXE pending bit is cleared only by a write to the USART_DR register (USART_SendData()).
Return values
None

Definition at line 1452 of file stm32f4xx_usart.c.

FlagStatus USART_GetFlagStatus ( USART_TypeDef *  USARTx,
uint16_t  USART_FLAG 
)

Checks whether the specified USART flag is set or not.

Parameters
USARTxwhere x can be 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or UART peripheral.
USART_FLAGspecifies the flag to check. This parameter can be one of the following values:
  • USART_FLAG_CTS: CTS Change flag (not available for UART4 and UART5)
  • USART_FLAG_LBD: LIN Break detection flag
  • USART_FLAG_TXE: Transmit data register empty flag
  • USART_FLAG_TC: Transmission Complete flag
  • USART_FLAG_RXNE: Receive data register not empty flag
  • USART_FLAG_IDLE: Idle Line detection flag
  • USART_FLAG_ORE: OverRun Error flag
  • USART_FLAG_NE: Noise Error flag
  • USART_FLAG_FE: Framing Error flag
  • USART_FLAG_PE: Parity Error flag
Return values
Thenew state of USART_FLAG (SET or RESET).

Definition at line 1295 of file stm32f4xx_usart.c.

+ Here is the caller graph for this function:

ITStatus USART_GetITStatus ( USART_TypeDef *  USARTx,
uint16_t  USART_IT 
)

Checks whether the specified USART interrupt has occurred or not.

Parameters
USARTxwhere x can be 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or UART peripheral.
USART_ITspecifies the USART interrupt source to check. This parameter can be one of the following values:
  • USART_IT_CTS: CTS change interrupt (not available for UART4 and UART5)
  • USART_IT_LBD: LIN Break detection interrupt
  • 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_ORE_RX : OverRun Error interrupt if the RXNEIE bit is set
  • USART_IT_ORE_ER : OverRun Error interrupt if the EIE bit is set
  • USART_IT_NE: Noise Error interrupt
  • USART_IT_FE: Framing Error interrupt
  • USART_IT_PE: Parity Error interrupt
Return values
Thenew state of USART_IT (SET or RESET).

Definition at line 1378 of file stm32f4xx_usart.c.

void USART_ITConfig ( USART_TypeDef *  USARTx,
uint16_t  USART_IT,
FunctionalState  NewState 
)

Enables or disables the specified USART interrupts.

Parameters
USARTxwhere x can be 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or UART peripheral.
USART_ITspecifies the USART interrupt sources to be enabled or disabled. This parameter can be one of the following values:
  • USART_IT_CTS: CTS change interrupt
  • USART_IT_LBD: LIN Break detection interrupt
  • 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_PE: Parity Error interrupt
  • USART_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
NewStatenew state of the specified USARTx interrupts. This parameter can be: ENABLE or DISABLE.
Return values
None

Definition at line 1231 of file stm32f4xx_usart.c.