MG32L003 Standard Peripherals Firmware Library
Functions
I2C_Private_Functions

Functions

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

Detailed Description

Function Documentation

◆ I2C_ACK()

void I2C_ACK ( FunctionalState  NewState)

Sets or clears I2C peripheral ACK status.

Parameters
NewStateThe new state of the I2C ack status. This parameter can be: ENABLE or DISABLE.
Return values
None

◆ I2C_AckGeneralCallCmd()

void I2C_AckGeneralCallCmd ( FunctionalState  NewState)

Enables or disables the general ack.

Parameters
NewStateThe new state of the general ack function. This parameter can be: ENABLE or DISABLE.
Return values
None

◆ I2C_CheckFlag()

I2CStatus I2C_CheckFlag ( uint32_t *  I2C_Flag)

Gets the last I2C module status flag.

Parameters
None
Return values
AnI2C 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.

Parameters
None
Return values
None

◆ I2C_Cmd()

void I2C_Cmd ( FunctionalState  NewState)

Enables or disables I2C peripheral.

Parameters
NewStateThe new state of the I2C peripheral. This parameter can be: ENABLE or DISABLE.
Return values
None

◆ I2C_DeInit()

void I2C_DeInit ( void  )

Deinitializes the I2C peripheral registers to their default reset values.

Parameters
None
Return values
None

◆ I2C_GetITStatus()

ITStatus I2C_GetITStatus ( void  )

Checks whether I2C interrupt has occurred or not.

Parameters
None
Return values
Thenew state of I2C_IT (SET or RESET).

◆ I2C_HighSpeedModeCmd()

void I2C_HighSpeedModeCmd ( FunctionalState  NewState)

Configures I2C high speed mode.

Parameters
NewStateThe new state of the I2C high speed mode. This parameter can be: ENABLE or DISABLE.
Return values
None

◆ I2C_Init()

void I2C_Init ( I2C_InitTypeDef I2C_InitStruct)

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

Parameters
I2C_InitStructPointer to I2C initialization structure.
Return values
None

◆ I2C_ReceiveByte()

void I2C_ReceiveByte ( uint8_t *  pData)

Reads data from data register.

Parameters
pDatapointer to reveive date buffer.
Return values
None

◆ I2C_SlaveAddressConfig()

void I2C_SlaveAddressConfig ( uint32_t  SlaveAddress)

Configures the I2C slave address.

Parameters
SlaveAddressspecifies the I2C slave address.
Return values
None

◆ I2C_Start()

void I2C_Start ( FunctionalState  NewState)

Sets or clears I2C peripheral start status.

Parameters
NewStateThe new state of the I2C start status. This parameter can be: ENABLE or DISABLE.
Return values
None

◆ I2C_Stop()

void I2C_Stop ( FunctionalState  NewState)

Sets or clears I2C peripheral stop status.

Parameters
NewStateThe new state of the I2C stop status. This parameter can be: ENABLE or DISABLE.
Return values
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.

Parameters
I2C_STAThe new state of the I2C start status. This parameter can be: I2C_STA_0 or I2C_STA_1.
I2C_STOThe new state of the I2C stop status. This parameter can be: I2C_STO_0 or I2C_STO_1.
I2C_AAThe new state of the I2C ack status. This parameter can be: I2C_AA_0 or I2C_AA_1.
Note
This function will clear SI bit of CR register, and you should switch I2C status accoring to description of user manual.
Return values
None

◆ I2C_WriteAddress()

void I2C_WriteAddress ( uint8_t  Address,
uint8_t  I2C_Direction 
)

Write the slave address byte by the direction.

Parameters
Addressspecifies the slave address to write.
I2C_Directionspecifies 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
Return values
None

◆ I2C_WriteByte()

void I2C_WriteByte ( uint8_t  I2C_DataCmd)

Write one byte data.

Parameters
I2C_DataCmdthe data and command to send.
Return values
None.