I2C_Private_Functions
[I2C]

Functions

void I2C_AcknowledgeConfig (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the specified I2C acknowledge feature.
void I2C_ARPCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the specified I2C ARP.
void I2C_CalculatePEC (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the PEC value calculation of the transfered bytes.
ErrorStatus I2C_CheckEvent (I2C_TypeDef *I2Cx, uint32_t I2C_EVENT)
 I2C State Monitoring Functions.
void I2C_ClearFlag (I2C_TypeDef *I2Cx, uint32_t I2C_FLAG)
 Clears the I2Cx's pending flags.
void I2C_ClearITPendingBit (I2C_TypeDef *I2Cx, uint32_t I2C_IT)
 Clears the I2Cx’s interrupt pending bits.
void I2C_Cmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the specified I2C peripheral.
void I2C_DeInit (I2C_TypeDef *I2Cx)
 Deinitializes the I2Cx peripheral registers to their default reset values.
void I2C_DMACmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the specified I2C DMA requests.
void I2C_DMALastTransferCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Specifies if the next DMA transfer will be the last one.
void I2C_DualAddressCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the specified I2C dual addressing mode.
void I2C_FastModeDutyCycleConfig (I2C_TypeDef *I2Cx, uint16_t I2C_DutyCycle)
 Selects the specified I2C fast mode duty cycle.
void I2C_GeneralCallCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the specified I2C general call feature.
void I2C_GenerateSTART (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Generates I2Cx communication START condition.
void I2C_GenerateSTOP (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Generates I2Cx communication STOP condition.
FlagStatus I2C_GetFlagStatus (I2C_TypeDef *I2Cx, uint32_t I2C_FLAG)
 3) Flag-based state monitoring
ITStatus I2C_GetITStatus (I2C_TypeDef *I2Cx, uint32_t I2C_IT)
 Checks whether the specified I2C interrupt has occurred or not.
uint32_t I2C_GetLastEvent (I2C_TypeDef *I2Cx)
 2) Advanced state monitoring
uint8_t I2C_GetPEC (I2C_TypeDef *I2Cx)
 Returns the PEC value for the specified I2C.
void I2C_Init (I2C_TypeDef *I2Cx, I2C_InitTypeDef *I2C_InitStruct)
 Initializes the I2Cx peripheral according to the specified parameters in the I2C_InitStruct.
void I2C_ITConfig (I2C_TypeDef *I2Cx, uint16_t I2C_IT, FunctionalState NewState)
 Enables or disables the specified I2C interrupts.
void I2C_OwnAddress2Config (I2C_TypeDef *I2Cx, uint8_t Address)
 Configures the specified I2C own address2.
void I2C_PECPositionConfig (I2C_TypeDef *I2Cx, uint16_t I2C_PECPosition)
 Selects the specified I2C PEC position.
uint16_t I2C_ReadRegister (I2C_TypeDef *I2Cx, uint8_t I2C_Register)
 Reads the specified I2C register and returns its value.
uint8_t I2C_ReceiveData (I2C_TypeDef *I2Cx)
 Returns the most recent received data by the I2Cx peripheral.
void I2C_Send7bitAddress (I2C_TypeDef *I2Cx, uint8_t Address, uint8_t I2C_Direction)
 Transmits the address byte to select the slave device.
void I2C_SendData (I2C_TypeDef *I2Cx, uint8_t Data)
 Sends a data byte through the I2Cx peripheral.
void I2C_SMBusAlertConfig (I2C_TypeDef *I2Cx, uint16_t I2C_SMBusAlert)
 Drives the SMBusAlert pin high or low for the specified I2C.
void I2C_SoftwareResetCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the specified I2C software reset.
void I2C_StretchClockCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the specified I2C Clock stretching.
void I2C_StructInit (I2C_InitTypeDef *I2C_InitStruct)
 Fills each I2C_InitStruct member with its default value.
void I2C_TransmitPEC (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the specified I2C PEC transfer.

Function Documentation

void I2C_AcknowledgeConfig ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Enables or disables the specified I2C acknowledge feature.

Parameters:
I2Cx,: where x can be 1 or 2 to select the I2C peripheral.
NewState,: new state of the I2C Acknowledgement. This parameter can be: ENABLE or DISABLE.
Return values:
None. 

Definition at line 441 of file stm32f10x_i2c.c.

References assert_param, I2C_TypeDef::CR1, CR1_ACK_Reset, CR1_ACK_Set, DISABLE, IS_FUNCTIONAL_STATE, and IS_I2C_ALL_PERIPH.

Referenced by LM75_GetStatus(), PhysicalAddressDiscovery(), and sEE_ReadBuffer().

void I2C_ARPCmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Enables or disables the specified I2C ARP.

Parameters:
I2Cx,: where x can be 1 or 2 to select the I2C peripheral.
NewState,: new state of the I2Cx ARP. This parameter can be: ENABLE or DISABLE.
Return values:
None 

Definition at line 794 of file stm32f10x_i2c.c.

References assert_param, I2C_TypeDef::CR1, CR1_ENARP_Reset, CR1_ENARP_Set, DISABLE, IS_FUNCTIONAL_STATE, and IS_I2C_ALL_PERIPH.

void I2C_CalculatePEC ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Enables or disables the PEC value calculation of the transfered bytes.

Parameters:
I2Cx,: where x can be 1 or 2 to select the I2C peripheral.
NewState,: new state of the I2Cx PEC value calculation. This parameter can be: ENABLE or DISABLE.
Return values:
None 

Definition at line 757 of file stm32f10x_i2c.c.

References assert_param, I2C_TypeDef::CR1, CR1_ENPEC_Reset, CR1_ENPEC_Set, DISABLE, IS_FUNCTIONAL_STATE, and IS_I2C_ALL_PERIPH.

ErrorStatus I2C_CheckEvent ( I2C_TypeDef I2Cx,
uint32_t  I2C_EVENT 
)

I2C State Monitoring Functions.

This I2C driver provides three different ways for I2C state monitoring depending on the application requirements and constraints:

1) Basic state monitoring: Using I2C_CheckEvent() function: It compares the status registers (SR1 and SR2) content to a given event (can be the combination of one or more flags). It returns SUCCESS if the current status includes the given flags and returns ERROR if one or more flags are missing in the current status.

  • When to use:
    • This function is suitable for most applciations as well as for startup activity since the events are fully described in the product reference manual (RM0008).
    • It is also suitable for users who need to define their own events.
  • Limitations:
    • If an error occurs (ie. error flags are set besides to the monitored flags), the I2C_CheckEvent() function may return SUCCESS despite the communication hold or corrupted real state. In this case, it is advised to use error interrupts to monitor the error events and handle them in the interrupt IRQ handler.
Note:
For error management, it is advised to use the following functions:

2) Advanced state monitoring: Using the function I2C_GetLastEvent() which returns the image of both status registers in a single word (uint32_t) (Status Register 2 value is shifted left by 16 bits and concatenated to Status Register 1).

  • When to use:
    • This function is suitable for the same applications above but it allows to overcome the mentionned limitation of I2C_GetFlagStatus() function. The returned value could be compared to events already defined in the library (stm32f10x_i2c.h) or to custom values defiend by user.
    • This function is suitable when multiple flags are monitored at the same time.
    • At the opposite of I2C_CheckEvent() function, this function allows user to choose when an event is accepted (when all events flags are set and no other flags are set or just when the needed flags are set like I2C_CheckEvent() function).
  • Limitations:
    • User may need to define his own events.
    • Same remark concerning the error management is applicable for this function if user decides to check only regular communication flags (and ignores error flags).

3) Flag-based state monitoring: Using the function I2C_GetFlagStatus() which simply returns the status of one single flag (ie. I2C_FLAG_RXNE ...).

  • When to use:
    • This function could be used for specific applications or in debug phase.
    • It is suitable when only one flag checking is needed (most I2C events are monitored through multiple flags).
  • Limitations:
    • When calling this function, the Status register is accessed. Some flags are cleared when the status register is accessed. So checking the status of one Flag, may clear other ones.
    • Function may need to be called twice or more in order to monitor one single event.

For detailed description of Events, please refer to section I2C_Events in stm32f10x_i2c.h file. 1) Basic state monitoring Checks whether the last I2Cx Event is equal to the one passed as parameter.

Parameters:
I2Cx,: where x can be 1 or 2 to select the I2C peripheral.
I2C_EVENT,: specifies the event to be checked. This parameter can be one of the following values:

  • I2C_EVENT_SLAVE_TRANSMITTER_ADDRESS_MATCHED : EV1
  • I2C_EVENT_SLAVE_RECEIVER_ADDRESS_MATCHED : EV1
  • I2C_EVENT_SLAVE_TRANSMITTER_SECONDADDRESS_MATCHED : EV1
  • I2C_EVENT_SLAVE_RECEIVER_SECONDADDRESS_MATCHED : EV1
  • I2C_EVENT_SLAVE_GENERALCALLADDRESS_MATCHED : EV1
  • I2C_EVENT_SLAVE_BYTE_RECEIVED : EV2
  • (I2C_EVENT_SLAVE_BYTE_RECEIVED | I2C_FLAG_DUALF) : EV2
  • (I2C_EVENT_SLAVE_BYTE_RECEIVED | I2C_FLAG_GENCALL) : EV2
  • I2C_EVENT_SLAVE_BYTE_TRANSMITTED : EV3
  • (I2C_EVENT_SLAVE_BYTE_TRANSMITTED | I2C_FLAG_DUALF) : EV3
  • (I2C_EVENT_SLAVE_BYTE_TRANSMITTED | I2C_FLAG_GENCALL) : EV3
  • I2C_EVENT_SLAVE_ACK_FAILURE : EV3_2
  • I2C_EVENT_SLAVE_STOP_DETECTED : EV4
  • I2C_EVENT_MASTER_MODE_SELECT : EV5
  • I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED : EV6
  • I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED : EV6
  • I2C_EVENT_MASTER_BYTE_RECEIVED : EV7
  • I2C_EVENT_MASTER_BYTE_TRANSMITTING : EV8
  • I2C_EVENT_MASTER_BYTE_TRANSMITTED : EV8_2
  • I2C_EVENT_MASTER_MODE_ADDRESS10 : EV9
Note:
: For detailed description of Events, please refer to section I2C_Events in stm32f10x_i2c.h file.
Return values:
An ErrorStatus enumuration value:

  • SUCCESS: Last event is equal to the I2C_EVENT
  • ERROR: Last event is different from the I2C_EVENT

Definition at line 984 of file stm32f10x_i2c.c.

References assert_param, ERROR, FLAG_Mask, IS_I2C_ALL_PERIPH, IS_I2C_EVENT, I2C_TypeDef::SR1, I2C_TypeDef::SR2, status, and SUCCESS.

Referenced by I2C_ReadDataBuffer(), I2C_ReadDeviceRegister(), I2C_WriteDeviceRegister(), LM75_GetStatus(), LM75_ReadConfReg(), LM75_ReadReg(), LM75_ReadTemp(), LM75_ShutDown(), LM75_WriteConfReg(), LM75_WriteReg(), main(), PhysicalAddressDiscovery(), sEE_ReadBuffer(), sEE_WaitEepromStandbyState(), and sEE_WritePage().

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_SMBALERT: SMBus Alert flag
  • I2C_FLAG_TIMEOUT: Timeout or Tlow error flag
  • I2C_FLAG_PECERR: PEC error in reception flag
  • I2C_FLAG_OVR: Overrun/Underrun flag (Slave mode)
  • I2C_FLAG_AF: Acknowledge failure flag
  • I2C_FLAG_ARLO: Arbitration lost flag (Master mode)
  • I2C_FLAG_BERR: Bus error flag
Note:
  • STOPF (STOP detection) is cleared by software sequence: a read operation to I2C_SR1 register (I2C_GetFlagStatus()) followed by a write operation to I2C_CR1 register (I2C_Cmd() to re-enable the I2C peripheral).
  • ADD10 (10-bit header sent) is cleared by software sequence: a read operation to I2C_SR1 (I2C_GetFlagStatus()) followed by writing the second byte of the address in DR register.
  • BTF (Byte Transfer Finished) is cleared by software sequence: a read operation to I2C_SR1 register (I2C_GetFlagStatus()) followed by a read/write to I2C_DR register (I2C_SendData()).
  • ADDR (Address sent) is cleared by software sequence: a read operation to I2C_SR1 register (I2C_GetFlagStatus()) followed by a read operation to I2C_SR2 register ((void)(I2Cx->SR2)).
  • SB (Start Bit) is cleared software sequence: a read operation to I2C_SR1 register (I2C_GetFlagStatus()) followed by a write operation to I2C_DR register (I2C_SendData()).
Return values:
None 

Definition at line 1166 of file stm32f10x_i2c.c.

References assert_param, FLAG_Mask, IS_I2C_ALL_PERIPH, IS_I2C_CLEAR_FLAG, and I2C_TypeDef::SR1.

Referenced by LM75_GetStatus(), and sEE_WaitEepromStandbyState().

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_SMBALERT: SMBus Alert interrupt
  • I2C_IT_TIMEOUT: Timeout or Tlow error interrupt
  • I2C_IT_PECERR: PEC error in reception interrupt
  • I2C_IT_OVR: Overrun/Underrun interrupt (Slave mode)
  • I2C_IT_AF: Acknowledge failure interrupt
  • I2C_IT_ARLO: Arbitration lost interrupt (Master mode)
  • I2C_IT_BERR: Bus error interrupt
Note:
  • STOPF (STOP detection) is cleared by software sequence: a read operation to I2C_SR1 register (I2C_GetITStatus()) followed by a write operation to I2C_CR1 register (I2C_Cmd() to re-enable the I2C peripheral).
  • ADD10 (10-bit header sent) is cleared by software sequence: a read operation to I2C_SR1 (I2C_GetITStatus()) followed by writing the second byte of the address in I2C_DR register.
  • BTF (Byte Transfer Finished) is cleared by software sequence: a read operation to I2C_SR1 register (I2C_GetITStatus()) followed by a read/write to I2C_DR register (I2C_SendData()).
  • ADDR (Address sent) is cleared by software sequence: a read operation to I2C_SR1 register (I2C_GetITStatus()) followed by a read operation to I2C_SR2 register ((void)(I2Cx->SR2)).
  • SB (Start Bit) is cleared by software sequence: a read operation to I2C_SR1 register (I2C_GetITStatus()) followed by a write operation to I2C_DR register (I2C_SendData()).
Return values:
None 

Definition at line 1261 of file stm32f10x_i2c.c.

References assert_param, FLAG_Mask, IS_I2C_ALL_PERIPH, IS_I2C_CLEAR_IT, and I2C_TypeDef::SR1.

Referenced by I2C1_ER_IRQHandler(), and main().

void I2C_Cmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Enables or disables the specified I2C peripheral.

Parameters:
I2Cx,: where x can be 1 or 2 to select the I2C peripheral.
NewState,: new state of the I2Cx peripheral. This parameter can be: ENABLE or DISABLE.
Return values:
None 

Definition at line 321 of file stm32f10x_i2c.c.

References assert_param, I2C_TypeDef::CR1, CR1_PE_Reset, CR1_PE_Set, DISABLE, IS_FUNCTIONAL_STATE, and IS_I2C_ALL_PERIPH.

Referenced by HDMI_CEC_Init(), LM75_Init(), LM75_LowLevel_DeInit(), main(), sEE_Init(), and sEE_LowLevel_DeInit().

void I2C_DeInit ( I2C_TypeDef I2Cx  ) 

Deinitializes the I2Cx peripheral registers to their default reset values.

Parameters:
I2Cx,: where x can be 1 or 2 to select the I2C peripheral.
Return values:
None 

Definition at line 161 of file stm32f10x_i2c.c.

References assert_param, DISABLE, ENABLE, I2C1, IS_I2C_ALL_PERIPH, RCC_APB1Periph_I2C1, RCC_APB1Periph_I2C2, and RCC_APB1PeriphResetCmd().

Referenced by LM75_Init(), LM75_LowLevel_DeInit(), and sEE_LowLevel_DeInit().

void I2C_DMACmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Enables or disables the specified I2C DMA requests.

Parameters:
I2Cx,: where x can be 1 or 2 to select the I2C peripheral.
NewState,: new state of the I2C DMA transfer. This parameter can be: ENABLE or DISABLE.
Return values:
None 

Definition at line 345 of file stm32f10x_i2c.c.

References assert_param, I2C_TypeDef::CR2, CR2_DMAEN_Reset, CR2_DMAEN_Set, DISABLE, IS_FUNCTIONAL_STATE, and IS_I2C_ALL_PERIPH.

Referenced by I2C_ReadDataBuffer(), I2C_ReadDeviceRegister(), I2C_WriteDeviceRegister(), LM75_ReadConfReg(), LM75_ReadReg(), LM75_ReadTemp(), LM75_ShutDown(), LM75_WriteConfReg(), LM75_WriteReg(), main(), and sEE_Init().

void I2C_DMALastTransferCmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Specifies if the next DMA transfer will be the last one.

Parameters:
I2Cx,: where x can be 1 or 2 to select the I2C peripheral.
NewState,: new state of the I2C DMA last transfer. This parameter can be: ENABLE or DISABLE.
Return values:
None 

Definition at line 369 of file stm32f10x_i2c.c.

References assert_param, I2C_TypeDef::CR2, CR2_LAST_Reset, CR2_LAST_Set, DISABLE, IS_FUNCTIONAL_STATE, and IS_I2C_ALL_PERIPH.

Referenced by I2C_ReadDataBuffer(), I2C_ReadDeviceRegister(), LM75_ReadConfReg(), LM75_ReadReg(), LM75_ReadTemp(), LM75_ShutDown(), and sEE_ReadBuffer().

void I2C_DualAddressCmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Enables or disables the specified I2C dual addressing mode.

Parameters:
I2Cx,: where x can be 1 or 2 to select the I2C peripheral.
NewState,: new state of the I2C dual addressing mode. This parameter can be: ENABLE or DISABLE.
Return values:
None 

Definition at line 491 of file stm32f10x_i2c.c.

References assert_param, DISABLE, IS_FUNCTIONAL_STATE, IS_I2C_ALL_PERIPH, I2C_TypeDef::OAR2, OAR2_ENDUAL_Reset, and OAR2_ENDUAL_Set.

void I2C_FastModeDutyCycleConfig ( I2C_TypeDef I2Cx,
uint16_t  I2C_DutyCycle 
)

Selects the specified I2C fast mode duty cycle.

Parameters:
I2Cx,: where x can be 1 or 2 to select the I2C peripheral.
I2C_DutyCycle,: specifies the fast mode duty cycle. This parameter can be one of the following values:

  • I2C_DutyCycle_2: I2C fast mode Tlow/Thigh = 2
  • I2C_DutyCycle_16_9: I2C fast mode Tlow/Thigh = 16/9
Return values:
None 

Definition at line 844 of file stm32f10x_i2c.c.

References assert_param, I2C_TypeDef::CCR, I2C_DutyCycle_16_9, I2C_DutyCycle_2, IS_I2C_ALL_PERIPH, and IS_I2C_DUTY_CYCLE.

void I2C_GeneralCallCmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Enables or disables the specified I2C general call feature.

Parameters:
I2Cx,: where x can be 1 or 2 to select the I2C peripheral.
NewState,: new state of the I2C General call. This parameter can be: ENABLE or DISABLE.
Return values:
None 

Definition at line 515 of file stm32f10x_i2c.c.

References assert_param, I2C_TypeDef::CR1, CR1_ENGC_Reset, CR1_ENGC_Set, DISABLE, IS_FUNCTIONAL_STATE, and IS_I2C_ALL_PERIPH.

void I2C_GenerateSTART ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Generates I2Cx communication START condition.

Parameters:
I2Cx,: where x can be 1 or 2 to select the I2C peripheral.
NewState,: new state of the I2C START condition generation. This parameter can be: ENABLE or DISABLE.
Return values:
None. 

Definition at line 393 of file stm32f10x_i2c.c.

References assert_param, I2C_TypeDef::CR1, CR1_START_Reset, CR1_START_Set, DISABLE, IS_FUNCTIONAL_STATE, and IS_I2C_ALL_PERIPH.

Referenced by I2C_ReadDataBuffer(), I2C_ReadDeviceRegister(), I2C_WriteDeviceRegister(), LM75_GetStatus(), LM75_ReadConfReg(), LM75_ReadReg(), LM75_ReadTemp(), LM75_ShutDown(), LM75_WriteConfReg(), LM75_WriteReg(), main(), PhysicalAddressDiscovery(), sEE_ReadBuffer(), sEE_WaitEepromStandbyState(), and sEE_WritePage().

void I2C_GenerateSTOP ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Generates I2Cx communication STOP condition.

Parameters:
I2Cx,: where x can be 1 or 2 to select the I2C peripheral.
NewState,: new state of the I2C STOP condition generation. This parameter can be: ENABLE or DISABLE.
Return values:
None. 

Definition at line 417 of file stm32f10x_i2c.c.

References assert_param, I2C_TypeDef::CR1, CR1_STOP_Reset, CR1_STOP_Set, DISABLE, IS_FUNCTIONAL_STATE, and IS_I2C_ALL_PERIPH.

Referenced by I2C_ReadDataBuffer(), I2C_ReadDeviceRegister(), I2C_WriteDeviceRegister(), LM75_ReadConfReg(), LM75_ReadReg(), LM75_ReadTemp(), LM75_ShutDown(), LM75_WriteConfReg(), LM75_WriteReg(), main(), PhysicalAddressDiscovery(), sEE_I2C_DMA_RX_IRQHandler(), sEE_I2C_DMA_TX_IRQHandler(), sEE_ReadBuffer(), and sEE_WaitEepromStandbyState().

FlagStatus I2C_GetFlagStatus ( I2C_TypeDef I2Cx,
uint32_t  I2C_FLAG 
)

3) Flag-based state monitoring

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_DUALF: Dual flag (Slave mode)
  • I2C_FLAG_SMBHOST: SMBus host header (Slave mode)
  • I2C_FLAG_SMBDEFAULT: SMBus default header (Slave mode)
  • I2C_FLAG_GENCALL: General call header flag (Slave mode)
  • I2C_FLAG_TRA: Transmitter/Receiver flag
  • I2C_FLAG_BUSY: Bus busy flag
  • I2C_FLAG_MSL: Master/Slave flag
  • I2C_FLAG_SMBALERT: SMBus Alert flag
  • I2C_FLAG_TIMEOUT: Timeout or Tlow error flag
  • I2C_FLAG_PECERR: PEC error in reception flag
  • I2C_FLAG_OVR: Overrun/Underrun flag (Slave mode)
  • I2C_FLAG_AF: Acknowledge failure flag
  • I2C_FLAG_ARLO: Arbitration lost flag (Master mode)
  • I2C_FLAG_BERR: Bus error flag
  • I2C_FLAG_TXE: Data register empty flag (Transmitter)
  • I2C_FLAG_RXNE: Data register not empty (Receiver) flag
  • I2C_FLAG_STOPF: Stop detection flag (Slave mode)
  • I2C_FLAG_ADD10: 10-bit header sent flag (Master mode)
  • I2C_FLAG_BTF: Byte transfer finished flag
  • I2C_FLAG_ADDR: Address sent flag (Master mode) “ADSL” Address matched flag (Slave mode)”ENDAD”
  • I2C_FLAG_SB: Start bit flag (Master mode)
Return values:
The new state of I2C_FLAG (SET or RESET).

Definition at line 1087 of file stm32f10x_i2c.c.

References assert_param, FLAG_Mask, IS_I2C_ALL_PERIPH, IS_I2C_GET_FLAG, RESET, and SET.

Referenced by I2C_ReadDataBuffer(), I2C_ReadDeviceRegister(), I2C_WriteDeviceRegister(), LM75_GetStatus(), LM75_ReadConfReg(), LM75_ReadReg(), LM75_ReadTemp(), LM75_ShutDown(), LM75_WriteConfReg(), LM75_WriteReg(), main(), PhysicalAddressDiscovery(), sEE_I2C_DMA_TX_IRQHandler(), sEE_ReadBuffer(), sEE_WaitEepromStandbyState(), and sEE_WritePage().

ITStatus I2C_GetITStatus ( I2C_TypeDef I2Cx,
uint32_t  I2C_IT 
)

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_SMBALERT: SMBus Alert flag
  • I2C_IT_TIMEOUT: Timeout or Tlow error flag
  • I2C_IT_PECERR: PEC error in reception flag
  • I2C_IT_OVR: Overrun/Underrun flag (Slave mode)
  • I2C_IT_AF: Acknowledge failure flag
  • I2C_IT_ARLO: Arbitration lost flag (Master mode)
  • I2C_IT_BERR: Bus error flag
  • I2C_IT_TXE: Data register empty flag (Transmitter)
  • I2C_IT_RXNE: Data register not empty (Receiver) flag
  • I2C_IT_STOPF: Stop detection flag (Slave mode)
  • I2C_IT_ADD10: 10-bit header sent flag (Master mode)
  • I2C_IT_BTF: Byte transfer finished flag
  • I2C_IT_ADDR: Address sent flag (Master mode) “ADSL” Address matched flag (Slave mode)”ENDAD”
  • I2C_IT_SB: Start bit flag (Master mode)
Return values:
The new state of I2C_IT (SET or RESET).

Definition at line 1200 of file stm32f10x_i2c.c.

References assert_param, I2C_TypeDef::CR2, FLAG_Mask, IS_I2C_ALL_PERIPH, IS_I2C_GET_IT, ITEN_Mask, RESET, SET, and I2C_TypeDef::SR1.

Referenced by I2C1_ER_IRQHandler().

uint32_t I2C_GetLastEvent ( I2C_TypeDef I2Cx  ) 

2) Advanced state monitoring

Returns the last I2Cx Event.

Parameters:
I2Cx,: where x can be 1 or 2 to select the I2C peripheral.
Note:
: For detailed description of Events, please refer to section I2C_Events in stm32f10x_i2c.h file.
Return values:
The last event

Definition at line 1032 of file stm32f10x_i2c.c.

References assert_param, FLAG_Mask, IS_I2C_ALL_PERIPH, I2C_TypeDef::SR1, and I2C_TypeDef::SR2.

uint8_t I2C_GetPEC ( I2C_TypeDef I2Cx  ) 

Returns the PEC value for the specified I2C.

Parameters:
I2Cx,: where x can be 1 or 2 to select the I2C peripheral.
Return values:
The PEC value.

Definition at line 779 of file stm32f10x_i2c.c.

References assert_param, IS_I2C_ALL_PERIPH, and I2C_TypeDef::SR2.

void I2C_Init ( I2C_TypeDef I2Cx,
I2C_InitTypeDef I2C_InitStruct 
)

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

Parameters:
I2Cx,: where x can be 1 or 2 to select the I2C peripheral.
I2C_InitStruct,: pointer to a I2C_InitTypeDef structure that contains the configuration information for the specified I2C peripheral.
Return values:
None 

Definition at line 190 of file stm32f10x_i2c.c.

References assert_param, I2C_TypeDef::CCR, CCR_CCR_Set, CCR_FS_Set, I2C_TypeDef::CR1, CR1_CLEAR_Mask, CR1_PE_Reset, CR1_PE_Set, I2C_TypeDef::CR2, CR2_FREQ_Reset, I2C_InitTypeDef::I2C_Ack, I2C_InitTypeDef::I2C_AcknowledgedAddress, I2C_InitTypeDef::I2C_ClockSpeed, I2C_InitTypeDef::I2C_DutyCycle, I2C_DutyCycle_16_9, I2C_DutyCycle_2, I2C_InitTypeDef::I2C_Mode, I2C_InitTypeDef::I2C_OwnAddress1, IS_I2C_ACK_STATE, IS_I2C_ACKNOWLEDGE_ADDRESS, IS_I2C_ALL_PERIPH, IS_I2C_CLOCK_SPEED, IS_I2C_DUTY_CYCLE, IS_I2C_MODE, IS_I2C_OWN_ADDRESS1, I2C_TypeDef::OAR1, RCC_ClocksTypeDef::PCLK1_Frequency, RCC_GetClocksFreq(), and I2C_TypeDef::TRISE.

Referenced by HDMI_CEC_Init(), IOE_I2C_Config(), LM75_Init(), main(), and sEE_Init().

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

Enables or disables the specified I2C interrupts.

Parameters:
I2Cx,: where x can be 1 or 2 to select the I2C peripheral.
I2C_IT,: specifies the I2C interrupts sources to be enabled or disabled. This parameter can be any combination of the following values:

  • I2C_IT_BUF: Buffer interrupt mask
  • I2C_IT_EVT: Event interrupt mask
  • I2C_IT_ERR: Error interrupt mask
NewState,: new state of the specified I2C interrupts. This parameter can be: ENABLE or DISABLE.
Return values:
None 

Definition at line 544 of file stm32f10x_i2c.c.

References assert_param, I2C_TypeDef::CR2, DISABLE, IS_FUNCTIONAL_STATE, IS_I2C_ALL_PERIPH, and IS_I2C_CONFIG_IT.

Referenced by LM75_Init().

void I2C_OwnAddress2Config ( I2C_TypeDef I2Cx,
uint8_t  Address 
)

Configures the specified I2C own address2.

Parameters:
I2Cx,: where x can be 1 or 2 to select the I2C peripheral.
Address,: specifies the 7bit I2C own address2.
Return values:
None. 

Definition at line 464 of file stm32f10x_i2c.c.

References assert_param, IS_I2C_ALL_PERIPH, I2C_TypeDef::OAR2, and OAR2_ADD2_Reset.

void I2C_PECPositionConfig ( I2C_TypeDef I2Cx,
uint16_t  I2C_PECPosition 
)

Selects the specified I2C PEC position.

Parameters:
I2Cx,: where x can be 1 or 2 to select the I2C peripheral.
I2C_PECPosition,: specifies the PEC position. This parameter can be one of the following values:

  • I2C_PECPosition_Next: indicates that the next byte is PEC
  • I2C_PECPosition_Current: indicates that current byte is PEC
Return values:
None 

Definition at line 733 of file stm32f10x_i2c.c.

References assert_param, I2C_TypeDef::CR1, I2C_PECPosition_Current, I2C_PECPosition_Next, IS_I2C_ALL_PERIPH, and IS_I2C_PEC_POSITION.

uint16_t I2C_ReadRegister ( I2C_TypeDef I2Cx,
uint8_t  I2C_Register 
)

Reads the specified I2C register and returns its value.

Parameters:
I2C_Register,: specifies the register to read. This parameter can be one of the following values:

  • I2C_Register_CR1: CR1 register.
  • I2C_Register_CR2: CR2 register.
  • I2C_Register_OAR1: OAR1 register.
  • I2C_Register_OAR2: OAR2 register.
  • I2C_Register_DR: DR register.
  • I2C_Register_SR1: SR1 register.
  • I2C_Register_SR2: SR2 register.
  • I2C_Register_CCR: CCR register.
  • I2C_Register_TRISE: TRISE register.
Return values:
The value of the read register.

Definition at line 635 of file stm32f10x_i2c.c.

References assert_param, IS_I2C_ALL_PERIPH, and IS_I2C_REGISTER.

uint8_t I2C_ReceiveData ( I2C_TypeDef I2Cx  ) 

Returns the most recent received data by the I2Cx peripheral.

Parameters:
I2Cx,: where x can be 1 or 2 to select the I2C peripheral.
Return values:
The value of the received data.

Definition at line 582 of file stm32f10x_i2c.c.

References assert_param, I2C_TypeDef::DR, and IS_I2C_ALL_PERIPH.

Referenced by PhysicalAddressDiscovery(), and sEE_ReadBuffer().

void I2C_Send7bitAddress ( I2C_TypeDef I2Cx,
uint8_t  Address,
uint8_t  I2C_Direction 
)

Transmits the address byte to select the slave device.

Parameters:
I2Cx,: where x can be 1 or 2 to select the I2C peripheral.
Address,: specifies the slave address which will be transmitted
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
Return values:
None. 

Definition at line 600 of file stm32f10x_i2c.c.

References assert_param, I2C_TypeDef::DR, I2C_Direction_Transmitter, IS_I2C_ALL_PERIPH, IS_I2C_DIRECTION, OAR1_ADD0_Reset, and OAR1_ADD0_Set.

Referenced by I2C_ReadDataBuffer(), I2C_ReadDeviceRegister(), I2C_WriteDeviceRegister(), LM75_GetStatus(), LM75_ReadConfReg(), LM75_ReadReg(), LM75_ReadTemp(), LM75_ShutDown(), LM75_WriteConfReg(), LM75_WriteReg(), main(), PhysicalAddressDiscovery(), sEE_ReadBuffer(), sEE_WaitEepromStandbyState(), and sEE_WritePage().

void I2C_SendData ( I2C_TypeDef I2Cx,
uint8_t  Data 
)

Sends a data byte through the I2Cx peripheral.

Parameters:
I2Cx,: where x can be 1 or 2 to select the I2C peripheral.
Data,: Byte to be transmitted..
Return values:
None 

Definition at line 569 of file stm32f10x_i2c.c.

References assert_param, I2C_TypeDef::DR, and IS_I2C_ALL_PERIPH.

Referenced by I2C_ReadDataBuffer(), I2C_ReadDeviceRegister(), I2C_WriteDeviceRegister(), LM75_ReadConfReg(), LM75_ReadReg(), LM75_ReadTemp(), LM75_ShutDown(), LM75_WriteConfReg(), LM75_WriteReg(), PhysicalAddressDiscovery(), sEE_ReadBuffer(), and sEE_WritePage().

void I2C_SMBusAlertConfig ( I2C_TypeDef I2Cx,
uint16_t  I2C_SMBusAlert 
)

Drives the SMBusAlert pin high or low for the specified I2C.

Parameters:
I2Cx,: where x can be 1 or 2 to select the I2C peripheral.
I2C_SMBusAlert,: specifies SMBAlert pin level. This parameter can be one of the following values:

  • I2C_SMBusAlert_Low: SMBAlert pin driven low
  • I2C_SMBusAlert_High: SMBAlert pin driven high
Return values:
None 

Definition at line 683 of file stm32f10x_i2c.c.

References assert_param, I2C_TypeDef::CR1, I2C_SMBusAlert_High, I2C_SMBusAlert_Low, IS_I2C_ALL_PERIPH, and IS_I2C_SMBUS_ALERT.

void I2C_SoftwareResetCmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Enables or disables the specified I2C software reset.

Parameters:
I2Cx,: where x can be 1 or 2 to select the I2C peripheral.
NewState,: new state of the I2C software reset. This parameter can be: ENABLE or DISABLE.
Return values:
None 

Definition at line 657 of file stm32f10x_i2c.c.

References assert_param, I2C_TypeDef::CR1, CR1_SWRST_Reset, CR1_SWRST_Set, DISABLE, IS_FUNCTIONAL_STATE, and IS_I2C_ALL_PERIPH.

void I2C_StretchClockCmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Enables or disables the specified I2C Clock stretching.

Parameters:
I2Cx,: where x can be 1 or 2 to select the I2C peripheral.
NewState,: new state of the I2Cx Clock stretching. This parameter can be: ENABLE or DISABLE.
Return values:
None 

Definition at line 818 of file stm32f10x_i2c.c.

References assert_param, I2C_TypeDef::CR1, CR1_NOSTRETCH_Reset, CR1_NOSTRETCH_Set, DISABLE, IS_FUNCTIONAL_STATE, and IS_I2C_ALL_PERIPH.

void I2C_StructInit ( I2C_InitTypeDef I2C_InitStruct  ) 

Fills each I2C_InitStruct member with its default value.

Parameters:
I2C_InitStruct,: pointer to an I2C_InitTypeDef structure which will be initialized.
Return values:
None 

Definition at line 297 of file stm32f10x_i2c.c.

References I2C_InitTypeDef::I2C_Ack, I2C_Ack_Disable, I2C_InitTypeDef::I2C_AcknowledgedAddress, I2C_AcknowledgedAddress_7bit, I2C_InitTypeDef::I2C_ClockSpeed, I2C_InitTypeDef::I2C_DutyCycle, I2C_DutyCycle_2, I2C_InitTypeDef::I2C_Mode, I2C_Mode_I2C, and I2C_InitTypeDef::I2C_OwnAddress1.

void I2C_TransmitPEC ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Enables or disables the specified I2C PEC transfer.

Parameters:
I2Cx,: where x can be 1 or 2 to select the I2C peripheral.
NewState,: new state of the I2C PEC transmission. This parameter can be: ENABLE or DISABLE.
Return values:
None 

Definition at line 707 of file stm32f10x_i2c.c.

References assert_param, I2C_TypeDef::CR1, CR1_PEC_Reset, CR1_PEC_Set, DISABLE, IS_FUNCTIONAL_STATE, and IS_I2C_ALL_PERIPH.

STM32F10x Standard Peripherals Library: Footer

 

 

 

      For complete documentation on STM32(CORTEX M3) 32-bit Microcontrollers platform visit  www.st.com/STM32