STM32F37 Standard Peripheral bibliotheek  1.0
ST Microelectronics bibliotheek documentatie voor de STM32F37 Standard Peripheral Library
 All Data Structures Files Functions Variables Enumerations Enumerator Groups
Interrupts and flags management functions

Interrupts and flags management functions. More...

Functions

void CAN_ITConfig (CAN_TypeDef *CANx, uint32_t CAN_IT, FunctionalState NewState)
 Enables or disables the specified CANx interrupts. More...
 
FlagStatus CAN_GetFlagStatus (CAN_TypeDef *CANx, uint32_t CAN_FLAG)
 Checks whether the specified CAN flag is set or not. More...
 
void CAN_ClearFlag (CAN_TypeDef *CANx, uint32_t CAN_FLAG)
 Clears the CAN's pending flags. More...
 
ITStatus CAN_GetITStatus (CAN_TypeDef *CANx, uint32_t CAN_IT)
 Checks whether the specified CANx interrupt has occurred or not. More...
 
void CAN_ClearITPendingBit (CAN_TypeDef *CANx, uint32_t CAN_IT)
 Clears the CANx's interrupt pending bits. More...
 

Detailed Description

Interrupts and flags management functions.

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

    [..] This section provides functions allowing to configure the CAN Interrupts and 
         to get the status and clear flags and Interrupts pending bits.
         
         The CAN provides 14 Interrupts sources and 15 Flags:

  *** Flags ***
  =============
    [..]The 15 flags can be divided on 4 groups: 

        (+)Transmit Flags
           (##) CAN_FLAG_RQCP0, 
           (##) CAN_FLAG_RQCP1, 
           (##) CAN_FLAG_RQCP2  : Request completed MailBoxes 0, 1 and 2  Flags
                Set when when the last request (transmit or abort) has 
                been performed. 

        (+)Receive Flags
           (##) CAN_FLAG_FMP0,
           (##) CAN_FLAG_FMP1   : FIFO 0 and 1 Message Pending Flags 
                set to signal that messages are pending in the receive 
                FIFO.
                These Flags are cleared only by hardware. 
           (##) CAN_FLAG_FF0,
           (##) CAN_FLAG_FF1    : FIFO 0 and 1 Full Flags
                set when three messages are stored in the selected 
                FIFO.
           (##) CAN_FLAG_FOV0
           (##) CAN_FLAG_FOV1   : FIFO 0 and 1 Overrun Flags
                set when a new message has been received and passed 
                the filter while the FIFO was full.         

        (+)Operating Mode Flags
           (##) CAN_FLAG_WKU    : Wake up Flag
                set to signal that a SOF bit has been detected while 
                the CAN hardware was in Sleep mode. 
                
           (##) CAN_FLAG_SLAK   : Sleep acknowledge Flag
                Set to signal that the CAN has entered Sleep Mode. 
    
        (+)Error Flags
           (##) CAN_FLAG_EWG    : Error Warning Flag
                Set when the warning limit has been reached (Receive 
                Error Counter or Transmit Error Counter greater than 96). 
                This Flag is cleared only by hardware.
           (##) CAN_FLAG_EPV    : Error Passive Flag
                Set when the Error Passive limit has been reached 
                (Receive Error Counter or Transmit Error Counter 
                greater than 127).
                This Flag is cleared only by hardware.
           (##) CAN_FLAG_BOF    : Bus-Off Flag
                set when CAN enters the bus-off state. The bus-off 
                state is entered on TEC overflow, greater than 255.
                This Flag is cleared only by hardware.
           (##) CAN_FLAG_LEC    : Last error code Flag
                set If a message has been transferred (reception or
                transmission) with error, and the error code is hold.              
                
  *** Interrupts ***
  ==================
    [..]The 14 interrupts can be divided on 4 groups: 
  
        (+)Transmit interrupt
           (##) CAN_IT_TME   :  Transmit mailbox empty Interrupt
                if enabled, this interrupt source is pending when 
                no transmit request are pending for Tx mailboxes.      

        (+)Receive Interrupts
           (##) CAN_IT_FMP0,
           (##) CAN_IT_FMP1  :  FIFO 0 and FIFO1 message pending Interrupts
                if enabled, these interrupt sources are pending when 
                messages are pending in the receive FIFO.
                The corresponding interrupt pending bits are cleared 
                only by hardware.
           (##) CAN_IT_FF0,              
           (##) CAN_IT_FF1   :  FIFO 0 and FIFO1 full Interrupts
                if enabled, these interrupt sources are pending when
                three messages are stored in the selected FIFO.
           (##) CAN_IT_FOV0,        
           (##) CAN_IT_FOV1    :  FIFO 0 and FIFO1 overrun Interrupts        
                if enabled, these interrupt sources are pending when
                a new message has been received and passed the filter
                while the FIFO was full.

        (+)Operating Mode Interrupts
           (##) CAN_IT_WKU     :  Wake-up Interrupt
                if enabled, this interrupt source is pending when 
                a SOF bit has been detected while the CAN hardware was 
                in Sleep mode.
                                  
           (##) CAN_IT_SLK     :  Sleep acknowledge Interrupt
                if enabled, this interrupt source is pending when 
                the CAN has entered Sleep Mode.       

        (+)Error Interrupts 
           (##) CAN_IT_EWG     :  Error warning Interrupt 
                if enabled, this interrupt source is pending when
                the warning limit has been reached (Receive Error 
                Counter or Transmit Error Counter=96). 
                
           (##) CAN_IT_EPV     :  Error passive Interrupt        
                if enabled, this interrupt source is pending when
                the Error Passive limit has been reached (Receive 
                Error Counter or Transmit Error Counter>127).
                
           (##) CAN_IT_BOF     :  Bus-off Interrupt
                if enabled, this interrupt source is pending when
                CAN enters the bus-off state. The bus-off state is 
                entered on TEC overflow, greater than 255.
                This Flag is cleared only by hardware.
                
           (##) CAN_IT_LEC     :  Last error code Interrupt        
                if enabled, this interrupt source is pending  when
                a message has been transferred (reception or
                transmission) with error, and the error code is hold.
                
           (##) CAN_IT_ERR     :  Error Interrupt
                if enabled, this interrupt source is pending when 
                an error condition is pending.      

  *** Managing the CAN controller events ***
  ==========================================
    [..]The user should identify which mode will be used in his application to manage 
        the CAN controller events: Polling mode or Interrupt mode.
        (+)In the Polling Mode it is advised to use the following functions:
           (##) CAN_GetFlagStatus() : to check if flags events occur. 
           (##) CAN_ClearFlag()     : to clear the flags events.

        (+)In the Interrupt Mode it is advised to use the following functions:
           (##) CAN_ITConfig()       : to enable or disable the interrupt source.
           (##) CAN_GetITStatus()    : to check if Interrupt occurs.
           (##) CAN_ClearITPendingBit() : to clear the Interrupt pending Bit (corresponding Flag).
             -@@-This function has no impact on CAN_IT_FMP0 and CAN_IT_FMP1 Interrupts 
                 pending bits since there are cleared only by hardware. 

Function Documentation

void CAN_ClearFlag ( CAN_TypeDef *  CANx,
uint32_t  CAN_FLAG 
)

Clears the CAN's pending flags.

Parameters
CANx,:where x can be 1 or 2 to to select the CAN peripheral.
CAN_FLAG,:specifies the flag to clear. This parameter can be one of the following values:
  • CAN_FLAG_RQCP0: Request MailBox0 Flag
  • CAN_FLAG_RQCP1: Request MailBox1 Flag
  • CAN_FLAG_RQCP2: Request MailBox2 Flag
  • CAN_FLAG_FF0: FIFO 0 Full Flag
  • CAN_FLAG_FOV0: FIFO 0 Overrun Flag
  • CAN_FLAG_FF1: FIFO 1 Full Flag
  • CAN_FLAG_FOV1: FIFO 1 Overrun Flag
  • CAN_FLAG_WKU: Wake up Flag
  • CAN_FLAG_SLAK: Sleep acknowledge Flag
  • CAN_FLAG_LEC: Last error code Flag
Return values
None
void CAN_ClearITPendingBit ( CAN_TypeDef *  CANx,
uint32_t  CAN_IT 
)

Clears the CANx's interrupt pending bits.

Parameters
CANx,:where x can be 1 or 2 to to select the CAN peripheral.
CAN_IT,:specifies the interrupt pending bit to clear. This parameter can be one of the following values:
  • CAN_IT_TME: Transmit mailbox empty Interrupt
  • CAN_IT_FF0: FIFO 0 full Interrupt
  • CAN_IT_FOV0: FIFO 0 overrun Interrupt
  • CAN_IT_FF1: FIFO 1 full Interrupt
  • CAN_IT_FOV1: FIFO 1 overrun Interrupt
  • CAN_IT_WKU: Wake-up Interrupt
  • CAN_IT_SLK: Sleep acknowledge Interrupt
  • CAN_IT_EWG: Error warning Interrupt
  • CAN_IT_EPV: Error passive Interrupt
  • CAN_IT_BOF: Bus-off Interrupt
  • CAN_IT_LEC: Last error code Interrupt
  • CAN_IT_ERR: Error Interrupt
Return values
None
FlagStatus CAN_GetFlagStatus ( CAN_TypeDef *  CANx,
uint32_t  CAN_FLAG 
)

Checks whether the specified CAN flag is set or not.

Parameters
CANx,:where x can be 1 or 2 to to select the CAN peripheral.
CAN_FLAG,:specifies the flag to check. This parameter can be one of the following values:
  • CAN_FLAG_RQCP0: Request MailBox0 Flag
  • CAN_FLAG_RQCP1: Request MailBox1 Flag
  • CAN_FLAG_RQCP2: Request MailBox2 Flag
  • CAN_FLAG_FMP0: FIFO 0 Message Pending Flag
  • CAN_FLAG_FF0: FIFO 0 Full Flag
  • CAN_FLAG_FOV0: FIFO 0 Overrun Flag
  • CAN_FLAG_FMP1: FIFO 1 Message Pending Flag
  • CAN_FLAG_FF1: FIFO 1 Full Flag
  • CAN_FLAG_FOV1: FIFO 1 Overrun Flag
  • CAN_FLAG_WKU: Wake up Flag
  • CAN_FLAG_SLAK: Sleep acknowledge Flag
  • CAN_FLAG_EWG: Error Warning Flag
  • CAN_FLAG_EPV: Error Passive Flag
  • CAN_FLAG_BOF: Bus-Off Flag
  • CAN_FLAG_LEC: Last error code Flag
Return values
Thenew state of CAN_FLAG (SET or RESET).
ITStatus CAN_GetITStatus ( CAN_TypeDef *  CANx,
uint32_t  CAN_IT 
)

Checks whether the specified CANx interrupt has occurred or not.

Parameters
CANx,:where x can be 1 or 2 to to select the CAN peripheral.
CAN_IT,:specifies the CAN interrupt source to check. This parameter can be one of the following values:
  • CAN_IT_TME: Transmit mailbox empty Interrupt
  • CAN_IT_FMP0: FIFO 0 message pending Interrupt
  • CAN_IT_FF0: FIFO 0 full Interrupt
  • CAN_IT_FOV0: FIFO 0 overrun Interrupt
  • CAN_IT_FMP1: FIFO 1 message pending Interrupt
  • CAN_IT_FF1: FIFO 1 full Interrupt
  • CAN_IT_FOV1: FIFO 1 overrun Interrupt
  • CAN_IT_WKU: Wake-up Interrupt
  • CAN_IT_SLK: Sleep acknowledge Interrupt
  • CAN_IT_EWG: Error warning Interrupt
  • CAN_IT_EPV: Error passive Interrupt
  • CAN_IT_BOF: Bus-off Interrupt
  • CAN_IT_LEC: Last error code Interrupt
  • CAN_IT_ERR: Error Interrupt
Return values
Thecurrent state of CAN_IT (SET or RESET).
void CAN_ITConfig ( CAN_TypeDef *  CANx,
uint32_t  CAN_IT,
FunctionalState  NewState 
)

Enables or disables the specified CANx interrupts.

Parameters
CANx,:where x can be 1 or 2 to to select the CAN peripheral.
CAN_IT,:specifies the CAN interrupt sources to be enabled or disabled. This parameter can be:
  • CAN_IT_TME: Transmit mailbox empty Interrupt
  • CAN_IT_FMP0: FIFO 0 message pending Interrupt
  • CAN_IT_FF0: FIFO 0 full Interrupt
  • CAN_IT_FOV0: FIFO 0 overrun Interrupt
  • CAN_IT_FMP1: FIFO 1 message pending Interrupt
  • CAN_IT_FF1: FIFO 1 full Interrupt
  • CAN_IT_FOV1: FIFO 1 overrun Interrupt
  • CAN_IT_WKU: Wake-up Interrupt
  • CAN_IT_SLK: Sleep acknowledge Interrupt
  • CAN_IT_EWG: Error warning Interrupt
  • CAN_IT_EPV: Error passive Interrupt
  • CAN_IT_BOF: Bus-off Interrupt
  • CAN_IT_LEC: Last error code Interrupt
  • CAN_IT_ERR: Error Interrupt
NewState,:new state of the CAN interrupts. This parameter can be: ENABLE or DISABLE.
Return values
None