MG32F10x Standard Peripherals Firmware Library

函数
I2C_Private_Functions
MG32F10x_StdPeriph_Driver » I2C

## 函数
void | I2C_DeInit (I2C_TypeDef *I2Cx)
| Deinitializes the I2Cx peripheral registers to their default reset values. 更多...
void | I2C_Init (I2C_TypeDef *I2Cx, uint32_t I2C_CON)
| Initializes the I2Cx peripheral according to the specified parameters in the I2C_InitStruct. 更多...
void | I2C_TargetAddressConfig (I2C_TypeDef *I2Cx, uint32_t TargetAddress)
| Configures the specified I2C target address. 更多...
void | I2C_OwnAddressConfig (I2C_TypeDef *I2Cx, uint16_t Address)
| Configures the specified I2C own address. 更多...
void | I2C_HighSpeedModeMasterCodeConfig (I2C_TypeDef *I2Cx, uint8_t Code)
| Configures the I2C HS mode master code. 更多...
uint32_t | I2C_GetTxAbortSource (I2C_TypeDef *I2Cx)
| Returns the transmit abort source for the specified I2C. 更多...
void | I2C_SCLStuckAtLowTimeoutConfig (I2C_TypeDef *I2Cx, uint32_t Timeout)
| Configures the specified I2C SCL stuck at low timeout. 更多...
void | I2C_SDAStuckAtLowTimeoutConfig (I2C_TypeDef *I2Cx, uint32_t Timeout)
| Configures the specified I2C SDA stuck at low timeout. 更多...
void | I2C_Cmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
| Enables or disables the specified I2C peripheral. 更多...
void | I2C_SlaveDataNAckOnlyConfig (I2C_TypeDef *I2Cx, FunctionalState NewState)
| Enables or disables generate NACK after data byte received when as slave-receiver. 更多...
void | I2C_AckGeneralCallCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
| Enables or disables the General Call ACK Generate. 更多...
uint16_t | I2C_ReadData (I2C_TypeDef *I2Cx)
| Read data from Rx FIFO. 更多...
void | I2C_WriteDataCmd (I2C_TypeDef *I2Cx, uint16_t I2C_DataCmd)
| Write data and command Tx FIFO. 更多...
FlagStatus | I2C_GetFlagStatus (I2C_TypeDef *I2Cx, uint32_t I2C_FLAG)
| Checks whether the specified I2C flag is set or not. 更多...
void | I2C_ITConfig (I2C_TypeDef *I2Cx, uint16_t I2C_IT, FunctionalState NewState)
| Enables or disables the specified I2C interrupts. 更多...
ITStatus | I2C_GetRawITStatus (I2C_TypeDef *I2Cx, uint16_t I2C_IT)
| Checks whether the specified I2Cx raw interrupt status. 更多...
ITStatus | I2C_GetITStatus (I2C_TypeDef *I2Cx, uint16_t I2C_IT)
| Checks whether the specified I2Cx interrupt has occurred or not. 更多...
void | I2C_ClearITPendingBit (I2C_TypeDef *I2Cx, uint16_t I2C_IT)
| Clears the I2Cx's interrupt pending bits. 更多...
void | I2C_RxFIFOThresholdConfig (I2C_TypeDef *I2Cx, uint8_t Threshold)
| Configures the Receive FIFO threshold. 更多...
void | I2C_TxFIFOThresholdConfig (I2C_TypeDef *I2Cx, uint8_t Threshold)
| Configures the Transmit FIFO threshold. 更多...
uint8_t | I2C_GetRxFIFOLevel (I2C_TypeDef *I2Cx)
| Returns the number of valid data entries in the receive FIFO buffer. 更多...
uint8_t | I2C_GetTxFIFOLevel (I2C_TypeDef *I2Cx)
| Returns the number of valid data entries in the transmit FIFO buffer. 更多...
void | I2C_DMARxReqLevelConfig (I2C_TypeDef *I2Cx, uint8_t Level)
| Configures the DMA Rx request level. 更多...
void | I2C_DMATxReqLevelConfig (I2C_TypeDef *I2Cx, uint8_t Level)
| Configures the DMA Tx request level. 更多...
void | I2C_DMACmd (I2C_TypeDef *I2Cx, uint32_t I2C_DMAReq, FunctionalState NewState)
| Enables or disables the I2Cx's DMA interface. 更多...
void | I2C_SMBus_ITConfig (I2C_TypeDef *I2Cx, uint16_t I2C_SMBUS_IT, FunctionalState NewState)
| Enables or disables the specified SMBus interrupts. 更多...
ITStatus | I2C_SMBus_GetRawITStatus (I2C_TypeDef *I2Cx, uint16_t I2C_SMBUS_IT)
| Checks whether the specified SMBus raw interrupt status. 更多...
ITStatus | I2C_SMBus_GetITStatus (I2C_TypeDef *I2Cx, uint16_t I2C_SMBUS_IT)
| Checks whether the specified SMBus interrupt has occurred or not. 更多...
void | I2C_SMBus_ClearITPendingBit (I2C_TypeDef *I2Cx, uint16_t I2C_SMBUS_IT)
| Clears the I2Cx's interrupt pending bits. 更多...

## 详细描述

## 函数说明

## ◆ I2C_AckGeneralCallCmd()

void I2C_AckGeneralCallCmd | ( | I2C_TypeDef * | I2Cx,
|  | FunctionalState | NewState
| ) |  |

Enables or disables the General Call ACK Generate.

参数

  I2Cx | Pointer to selected I2C peripheral. This parameter can be one of the following values: I2C1, I2C2.
  NewState | new state of the General Call ACK Generate. This parameter can be: ENABLE or DISABLE.

返回
  None

## ◆ I2C_ClearITPendingBit()

void I2C_ClearITPendingBit | ( | I2C_TypeDef * | I2Cx,
|  | uint16_t | I2C_IT
| ) |  |

Clears the I2Cx's interrupt pending bits.

参数

  I2Cx | Pointer to selected I2C peripheral. This parameter can be one of the following values: I2C1, I2C2.
  I2C_IT | specifies the interrupt pending bit to clear. This parameter can be a combination of the following values: I2C_IT_RX_UNDER I2C_IT_RX_OVER I2C_IT_TX_OVER I2C_IT_RD_REQ I2C_IT_TX_ABRT I2C_IT_RX_DONE I2C_IT_ACTIVITY I2C_IT_STOP_DET I2C_IT_START_DET I2C_IT_GEN_CALL I2C_IT_RESTART_DET I2C_IT_SCL_STUCK_AT_LOW

返回
  None.

## ◆ I2C_Cmd()

void I2C_Cmd | ( | I2C_TypeDef * | I2Cx,
|  | FunctionalState | NewState
| ) |  |

Enables or disables the specified I2C peripheral.

参数

  I2Cx | Pointer to selected I2C peripheral. This parameter can be one of the following values: I2C1, I2C2.
  NewState | new state of the I2Cx peripheral. This parameter can be: ENABLE or DISABLE.

返回
  None

## ◆ I2C_DeInit()

void I2C_DeInit | ( | I2C_TypeDef * | I2Cx | ) |

Deinitializes the I2Cx peripheral registers to their default reset values.

参数

  I2Cx | Pointer to selected I2C peripheral. This parameter can be one of the following values: I2C1, I2C2.

返回
  None

## ◆ I2C_DMACmd()

void I2C_DMACmd | ( | I2C_TypeDef * | I2Cx,
|  | uint32_t | I2C_DMAReq,
|  | FunctionalState | NewState
| ) |  |

Enables or disables the I2Cx's DMA interface.

参数

  I2Cx | Pointer to selected I2C peripheral. This parameter can be one of the following values: I2C1, I2C2.
  I2C_DMAReq | specifies the DMA request. This parameter can be any combination of the following values: I2C_DMAReq_Rx: I2C DMA receive request I2C_DMAReq_Tx: I2C DMA transmit request
  NewState | new state of the DMA Request sources. This parameter can be: ENABLE or DISABLE.

返回
  None.

## ◆ I2C_DMARxReqLevelConfig()

void I2C_DMARxReqLevelConfig | ( | I2C_TypeDef * | I2Cx,
|  | uint8_t | Level
| ) |  |

Configures the DMA Rx request level.

参数

  I2Cx | Pointer to selected I2C peripheral. This parameter can be one of the following values: I2C1, I2C2.
  Level | The level of the DMA Rx request to set.

返回
  None.

## ◆ I2C_DMATxReqLevelConfig()

void I2C_DMATxReqLevelConfig | ( | I2C_TypeDef * | I2Cx,
|  | uint8_t | Level
| ) |  |

Configures the DMA Tx request level.

参数

  I2Cx | Pointer to selected I2C peripheral. This parameter can be one of the following values: I2C1, I2C2.
  Level | The level of the DMA Tx request to set.

返回
  None.

## ◆ I2C_GetFlagStatus()

FlagStatus I2C_GetFlagStatus | ( | I2C_TypeDef * | I2Cx,
|  | uint32_t | I2C_FLAG
| ) |  |

Checks whether the specified I2C flag is set or not.

参数

  I2Cx | Pointer to selected I2C peripheral. This parameter can be one of the following values: I2C1, I2C2.
  I2C_FLAG | specifies the flag to check. This parameter can be one of the following values: I2C_FLAG_ACTIVITY I2C_FLAG_TFNF I2C_FLAG_TFE I2C_FLAG_RFNE I2C_FLAG_RFF I2C_FLAG_MST_ACTIVITY I2C_FLAG_SLV_ACTIVITY I2C_FLAG_MST_HOLD_TX_FIFO_EMPTY I2C_FLAG_MST_HOLD_RX_FIFO_FULL I2C_FLAG_SLV_HOLD_TX_FIFO_EMPTY I2C_FLAG_SLV_HOLD_RX_FIFO_FULL I2C_FLAG_SDA_STUCK_NOT_RECOVERED I2C_FLAG_SMBUS_QUICK_CMD_BIT I2C_FLAG_SMBUS_SLAVE_ADDR_VALID I2C_FLAG_SMBUS_SLAVE_ADDR_RESOLVED I2C_FLAG_SMBUS_SUSPEND_STATUS I2C_FLAG_SMBUS_ALERT_STATUS

返回
  The new state of I2C_FLAG (SET or RESET).

## ◆ I2C_GetITStatus()

ITStatus I2C_GetITStatus | ( | I2C_TypeDef * | I2Cx,
|  | uint16_t | I2C_IT
| ) |  |

Checks whether the specified I2Cx interrupt has occurred or not.

参数

  I2Cx | Pointer to selected I2C peripheral. This parameter can be one of the following values: I2C1, I2C2.
  I2C_IT | specifies the I2C interrupt source to check. This parameter can be one of the following values: I2C_IT_RX_UNDER I2C_IT_RX_OVER I2C_IT_RX_FULL I2C_IT_TX_OVER I2C_IT_TX_EMPTY I2C_IT_RD_REQ I2C_IT_TX_ABRT I2C_IT_RX_DONE I2C_IT_ACTIVITY I2C_IT_STOP_DET I2C_IT_START_DET I2C_IT_GEN_CALL I2C_IT_RESTART_DET I2C_IT_SCL_STUCK_AT_LOW

返回
  The new state of I2C_IT (SET or RESET).

## ◆ I2C_GetRawITStatus()

ITStatus I2C_GetRawITStatus | ( | I2C_TypeDef * | I2Cx,
|  | uint16_t | I2C_IT
| ) |  |

Checks whether the specified I2Cx raw interrupt status.

参数

  I2Cx | Pointer to selected I2C peripheral. This parameter can be one of the following values: I2C1, I2C2.
  I2C_IT | specifies the I2C interrupt source to check. This parameter can be one of the following values: I2C_IT_RX_UNDER I2C_IT_RX_OVER I2C_IT_RX_FULL I2C_IT_TX_OVER I2C_IT_TX_EMPTY I2C_IT_RD_REQ I2C_IT_TX_ABRT I2C_IT_RX_DONE I2C_IT_ACTIVITY I2C_IT_STOP_DET I2C_IT_START_DET I2C_IT_GEN_CALL I2C_IT_RESTART_DET I2C_IT_SCL_STUCK_AT_LOW

返回
  The new state of raw I2C_IT (SET or RESET).

## ◆ I2C_GetRxFIFOLevel()

uint8_t I2C_GetRxFIFOLevel | ( | I2C_TypeDef * | I2Cx | ) |

Returns the number of valid data entries in the receive FIFO buffer.

参数

  I2Cx | Pointer to selected I2C peripheral. This parameter can be one of the following values: I2C1, I2C2.

返回
  The number of valid data entries in the receive FIFO.

## ◆ I2C_GetTxAbortSource()

uint32_t I2C_GetTxAbortSource | ( | I2C_TypeDef * | I2Cx | ) |

Returns the transmit abort source for the specified I2C.

参数

  I2Cx | Pointer to selected I2C peripheral. This parameter can be one of the following values: I2C1, I2C2.

返回
  The transmit abort source.

## ◆ I2C_GetTxFIFOLevel()

uint8_t I2C_GetTxFIFOLevel | ( | I2C_TypeDef * | I2Cx | ) |

Returns the number of valid data entries in the transmit FIFO buffer.

参数

  I2Cx | Pointer to selected I2C peripheral. This parameter can be one of the following values: I2C1, I2C2.

返回
  The number of valid data entries in the transmit FIFO.

## ◆ I2C_HighSpeedModeMasterCodeConfig()

void I2C_HighSpeedModeMasterCodeConfig | ( | I2C_TypeDef * | I2Cx,
|  | uint8_t | Code
| ) |  |

Configures the I2C HS mode master code.

参数

  I2Cx | Pointer to selected I2C peripheral. This parameter can be one of the following values: I2C2.
  Code | specifies the I2C HS mode master code.

返回
  None

## ◆ I2C_Init()

void I2C_Init | ( | I2C_TypeDef * | I2Cx,
|  | uint32_t | I2C_CON
| ) |  |

Initializes the I2Cx peripheral according to the specified parameters in the I2C_InitStruct.

参数

  I2Cx | Pointer to selected I2C peripheral. This parameter can be one of the following values: I2C1, I2C2.
  I2C_CON | specifies the configuration for the specified I2C peripheral.

返回
  None

## ◆ I2C_ITConfig()

void I2C_ITConfig | ( | I2C_TypeDef * | I2Cx,
|  | uint16_t | I2C_IT,
|  | FunctionalState | NewState
| ) |  |

Enables or disables the specified I2C interrupts.

参数

  I2Cx | Pointer to selected I2C peripheral. This parameter can be one of the following values: I2C1, I2C2.
  I2C_IT | specifies the I2C interrupt source to be enabled or disabled. This parameter can be a combination of the following values: I2C_IT_RX_UNDER I2C_IT_RX_OVER I2C_IT_RX_FULL I2C_IT_TX_OVER I2C_IT_TX_EMPTY I2C_IT_RD_REQ I2C_IT_TX_ABRT I2C_IT_RX_DONE I2C_IT_ACTIVITY I2C_IT_STOP_DET I2C_IT_START_DET I2C_IT_GEN_CALL I2C_IT_RESTART_DET I2C_IT_SCL_STUCK_AT_LOW
  NewState | new state of the specified I2C interrupt. This parameter can be: ENABLE or DISABLE.

返回
  None.

## ◆ I2C_OwnAddressConfig()

void I2C_OwnAddressConfig | ( | I2C_TypeDef * | I2Cx,
|  | uint16_t | Address
| ) |  |

Configures the specified I2C own address.

参数

  I2Cx | Pointer to selected I2C peripheral. This parameter can be one of the following values: I2C1, I2C2.
  Address | specifies the I2C own address.

返回
  None

## ◆ I2C_ReadData()

uint16_t I2C_ReadData | ( | I2C_TypeDef * | I2Cx | ) |

Read data from Rx FIFO.

参数

  I2Cx | Pointer to selected I2C peripheral. This parameter can be one of the following values: I2C1, I2C2.

返回
  The received data.

## ◆ I2C_RxFIFOThresholdConfig()

void I2C_RxFIFOThresholdConfig | ( | I2C_TypeDef * | I2Cx,
|  | uint8_t | Threshold
| ) |  |

Configures the Receive FIFO threshold.

参数

  I2Cx | Pointer to selected I2C peripheral. This parameter can be one of the following values: I2C1, I2C2.
  Threshold | The Receive FIFO threshold to set.
  The | RX_FULL interrupt will trigger when the level > Threshold.

返回
  None.

## ◆ I2C_SCLStuckAtLowTimeoutConfig()

void I2C_SCLStuckAtLowTimeoutConfig | ( | I2C_TypeDef * | I2Cx,
|  | uint32_t | Timeout
| ) |  |

Configures the specified I2C SCL stuck at low timeout.

参数

  I2Cx | Pointer to selected I2C peripheral. This parameter can be one of the following values: I2C1, I2C2.
  Timeout | specifies the SCL stuck at low timeout.

返回
  None

## ◆ I2C_SDAStuckAtLowTimeoutConfig()

void I2C_SDAStuckAtLowTimeoutConfig | ( | I2C_TypeDef * | I2Cx,
|  | uint32_t | Timeout
| ) |  |

Configures the specified I2C SDA stuck at low timeout.

参数

  I2Cx | Pointer to selected I2C peripheral. This parameter can be one of the following values: I2C1, I2C2.
  Timeout | specifies the SDA stuck at low timeout.

返回
  None

## ◆ I2C_SlaveDataNAckOnlyConfig()

void I2C_SlaveDataNAckOnlyConfig | ( | I2C_TypeDef * | I2Cx,
|  | FunctionalState | NewState
| ) |  |

Enables or disables generate NACK after data byte received when as slave-receiver.

参数

  I2Cx | Pointer to selected I2C peripheral. This parameter can be one of the following values: I2C1, I2C2.
  NewState | new state of generate NACK after data byte received. This parameter can be: ENABLE or DISABLE.

返回
  None

## ◆ I2C_SMBus_ClearITPendingBit()

void I2C_SMBus_ClearITPendingBit | ( | I2C_TypeDef * | I2Cx,
|  | uint16_t | I2C_SMBUS_IT
| ) |  |

Clears the I2Cx's interrupt pending bits.

参数

  I2Cx | Pointer to selected I2C peripheral. This parameter can be one of the following values: I2C1.
  I2C_SMBUS_IT | specifies the interrupt pending bit to clear. This parameter can be a combination of the following values: I2C_SMBUS_IT_SLV_CLOCK_EXTND_TIMEOUT I2C_SMBUS_IT_MST_CLOCK_EXTND_TIMEOUT I2C_SMBUS_IT_QUICK_CMD_DET I2C_SMBUS_IT_HOST_NTFY_MST_DET I2C_SMBUS_IT_ARP_PREPARE_CMD_DET I2C_SMBUS_IT_ARP_RST_CMD_DET I2C_SMBUS_IT_ARP_GET_UDID_CMD_DET I2C_SMBUS_IT_ARP_ASSGN_ADDR_CMD_DET I2C_SMBUS_IT_SLV_RX_PEC_NACK I2C_SMBUS_IT_SMBUS_SUSPEND_DET I2C_SMBUS_IT_SMBUS_ALERT_DET

返回
  None.

## ◆ I2C_SMBus_GetITStatus()

ITStatus I2C_SMBus_GetITStatus | ( | I2C_TypeDef * | I2Cx,
|  | uint16_t | I2C_SMBUS_IT
| ) |  |

Checks whether the specified SMBus interrupt has occurred or not.

参数

  I2Cx | Pointer to selected I2C peripheral. This parameter can be one of the following values: I2C1.
  I2C_SMBUS_IT | specifies the SMBus interrupt source to check. This parameter can be one of the following values: I2C_SMBUS_IT_SLV_CLOCK_EXTND_TIMEOUT I2C_SMBUS_IT_MST_CLOCK_EXTND_TIMEOUT I2C_SMBUS_IT_QUICK_CMD_DET I2C_SMBUS_IT_HOST_NTFY_MST_DET I2C_SMBUS_IT_ARP_PREPARE_CMD_DET I2C_SMBUS_IT_ARP_RST_CMD_DET I2C_SMBUS_IT_ARP_GET_UDID_CMD_DET I2C_SMBUS_IT_ARP_ASSGN_ADDR_CMD_DET I2C_SMBUS_IT_SLV_RX_PEC_NACK I2C_SMBUS_IT_SMBUS_SUSPEND_DET I2C_SMBUS_IT_SMBUS_ALERT_DET

返回
  The new state of I2C_SMBUS_IT (SET or RESET).

## ◆ I2C_SMBus_GetRawITStatus()

ITStatus I2C_SMBus_GetRawITStatus | ( | I2C_TypeDef * | I2Cx,
|  | uint16_t | I2C_SMBUS_IT
| ) |  |

Checks whether the specified SMBus raw interrupt status.

参数

  I2Cx | Pointer to selected I2C peripheral. This parameter can be one of the following values: I2C1.
  I2C_SMBUS_IT | specifies the SMBus interrupt source to check. This parameter can be one of the following values: I2C_SMBUS_IT_SLV_CLOCK_EXTND_TIMEOUT I2C_SMBUS_IT_MST_CLOCK_EXTND_TIMEOUT I2C_SMBUS_IT_QUICK_CMD_DET I2C_SMBUS_IT_HOST_NTFY_MST_DET I2C_SMBUS_IT_ARP_PREPARE_CMD_DET I2C_SMBUS_IT_ARP_RST_CMD_DET I2C_SMBUS_IT_ARP_GET_UDID_CMD_DET I2C_SMBUS_IT_ARP_ASSGN_ADDR_CMD_DET I2C_SMBUS_IT_SLV_RX_PEC_NACK I2C_SMBUS_IT_SMBUS_SUSPEND_DET I2C_SMBUS_IT_SMBUS_ALERT_DET

返回
  The new state of raw I2C_SMBUS_IT (SET or RESET).

## ◆ I2C_SMBus_ITConfig()

void I2C_SMBus_ITConfig | ( | I2C_TypeDef * | I2Cx,
|  | uint16_t | I2C_SMBUS_IT,
|  | FunctionalState | NewState
| ) |  |

Enables or disables the specified SMBus interrupts.

参数

  I2Cx | Pointer to selected I2C peripheral. This parameter can be one of the following values: I2C1.
  I2C_SMBUS_IT | specifies the SMBus interrupt source to be enabled or disabled. This parameter can be a combination of the following values: I2C_SMBUS_IT_SLV_CLOCK_EXTND_TIMEOUT I2C_SMBUS_IT_MST_CLOCK_EXTND_TIMEOUT I2C_SMBUS_IT_QUICK_CMD_DET I2C_SMBUS_IT_HOST_NTFY_MST_DET I2C_SMBUS_IT_ARP_PREPARE_CMD_DET I2C_SMBUS_IT_ARP_RST_CMD_DET I2C_SMBUS_IT_ARP_GET_UDID_CMD_DET I2C_SMBUS_IT_ARP_ASSGN_ADDR_CMD_DET I2C_SMBUS_IT_SLV_RX_PEC_NACK I2C_SMBUS_IT_SMBUS_SUSPEND_DET I2C_SMBUS_IT_SMBUS_ALERT_DET
  NewState | new state of the specified SMBus interrupt. This parameter can be: ENABLE or DISABLE.

返回
  None.

## ◆ I2C_TargetAddressConfig()

void I2C_TargetAddressConfig | ( | I2C_TypeDef * | I2Cx,
|  | uint32_t | TargetAddress
| ) |  |

Configures the specified I2C target address.

参数

  I2Cx | Pointer to selected I2C peripheral. This parameter can be one of the following values: I2C1, I2C2.
  TargetAddress | specifies the I2C target address.

返回
  None

## ◆ I2C_TxFIFOThresholdConfig()

void I2C_TxFIFOThresholdConfig | ( | I2C_TypeDef * | I2Cx,
|  | uint8_t | Threshold
| ) |  |

Configures the Transmit FIFO threshold.

参数

  I2Cx | Pointer to selected I2C peripheral. This parameter can be one of the following values: I2C1, I2C2.
  Threshold | The Transmit FIFO threshold to set.

注解
  The TX_EMPTY interrupt will trigger when the level <= Threshold.

返回
  None.

## ◆ I2C_WriteDataCmd()

void I2C_WriteDataCmd | ( | I2C_TypeDef * | I2Cx,
|  | uint16_t | I2C_DataCmd
| ) |  |

Write data and command Tx FIFO.

参数

  I2Cx | Pointer to selected I2C peripheral. This parameter can be one of the following values: I2C1, I2C2.
  I2C_DataCmd | the data and command to write.

返回
  None