STM32F0 Standard Peripheral bibliotheek  1.0
ST Microelectronics standard peripheral bibliotheek documentatie voor de STM32F0 familie
 All Data Structures Files Functions Variables Enumerations Enumerator Groups

I2C driver modules. More...

Modules

 I2C_Exported_Constants
 
 I2C_Private_Functions
 

Data Structures

struct  I2C_InitTypeDef
 I2C Init structure definition. More...
 

Macros

#define CR1_CLEAR_MASK   ((uint32_t)0x00CFE0FF) /*<! I2C CR1 clear register Mask */
 
#define CR2_CLEAR_MASK   ((uint32_t)0x07FF7FFF) /*<! I2C CR2 clear register Mask */
 
#define TIMING_CLEAR_MASK   ((uint32_t)0xF0FFFFFF) /*<! I2C TIMING clear register Mask */
 
#define ERROR_IT_MASK   ((uint32_t)0x00003F00) /*<! I2C Error interrupt register Mask */
 
#define TC_IT_MASK   ((uint32_t)0x000000C0) /*<! I2C TC interrupt register Mask */
 

Functions

void I2C_DeInit (I2C_TypeDef *I2Cx)
 Deinitializes the I2Cx peripheral registers to their default reset values. More...
 
void I2C_Init (I2C_TypeDef *I2Cx, I2C_InitTypeDef *I2C_InitStruct)
 Initializes the I2Cx peripheral according to the specified parameters in the I2C_InitStruct. More...
 
void I2C_StructInit (I2C_InitTypeDef *I2C_InitStruct)
 Fills each I2C_InitStruct member with its default value. More...
 
void I2C_Cmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the specified I2C peripheral. More...
 
void I2C_SoftwareResetCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the specified I2C software reset. More...
 
void I2C_ITConfig (I2C_TypeDef *I2Cx, uint32_t I2C_IT, FunctionalState NewState)
 Enables or disables the specified I2C interrupts. More...
 
void I2C_StretchClockCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the I2C Clock stretching. More...
 
void I2C_StopModeCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables I2C wakeup from stop mode. More...
 
void I2C_DualAddressCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the I2C own address 2. More...
 
void I2C_OwnAddress2Config (I2C_TypeDef *I2Cx, uint16_t Address, uint8_t Mask)
 Configures the I2C slave own address 2 and mask. More...
 
void I2C_GeneralCallCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the I2C general call mode. More...
 
void I2C_SlaveByteControlCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the I2C slave byte control. More...
 
void I2C_SlaveAddressConfig (I2C_TypeDef *I2Cx, uint16_t Address)
 Configures the slave address to be transmitted after start generation. More...
 
void I2C_10BitAddressingModeCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the I2C 10-bit addressing mode for the master. More...
 
void I2C_AutoEndCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the I2C automatic end mode (stop condition is automatically sent when nbytes data are transferred). More...
 
void I2C_ReloadCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the I2C nbytes reload mode. More...
 
void I2C_NumberOfBytesConfig (I2C_TypeDef *I2Cx, uint8_t Number_Bytes)
 Configures the number of bytes to be transmitted/received. More...
 
void I2C_MasterRequestConfig (I2C_TypeDef *I2Cx, uint16_t I2C_Direction)
 Configures the type of transfer request for the master. More...
 
void I2C_GenerateSTART (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Generates I2Cx communication START condition. More...
 
void I2C_GenerateSTOP (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Generates I2Cx communication STOP condition. More...
 
void I2C_10BitAddressHeaderCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the I2C 10-bit header only mode with read direction. More...
 
void I2C_AcknowledgeConfig (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Generates I2C communication Acknowledge. More...
 
uint8_t I2C_GetAddressMatched (I2C_TypeDef *I2Cx)
 Returns the I2C slave matched address . More...
 
uint16_t I2C_GetTransferDirection (I2C_TypeDef *I2Cx)
 Returns the I2C slave received request. More...
 
void I2C_TransferHandling (I2C_TypeDef *I2Cx, uint16_t Address, uint8_t Number_Bytes, uint32_t ReloadEndMode, uint32_t StartStopMode)
 Handles I2Cx communication when starting transfer or during transfer (TC or TCR flag are set). More...
 
void I2C_SMBusAlertCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables I2C SMBus alert. More...
 
void I2C_ClockTimeoutCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables I2C Clock Timeout (SCL Timeout detection). More...
 
void I2C_ExtendedClockTimeoutCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables I2C Extended Clock Timeout (SCL cumulative Timeout detection). More...
 
void I2C_IdleClockTimeoutCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables I2C Idle Clock Timeout (Bus idle SCL and SDA high detection). More...
 
void I2C_TimeoutAConfig (I2C_TypeDef *I2Cx, uint16_t Timeout)
 Configures the I2C Bus Timeout A (SCL Timeout when TIDLE = 0 or Bus idle SCL and SDA high when TIDLE = 1). More...
 
void I2C_TimeoutBConfig (I2C_TypeDef *I2Cx, uint16_t Timeout)
 Configures the I2C Bus Timeout B (SCL cumulative Timeout). More...
 
void I2C_CalculatePEC (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables I2C PEC calculation. More...
 
void I2C_PECRequestCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables I2C PEC transmission/reception request. More...
 
uint8_t I2C_GetPEC (I2C_TypeDef *I2Cx)
 Returns the I2C PEC. More...
 
uint32_t I2C_ReadRegister (I2C_TypeDef *I2Cx, uint8_t I2C_Register)
 Reads the specified I2C register and returns its value. More...
 
void I2C_SendData (I2C_TypeDef *I2Cx, uint8_t Data)
 Sends a data byte through the I2Cx peripheral. More...
 
uint8_t I2C_ReceiveData (I2C_TypeDef *I2Cx)
 Returns the most recent received data by the I2Cx peripheral. More...
 
void I2C_DMACmd (I2C_TypeDef *I2Cx, uint32_t I2C_DMAReq, FunctionalState NewState)
 Enables or disables the I2C DMA interface. More...
 
FlagStatus I2C_GetFlagStatus (I2C_TypeDef *I2Cx, uint32_t I2C_FLAG)
 Checks whether the specified I2C flag is set or not. More...
 
void I2C_ClearFlag (I2C_TypeDef *I2Cx, uint32_t I2C_FLAG)
 Clears the I2Cx's pending flags. More...
 
ITStatus I2C_GetITStatus (I2C_TypeDef *I2Cx, uint32_t I2C_IT)
 Checks whether the specified I2C interrupt has occurred or not. More...
 
void I2C_ClearITPendingBit (I2C_TypeDef *I2Cx, uint32_t I2C_IT)
 Clears the I2Cx's interrupt pending bits. More...
 

Detailed Description

I2C driver modules.

Function Documentation

void I2C_10BitAddressHeaderCmd ( I2C_TypeDef *  I2Cx,
FunctionalState  NewState 
)

Enables or disables the I2C 10-bit header only mode with read direction.

Parameters
I2Cx,:where x can be 1 or 2 to select the I2C peripheral.
NewState,:new state of the I2C 10-bit header only mode. This parameter can be: ENABLE or DISABLE.
Note
This mode can be used only when switching from master transmitter mode to master receiver mode.
Return values
None
void I2C_10BitAddressingModeCmd ( I2C_TypeDef *  I2Cx,
FunctionalState  NewState 
)

Enables or disables the I2C 10-bit addressing mode for the master.

Parameters
I2Cx,:where x can be 1 or 2 to select the I2C peripheral.
NewState,:new state of the I2C 10-bit addressing mode. This parameter can be: ENABLE or DISABLE.
Note
This function should be called before generating start condition.
Return values
None
void I2C_AcknowledgeConfig ( I2C_TypeDef *  I2Cx,
FunctionalState  NewState 
)

Generates I2C communication Acknowledge.

Parameters
I2Cx,:where x can be 1 or 2 to select the I2C peripheral.
NewState,:new state of the Acknowledge. This parameter can be: ENABLE or DISABLE.
Return values
None
void I2C_AutoEndCmd ( I2C_TypeDef *  I2Cx,
FunctionalState  NewState 
)

Enables or disables the I2C automatic end mode (stop condition is automatically sent when nbytes data are transferred).

Parameters
I2Cx,:where x can be 1 or 2 to select the I2C peripheral.
NewState,:new state of the I2C automatic end mode. This parameter can be: ENABLE or DISABLE.
Note
This function has effect if Reload mode is disabled.
Return values
None
void I2C_CalculatePEC ( I2C_TypeDef *  I2Cx,
FunctionalState  NewState 
)

Enables or disables I2C PEC calculation.

Parameters
I2Cx,:where x can be 1 to select the I2C peripheral.
NewState,:new state of the I2Cx PEC calculation. This parameter can be: ENABLE or DISABLE.
Return values
None
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
Thenew state of I2C_FLAG (SET or RESET).
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
Thenew state of I2C_IT (SET or RESET).
void I2C_ClockTimeoutCmd ( I2C_TypeDef *  I2Cx,
FunctionalState  NewState 
)

Enables or disables I2C Clock Timeout (SCL Timeout detection).

Parameters
I2Cx,:where x can be 1 to select the I2C peripheral.
NewState,:new state of the I2Cx clock Timeout. This parameter can be: ENABLE or DISABLE.
Return values
None
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
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
void I2C_DMACmd ( I2C_TypeDef *  I2Cx,
uint32_t  I2C_DMAReq,
FunctionalState  NewState 
)

Enables or disables the I2C DMA interface.

Parameters
I2Cx,:where x can be 1 or 2 to select the I2C peripheral.
I2C_DMAReq,:specifies the I2C DMA transfer request to be enabled or disabled. This parameter can be any combination of the following values:
  • I2C_DMAReq_Tx: Tx DMA transfer request
  • I2C_DMAReq_Rx: Rx DMA transfer request
NewState,:new state of the selected I2C DMA transfer request. This parameter can be: ENABLE or DISABLE.
Return values
None
void I2C_DualAddressCmd ( I2C_TypeDef *  I2Cx,
FunctionalState  NewState 
)

Enables or disables the I2C own address 2.

Parameters
I2Cx,:where x can be 1 or 2 to select the I2C peripheral.
NewState,:new state of the I2C own address 2. This parameter can be: ENABLE or DISABLE.
Return values
None
void I2C_ExtendedClockTimeoutCmd ( I2C_TypeDef *  I2Cx,
FunctionalState  NewState 
)

Enables or disables I2C Extended Clock Timeout (SCL cumulative Timeout detection).

Parameters
I2Cx,:where x can be 1 to select the I2C peripheral.
NewState,:new state of the I2Cx Extended clock Timeout. This parameter can be: ENABLE or DISABLE.
Return values
None
void I2C_GeneralCallCmd ( I2C_TypeDef *  I2Cx,
FunctionalState  NewState 
)

Enables or disables the I2C general call mode.

Parameters
I2Cx,:where x can be 1 or 2 to select the I2C peripheral.
NewState,:new state of the I2C general call mode. This parameter can be: ENABLE or DISABLE.
Return values
None
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
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
uint8_t I2C_GetAddressMatched ( I2C_TypeDef *  I2Cx)

Returns the I2C slave matched address .

Parameters
I2Cx,:where x can be 1 or 2 to select the I2C peripheral.
Return values
Thevalue of the slave matched address .
FlagStatus I2C_GetFlagStatus ( I2C_TypeDef *  I2Cx,
uint32_t  I2C_FLAG 
)

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
Thenew state of I2C_FLAG (SET or RESET).
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_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
Thenew state of I2C_IT (SET or RESET).
uint8_t I2C_GetPEC ( I2C_TypeDef *  I2Cx)

Returns the I2C PEC.

Parameters
I2Cx,:where x can be 1 to select the I2C peripheral.
Return values
Thevalue of the PEC .
uint16_t I2C_GetTransferDirection ( I2C_TypeDef *  I2Cx)

Returns the I2C slave received request.

Parameters
I2Cx,:where x can be 1 or 2 to select the I2C peripheral.
Return values
Thevalue of the received request.
void I2C_IdleClockTimeoutCmd ( I2C_TypeDef *  I2Cx,
FunctionalState  NewState 
)

Enables or disables I2C Idle Clock Timeout (Bus idle SCL and SDA high detection).

Parameters
I2Cx,:where x can be 1 to select the I2C peripheral.
NewState,:new state of the I2Cx Idle clock Timeout. This parameter can be: ENABLE or DISABLE.
Return values
None
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
void I2C_ITConfig ( I2C_TypeDef *  I2Cx,
uint32_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_ERRI: Error interrupt mask
  • I2C_IT_TCI: Transfer Complete interrupt mask
  • I2C_IT_STOPI: Stop Detection interrupt mask
  • I2C_IT_NACKI: Not Acknowledge received interrupt mask
  • I2C_IT_ADDRI: Address Match interrupt mask
  • I2C_IT_RXI: RX interrupt mask
  • I2C_IT_TXI: TX interrupt mask
NewState,:new state of the specified I2C interrupts. This parameter can be: ENABLE or DISABLE.
Return values
None
void I2C_MasterRequestConfig ( I2C_TypeDef *  I2Cx,
uint16_t  I2C_Direction 
)

Configures the type of transfer request for the master.

Parameters
I2Cx,:where x can be 1 or 2 to select the I2C peripheral.
I2C_Direction,:specifies the transfer request direction to be programmed. This parameter can be one of the following values:
  • I2C_Direction_Transmitter: Master request a write transfer
  • I2C_Direction_Receiver: Master request a read transfer
Return values
None
void I2C_NumberOfBytesConfig ( I2C_TypeDef *  I2Cx,
uint8_t  Number_Bytes 
)

Configures the number of bytes to be transmitted/received.

Parameters
I2Cx,:where x can be 1 or 2 to select the I2C peripheral.
Number_Bytes,:specifies the number of bytes to be programmed.
Return values
None
void I2C_OwnAddress2Config ( I2C_TypeDef *  I2Cx,
uint16_t  Address,
uint8_t  Mask 
)

Configures the I2C slave own address 2 and mask.

Parameters
I2Cx,:where x can be 1 or 2 to select the I2C peripheral.
Address,:specifies the slave address to be programmed.
Mask,:specifies own address 2 mask to be programmed. This parameter can be one of the following values:
  • I2C_OA2_NoMask: no mask.
  • I2C_OA2_Mask01: OA2[1] is masked and don't care.
  • I2C_OA2_Mask02: OA2[2:1] are masked and don't care.
  • I2C_OA2_Mask03: OA2[3:1] are masked and don't care.
  • I2C_OA2_Mask04: OA2[4:1] are masked and don't care.
  • I2C_OA2_Mask05: OA2[5:1] are masked and don't care.
  • I2C_OA2_Mask06: OA2[6:1] are masked and don't care.
  • I2C_OA2_Mask07: OA2[7:1] are masked and don't care.
Return values
None
void I2C_PECRequestCmd ( I2C_TypeDef *  I2Cx,
FunctionalState  NewState 
)

Enables or disables I2C PEC transmission/reception request.

Parameters
I2Cx,:where x can be 1 to select the I2C peripheral.
NewState,:new state of the I2Cx PEC request. This parameter can be: ENABLE or DISABLE.
Return values
None
uint32_t I2C_ReadRegister ( I2C_TypeDef *  I2Cx,
uint8_t  I2C_Register 
)

Reads the specified I2C register and returns its value.

Parameters
I2Cx,:where x can be 1 or 2 to select the I2C peripheral.
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_TIMINGR: TIMING register.
  • I2C_Register_TIMEOUTR: TIMEOUTR register.
  • I2C_Register_ISR: ISR register.
  • I2C_Register_ICR: ICR register.
  • I2C_Register_PECR: PECR register.
  • I2C_Register_RXDR: RXDR register.
  • I2C_Register_TXDR: TXDR register.
Return values
Thevalue of the read 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
Thevalue of the received data.
void I2C_ReloadCmd ( I2C_TypeDef *  I2Cx,
FunctionalState  NewState 
)

Enables or disables the I2C nbytes reload mode.

Parameters
I2Cx,:where x can be 1 or 2 to select the I2C peripheral.
NewState,:new state of the nbytes reload mode. This parameter can be: ENABLE or DISABLE.
Return values
None
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
void I2C_SlaveAddressConfig ( I2C_TypeDef *  I2Cx,
uint16_t  Address 
)

Configures the slave address to be transmitted after start generation.

Parameters
I2Cx,:where x can be 1 or 2 to select the I2C peripheral.
Address,:specifies the slave address to be programmed.
Note
This function should be called before generating start condition.
Return values
None
void I2C_SlaveByteControlCmd ( I2C_TypeDef *  I2Cx,
FunctionalState  NewState 
)

Enables or disables the I2C slave byte control.

Parameters
I2Cx,:where x can be 1 or 2 to select the I2C peripheral.
NewState,:new state of the I2C slave byte control. This parameter can be: ENABLE or DISABLE.
Return values
None
void I2C_SMBusAlertCmd ( I2C_TypeDef *  I2Cx,
FunctionalState  NewState 
)

Enables or disables I2C SMBus alert.

Parameters
I2Cx,:where x can be 1 to select the I2C peripheral.
NewState,:new state of the I2Cx SMBus alert. This parameter can be: ENABLE or DISABLE.
Return values
None
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
void I2C_StopModeCmd ( I2C_TypeDef *  I2Cx,
FunctionalState  NewState 
)

Enables or disables I2C wakeup from stop mode.

Parameters
I2Cx,:where x can be 1 to select the I2C peripheral.
NewState,:new state of the I2Cx stop mode. This parameter can be: ENABLE or DISABLE.
Return values
None
void I2C_StretchClockCmd ( I2C_TypeDef *  I2Cx,
FunctionalState  NewState 
)

Enables or disables the 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
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
void I2C_TimeoutAConfig ( I2C_TypeDef *  I2Cx,
uint16_t  Timeout 
)

Configures the I2C Bus Timeout A (SCL Timeout when TIDLE = 0 or Bus idle SCL and SDA high when TIDLE = 1).

Parameters
I2Cx,:where x can be 1 to select the I2C peripheral.
Timeout,:specifies the TimeoutA to be programmed.
Return values
None
void I2C_TimeoutBConfig ( I2C_TypeDef *  I2Cx,
uint16_t  Timeout 
)

Configures the I2C Bus Timeout B (SCL cumulative Timeout).

Parameters
I2Cx,:where x can be 1 to select the I2C peripheral.
Timeout,:specifies the TimeoutB to be programmed.
Return values
None
void I2C_TransferHandling ( I2C_TypeDef *  I2Cx,
uint16_t  Address,
uint8_t  Number_Bytes,
uint32_t  ReloadEndMode,
uint32_t  StartStopMode 
)

Handles I2Cx communication when starting transfer or during transfer (TC or TCR flag are set).

Parameters
I2Cx,:where x can be 1 or 2 to select the I2C peripheral.
Address,:specifies the slave address to be programmed.
Number_Bytes,:specifies the number of bytes to be programmed. This parameter must be a value between 0 and 255.
ReloadEndMode,:new state of the I2C START condition generation. This parameter can be one of the following values:
  • I2C_Reload_Mode: Enable Reload mode .
  • I2C_AutoEnd_Mode: Enable Automatic end mode.
  • I2C_SoftEnd_Mode: Enable Software end mode.
StartStopMode,:new state of the I2C START condition generation. This parameter can be one of the following values:
  • I2C_No_StartStop: Don't Generate stop and start condition.
  • I2C_Generate_Stop: Generate stop condition (Number_Bytes should be set to 0).
  • I2C_Generate_Start_Read: Generate Restart for read request.
  • I2C_Generate_Start_Write: Generate Restart for write request.
Return values
None