Interrupts and flags management functions.
More...
Interrupts and flags management functions.
===============================================================================
##### Interrupts and flags management functions #####
===============================================================================
[..] This section provides functions allowing to configure the I2C 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(refer I2C_Group6) .
*** Polling Mode ***
====================
[..] In Polling Mode, the I2C communication can be managed by 15 flags:
(#) I2C_FLAG_TXE: to indicate the status of Transmit data register empty flag.
(#) I2C_FLAG_TXIS: to indicate the status of Transmit interrupt status flag .
(#) I2C_FLAG_RXNE: to indicate the status of Receive data register not empty flag.
(#) I2C_FLAG_ADDR: to indicate the status of Address matched flag (slave mode).
(#) I2C_FLAG_NACKF: to indicate the status of NACK received flag.
(#) I2C_FLAG_STOPF: to indicate the status of STOP detection flag.
(#) I2C_FLAG_TC: to indicate the status of Transfer complete flag(master mode).
(#) I2C_FLAG_TCR: to indicate the status of Transfer complete reload flag.
(#) I2C_FLAG_BERR: to indicate the status of Bus error flag.
(#) I2C_FLAG_ARLO: to indicate the status of Arbitration lost flag.
(#) I2C_FLAG_OVR: to indicate the status of Overrun/Underrun flag.
(#) I2C_FLAG_PECERR: to indicate the status of PEC error in reception flag.
(#) I2C_FLAG_TIMEOUT: to indicate the status of Timeout or Tlow detection flag.
(#) I2C_FLAG_ALERT: to indicate the status of SMBus Alert flag.
(#) I2C_FLAG_BUSY: to indicate the status of Bus busy flag.
[..] In this Mode it is advised to use the following functions:
(+) FlagStatus I2C_GetFlagStatus(I2C_TypeDef* I2Cx, uint32_t I2C_FLAG);
(+) void I2C_ClearFlag(I2C_TypeDef* I2Cx, uint32_t I2C_FLAG);
[..]
(@)Do not use the BUSY flag to handle each data transmission or reception.It is
better to use the TXIS and RXNE flags instead.
*** Interrupt Mode ***
======================
[..] In Interrupt Mode, the I2C communication can be managed by 7 interrupt sources
and 15 pending bits:
[..] Interrupt Source:
(#) I2C_IT_ERRI: specifies the interrupt source for the Error interrupt.
(#) I2C_IT_TCI: specifies the interrupt source for the Transfer Complete interrupt.
(#) I2C_IT_STOPI: specifies the interrupt source for the Stop Detection interrupt.
(#) I2C_IT_NACKI: specifies the interrupt source for the Not Acknowledge received interrupt.
(#) I2C_IT_ADDRI: specifies the interrupt source for the Address Match interrupt.
(#) I2C_IT_RXI: specifies the interrupt source for the RX interrupt.
(#) I2C_IT_TXI: specifies the interrupt source for the TX interrupt.
[..] Pending Bits:
(#) I2C_IT_TXIS: to indicate the status of Transmit interrupt status flag.
(#) I2C_IT_RXNE: to indicate the status of Receive data register not empty flag.
(#) I2C_IT_ADDR: to indicate the status of Address matched flag (slave mode).
(#) I2C_IT_NACKF: to indicate the status of NACK received flag.
(#) I2C_IT_STOPF: to indicate the status of STOP detection flag.
(#) I2C_IT_TC: to indicate the status of Transfer complete flag (master mode).
(#) I2C_IT_TCR: to indicate the status of Transfer complete reload flag.
(#) I2C_IT_BERR: to indicate the status of Bus error flag.
(#) I2C_IT_ARLO: to indicate the status of Arbitration lost flag.
(#) I2C_IT_OVR: to indicate the status of Overrun/Underrun flag.
(#) I2C_IT_PECERR: to indicate the status of PEC error in reception flag.
(#) I2C_IT_TIMEOUT: to indicate the status of Timeout or Tlow detection flag.
(#) I2C_IT_ALERT: to indicate the status of SMBus Alert flag.
[..] In this Mode it is advised to use the following functions:
(+) void I2C_ClearITPendingBit(I2C_TypeDef* I2Cx, uint32_t I2C_IT);
(+) ITStatus I2C_GetITStatus(I2C_TypeDef* I2Cx, uint32_t I2C_IT);
void I2C_ClearFlag |
( |
I2C_TypeDef * |
I2Cx, |
|
|
uint32_t |
I2C_FLAG |
|
) |
| |
Clears the I2Cx's pending flags.
- Parameters
-
I2Cx | where x can be 1 or 2 to select the I2C peripheral. |
I2C_FLAG | specifies the flag to clear. This parameter can be any combination of the following values:
- I2C_FLAG_ADDR: Address matched (slave mode)
- I2C_FLAG_NACKF: NACK received flag
- I2C_FLAG_STOPF: STOP detection flag
- I2C_FLAG_BERR: Bus error
- I2C_FLAG_ARLO: Arbitration lost
- I2C_FLAG_OVR: Overrun/Underrun
- I2C_FLAG_PECERR: PEC error in reception
- I2C_FLAG_TIMEOUT: Timeout or Tlow detection flag
- I2C_FLAG_ALERT: SMBus Alert
|
- Return values
-
The | new state of I2C_FLAG (SET or RESET). |
Definition at line 1465 of file stm32f30x_i2c.c.
void I2C_ClearITPendingBit |
( |
I2C_TypeDef * |
I2Cx, |
|
|
uint32_t |
I2C_IT |
|
) |
| |
Clears the I2Cx's interrupt pending bits.
- Parameters
-
I2Cx | where x can be 1 or 2 to select the I2C peripheral. |
I2C_IT | specifies the interrupt pending bit to clear. This parameter can be any combination of the following values:
- I2C_IT_ADDR: Address matched (slave mode)
- I2C_IT_NACKF: NACK received flag
- I2C_IT_STOPF: STOP detection flag
- I2C_IT_BERR: Bus error
- I2C_IT_ARLO: Arbitration lost
- I2C_IT_OVR: Overrun/Underrun
- I2C_IT_PECERR: PEC error in reception
- I2C_IT_TIMEOUT: Timeout or Tlow detection flag
- I2C_IT_ALERT: SMBus Alert
|
- Return values
-
The | new state of I2C_IT (SET or RESET). |
Definition at line 1559 of file stm32f30x_i2c.c.
Checks whether the specified I2C flag is set or not.
- Parameters
-
I2Cx | where x can be 1 or 2 to select the I2C peripheral. |
I2C_FLAG | specifies the flag to check. This parameter can be one of the following values:
- I2C_FLAG_TXE: Transmit data register empty
- I2C_FLAG_TXIS: Transmit interrupt status
- I2C_FLAG_RXNE: Receive data register not empty
- I2C_FLAG_ADDR: Address matched (slave mode)
- I2C_FLAG_NACKF: NACK received flag
- I2C_FLAG_STOPF: STOP detection flag
- I2C_FLAG_TC: Transfer complete (master mode)
- I2C_FLAG_TCR: Transfer complete reload
- I2C_FLAG_BERR: Bus error
- I2C_FLAG_ARLO: Arbitration lost
- I2C_FLAG_OVR: Overrun/Underrun
- I2C_FLAG_PECERR: PEC error in reception
- I2C_FLAG_TIMEOUT: Timeout or Tlow detection flag
- I2C_FLAG_ALERT: SMBus Alert
- I2C_FLAG_BUSY: Bus busy
|
- Return values
-
The | new state of I2C_FLAG (SET or RESET). |
Definition at line 1421 of file stm32f30x_i2c.c.
Checks whether the specified I2C interrupt has occurred or not.
- Parameters
-
I2Cx | where x can be 1 or 2 to select the I2C peripheral. |
I2C_IT | specifies the interrupt source to check. This parameter can be one of the following values:
- I2C_IT_TXIS: Transmit interrupt status
- I2C_IT_RXNE: Receive data register not empty
- I2C_IT_ADDR: Address matched (slave mode)
- I2C_IT_NACKF: NACK received flag
- I2C_IT_STOPF: STOP detection flag
- I2C_IT_TC: Transfer complete (master mode)
- I2C_IT_TCR: Transfer complete reload
- I2C_IT_BERR: Bus error
- I2C_IT_ARLO: Arbitration lost
- I2C_IT_OVR: Overrun/Underrun
- I2C_IT_PECERR: PEC error in reception
- I2C_IT_TIMEOUT: Timeout or Tlow detection flag
- I2C_IT_ALERT: SMBus Alert
|
- Return values
-
The | new state of I2C_IT (SET or RESET). |
Definition at line 1495 of file stm32f30x_i2c.c.