MG32L003 Standard Peripherals Firmware Library

模块 | 结构体 | 枚举 | 函数
I2C
MG32L003_StdPeriph_Driver

I2C driver modules 更多...

## 模块
| I2C_Exported_Constants
| I2C_Private_Functions

## 结构体
struct | I2C_InitTypeDef
| I2C Initial Configuration Structure definition 更多...

## 枚举
enum | I2CStatus { I2C_ERROR = 0, I2C_OK = 1, I2C_SUCCESS = 2, I2C_WAITING = 3 }
| I2CStatus enum definition 更多...

## 函数
void | I2C_DeInit (void)
| Deinitializes the I2C peripheral registers to their default reset values. 更多...
void | I2C_Init (I2C_InitTypeDef *I2C_InitStruct)
| Initializes the I2C peripheral according to the specified parameters in the I2C_InitStruct. 更多...
void | I2C_SlaveAddressConfig (uint32_t SlaveAddress)
| Configures the I2C slave address. 更多...
void | I2C_HighSpeedModeCmd (FunctionalState NewState)
| Configures I2C high speed mode. 更多...
void | I2C_SwitchStatus (uint8_t I2C_STA, uint8_t I2C_STO, uint8_t I2C_AA)
| Writes I2C CR register for switching I2C bus status. 更多...
void | I2C_Start (FunctionalState NewState)
| Sets or clears I2C peripheral start status. 更多...
void | I2C_Stop (FunctionalState NewState)
| Sets or clears I2C peripheral stop status. 更多...
void | I2C_ACK (FunctionalState NewState)
| Sets or clears I2C peripheral ACK status. 更多...
void | I2C_Cmd (FunctionalState NewState)
| Enables or disables I2C peripheral. 更多...
void | I2C_AckGeneralCallCmd (FunctionalState NewState)
| Enables or disables the general ack. 更多...
void | I2C_ReceiveByte (uint8_t *pData)
| Reads data from data register. 更多...
void | I2C_WriteByte (uint8_t I2C_DataCmd)
| Write one byte data. 更多...
void | I2C_WriteAddress (uint8_t Address, uint8_t I2C_Direction)
| Write the slave address byte by the direction. 更多...
I2CStatus | I2C_CheckFlag (uint32_t *I2C_Flag)
| Gets the last I2C module status flag. 更多...
ITStatus | I2C_GetITStatus (void)
| Checks whether I2C interrupt has occurred or not. 更多...
void | I2C_ClearITPendingBit (void)
| Clears I2C interrupt pending bit. 更多...

## 详细描述

I2C driver modules

## 枚举类型说明

## ◆ I2CStatus

enum I2CStatus

I2CStatus enum definition

枚举值
I2C_ERROR | No i2c status flag
I2C_OK | No i2c error status flag
I2C_SUCCESS | Waited i2c status flag
I2C_WAITING | Waiting i2c status flag

## 函数说明

## ◆ I2C_ACK()

void I2C_ACK | ( | FunctionalState | NewState | ) |

Sets or clears I2C peripheral ACK status.

参数

  NewState | The new state of the I2C ack status. This parameter can be: ENABLE or DISABLE.

返回值

  None |

## ◆ I2C_AckGeneralCallCmd()

void I2C_AckGeneralCallCmd | ( | FunctionalState | NewState | ) |

Enables or disables the general ack.

参数

  NewState | The new state of the general ack function. This parameter can be: ENABLE or DISABLE.

返回值

  None |

## ◆ I2C_CheckFlag()

I2CStatus I2C_CheckFlag | ( | uint32_t * | I2C_Flag | ) |

Gets the last I2C module status flag.

参数

  None |

返回值

  An | I2C Status enumeration value: I2C_SUCCESS: Get the i2c module status I2C_WAITING: Can't get the i2c module status

## ◆ I2C_ClearITPendingBit()

void I2C_ClearITPendingBit | ( | void |  | ) |

Clears I2C interrupt pending bit.

参数

  None |

返回值

  None |

## ◆ I2C_Cmd()

void I2C_Cmd | ( | FunctionalState | NewState | ) |

Enables or disables I2C peripheral.

参数

  NewState | The new state of the I2C peripheral. This parameter can be: ENABLE or DISABLE.

返回值

  None |

## ◆ I2C_DeInit()

void I2C_DeInit | ( | void |  | ) |

Deinitializes the I2C peripheral registers to their default reset values.

参数

  None |

返回值

  None |

## ◆ I2C_GetITStatus()

ITStatus I2C_GetITStatus | ( | void |  | ) |

Checks whether I2C interrupt has occurred or not.

参数

  None |

返回值

  The | new state of I2C_IT (SET or RESET).

## ◆ I2C_HighSpeedModeCmd()

void I2C_HighSpeedModeCmd | ( | FunctionalState | NewState | ) |

Configures I2C high speed mode.

参数

  NewState | The new state of the I2C high speed mode. This parameter can be: ENABLE or DISABLE.

返回值

  None |

## ◆ I2C_Init()

void I2C_Init | ( | I2C_InitTypeDef * | I2C_InitStruct | ) |

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

参数

  I2C_InitStruct | Pointer to I2C initialization structure.

返回值

  None |

## ◆ I2C_ReceiveByte()

void I2C_ReceiveByte | ( | uint8_t * | pData | ) |

Reads data from data register.

参数

  pData | pointer to reveive date buffer.

返回值

  None |

## ◆ I2C_SlaveAddressConfig()

void I2C_SlaveAddressConfig | ( | uint32_t | SlaveAddress | ) |

Configures the I2C slave address.

参数

  SlaveAddress | specifies the I2C slave address.

返回值

  None |

## ◆ I2C_Start()

void I2C_Start | ( | FunctionalState | NewState | ) |

Sets or clears I2C peripheral start status.

参数

  NewState | The new state of the I2C start status. This parameter can be: ENABLE or DISABLE.

返回值

  None |

## ◆ I2C_Stop()

void I2C_Stop | ( | FunctionalState | NewState | ) |

Sets or clears I2C peripheral stop status.

参数

  NewState | The new state of the I2C stop status. This parameter can be: ENABLE or DISABLE.

返回值

  None |

## ◆ I2C_SwitchStatus()

void I2C_SwitchStatus | ( | uint8_t | I2C_STA,
|  | uint8_t | I2C_STO,
|  | uint8_t | I2C_AA
| ) |  |

Writes I2C CR register for switching I2C bus status.

参数

  I2C_STA | The new state of the I2C start status. This parameter can be: I2C_STA_0 or I2C_STA_1.
  I2C_STO | The new state of the I2C stop status. This parameter can be: I2C_STO_0 or I2C_STO_1.
  I2C_AA | The new state of the I2C ack status. This parameter can be: I2C_AA_0 or I2C_AA_1.

注解
  This function will clear SI bit of CR register, and you should switch I2C status accoring to description of user manual.

返回值

  None |

## ◆ I2C_WriteAddress()

void I2C_WriteAddress | ( | uint8_t | Address,
|  | uint8_t | I2C_Direction
| ) |  |

Write the slave address byte by the direction.

参数

  Address | specifies the slave address to write.
  I2C_Direction | specifies whether the I2C device will be a Transmitter or a Receiver. This parameter can be one of the following values I2C_Direction_Transmitter: Transmitter mode I2C_Direction_Receiver: Receiver mode

返回值

  None |

## ◆ I2C_WriteByte()

void I2C_WriteByte | ( | uint8_t | I2C_DataCmd | ) |

Write one byte data.

参数

  I2C_DataCmd | the data and command to send.

返回值

  None. |