Modules | Classes | Macros | Functions

I2C driver modules. More...

Collaboration diagram for I2C:

Modules

 I2C_Exported_Constants
 
 I2C_Private_Functions
 
 I2C_Exported_Types
 
 I2C_Exported_Macros
 
 I2C_Exported_Functions
 
 I2C_Private_TypesDefinitions
 
 I2C_Private_Defines
 
 I2C_Private_Macros
 
 I2C_Private_Variables
 
 I2C_Private_FunctionPrototypes
 

Classes

struct  I2C_InitTypeDef
 I2C Init structure definition. More...
 

Macros

#define CR1_CLEAR_MASK   ((uint32_t)0x00CFE0FF) /*<! I2C CR1 clear register Mask */
 
#define CR1_CLEAR_MASK   ((uint16_t)0xFBF5) /*<! I2C registers Masks */
 
#define CR2_CLEAR_MASK   ((uint32_t)0x07FF7FFF) /*<! I2C CR2 clear register Mask */
 
#define ERROR_IT_MASK   ((uint32_t)0x00003F00) /*<! I2C Error interrupt register Mask */
 
#define FLAG_MASK   ((uint32_t)0x00FFFFFF) /*<! I2C FLAG mask */
 
#define ITEN_MASK   ((uint32_t)0x07000000) /*<! I2C Interrupt Enable mask */
 
#define TC_IT_MASK   ((uint32_t)0x000000C0) /*<! I2C TC interrupt register Mask */
 
#define TIMING_CLEAR_MASK   ((uint32_t)0xF0FFFFFF) /*<! I2C TIMING clear register Mask */
 

Functions

void I2C_10BitAddressHeaderCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the I2C 10-bit header only mode with read direction. More...
 
void I2C_10BitAddressingModeCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the I2C 10-bit addressing mode for the master. More...
 
void I2C_AcknowledgeConfig (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the specified I2C acknowledge feature. More...
 
void I2C_AnalogFilterCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the Analog filter of I2C peripheral. More...
 
void I2C_ARPCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the specified I2C ARP. 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...
 
ErrorStatus I2C_CheckEvent (I2C_TypeDef *I2Cx, uint32_t I2C_EVENT)
 Checks whether the last I2Cx Event is equal to the one passed as parameter. More...
 
void I2C_ClearFlag (I2C_TypeDef *I2Cx, uint32_t I2C_FLAG)
 Clears the I2Cx's pending flags. More...
 
void I2C_ClearITPendingBit (I2C_TypeDef *I2Cx, uint32_t I2C_IT)
 Clears the I2Cx's interrupt pending bits. More...
 
void I2C_ClockTimeoutCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables I2C Clock Timeout (SCL Timeout detection). More...
 
void I2C_DigitalFilterConfig (I2C_TypeDef *I2Cx, uint16_t I2C_DigitalFilter)
 Configures the Digital noise filter of I2C peripheral. More...
 
void I2C_DMACmd (I2C_TypeDef *I2Cx, uint32_t I2C_DMAReq, FunctionalState NewState)
 Enables or disables the I2C DMA interface. More...
 
void I2C_DMACmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the specified I2C DMA requests. More...
 
void I2C_DMALastTransferCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Specifies that the next DMA transfer is the last one. More...
 
void I2C_ExtendedClockTimeoutCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables I2C Extended Clock Timeout (SCL cumulative Timeout detection). More...
 
void I2C_FastModeDutyCycleConfig (I2C_TypeDef *I2Cx, uint16_t I2C_DutyCycle)
 Selects the specified I2C fast mode duty cycle. 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...
 
uint8_t I2C_GetAddressMatched (I2C_TypeDef *I2Cx)
 Returns the I2C slave matched address . More...
 
FlagStatus I2C_GetFlagStatus (I2C_TypeDef *I2Cx, uint32_t I2C_FLAG)
 Checks whether the specified I2C flag is set or not. More...
 
ITStatus I2C_GetITStatus (I2C_TypeDef *I2Cx, uint32_t I2C_IT)
 Checks whether the specified I2C interrupt has occurred or not. More...
 
uint32_t I2C_GetLastEvent (I2C_TypeDef *I2Cx)
 Returns the last I2Cx Event. More...
 
uint16_t I2C_GetTransferDirection (I2C_TypeDef *I2Cx)
 Returns the I2C slave received request. 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_ITConfig (I2C_TypeDef *I2Cx, uint32_t I2C_IT, FunctionalState NewState)
 Enables or disables the specified I2C interrupts. More...
 
void I2C_ITConfig (I2C_TypeDef *I2Cx, uint16_t I2C_IT, FunctionalState NewState)
 Enables or disables the specified I2C interrupts. More...
 
void I2C_MasterRequestConfig (I2C_TypeDef *I2Cx, uint16_t I2C_Direction)
 Configures the type of transfer request for the master. More...
 
void I2C_NACKPositionConfig (I2C_TypeDef *I2Cx, uint16_t I2C_NACKPosition)
 Selects the specified I2C NACK position in master receiver mode. More...
 
void I2C_NumberOfBytesConfig (I2C_TypeDef *I2Cx, uint8_t Number_Bytes)
 Configures the number of bytes to be transmitted/received. 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_OwnAddress2Config (I2C_TypeDef *I2Cx, uint8_t Address)
 Configures the specified I2C own address2. More...
 
void I2C_PECPositionConfig (I2C_TypeDef *I2Cx, uint16_t I2C_PECPosition)
 Selects the specified I2C PEC position. More...
 
void I2C_PECRequestCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables I2C PEC transmission/reception request. More...
 
uint16_t I2C_ReadRegister (I2C_TypeDef *I2Cx, uint8_t I2C_Register)
 Reads the specified I2C register and returns its value. More...
 
uint8_t I2C_ReceiveData (I2C_TypeDef *I2Cx)
 Returns the most recent received data by the I2Cx peripheral. More...
 
void I2C_ReloadCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the I2C nbytes reload mode. More...
 
void I2C_Send7bitAddress (I2C_TypeDef *I2Cx, uint8_t Address, uint8_t I2C_Direction)
 Transmits the address byte to select the slave device. More...
 
void I2C_SendData (I2C_TypeDef *I2Cx, uint8_t Data)
 Sends a data byte through the I2Cx peripheral. More...
 
void I2C_SlaveAddressConfig (I2C_TypeDef *I2Cx, uint16_t Address)
 Configures the slave address to be transmitted after start generation. More...
 
void I2C_SlaveByteControlCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the I2C slave byte control. More...
 
void I2C_SMBusAlertCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables I2C SMBus alert. More...
 
void I2C_SMBusAlertConfig (I2C_TypeDef *I2Cx, uint16_t I2C_SMBusAlert)
 Drives the SMBusAlert pin high or low for the specified I2C. More...
 
void I2C_SoftwareResetCmd (I2C_TypeDef *I2Cx)
 Enables or disables the specified I2C software reset. More...
 
void I2C_SoftwareResetCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the specified I2C software reset. More...
 
void I2C_StopModeCmd (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables I2C wakeup from stop mode. 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_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_TransmitPEC (I2C_TypeDef *I2Cx, FunctionalState NewState)
 Enables or disables the specified I2C PEC transfer. More...
 

Detailed Description

I2C driver modules.

Macro Definition Documentation

#define CR1_CLEAR_MASK   ((uint32_t)0x00CFE0FF) /*<! I2C CR1 clear register Mask */

Definition at line 94 of file stm32f30x_i2c.c.

#define CR1_CLEAR_MASK   ((uint16_t)0xFBF5) /*<! I2C registers Masks */

Definition at line 107 of file stm32f4xx_i2c.c.

#define CR2_CLEAR_MASK   ((uint32_t)0x07FF7FFF) /*<! I2C CR2 clear register Mask */

Definition at line 95 of file stm32f30x_i2c.c.

#define ERROR_IT_MASK   ((uint32_t)0x00003F00) /*<! I2C Error interrupt register Mask */

Definition at line 97 of file stm32f30x_i2c.c.

#define FLAG_MASK   ((uint32_t)0x00FFFFFF) /*<! I2C FLAG mask */

Definition at line 108 of file stm32f4xx_i2c.c.

#define ITEN_MASK   ((uint32_t)0x07000000) /*<! I2C Interrupt Enable mask */

Definition at line 109 of file stm32f4xx_i2c.c.

#define TC_IT_MASK   ((uint32_t)0x000000C0) /*<! I2C TC interrupt register Mask */

Definition at line 98 of file stm32f30x_i2c.c.

#define TIMING_CLEAR_MASK   ((uint32_t)0xF0FFFFFF) /*<! I2C TIMING clear register Mask */

Definition at line 96 of file stm32f30x_i2c.c.

Function Documentation

void I2C_10BitAddressHeaderCmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

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

Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
NewStatenew 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

Definition at line 774 of file stm32f30x_i2c.c.

void I2C_10BitAddressingModeCmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

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

Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
NewStatenew 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

Definition at line 553 of file stm32f30x_i2c.c.

void I2C_AcknowledgeConfig ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Enables or disables the specified I2C acknowledge feature.

Parameters
I2Cxwhere x can be 1, 2 or 3 to select the I2C peripheral.
NewStatenew state of the I2C Acknowledgement. This parameter can be: ENABLE or DISABLE.
Return values
None.
Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
NewStatenew state of the I2C Acknowledgement. This parameter can be: ENABLE or DISABLE.
Return values
None.Enables or disables the specified I2C acknowledge feature.
Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
NewStatenew state of the Acknowledge. This parameter can be: ENABLE or DISABLE.
Return values
None

Definition at line 472 of file stm32f4xx_i2c.c.

void I2C_AnalogFilterCmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Enables or disables the Analog filter of I2C peripheral.

Parameters
I2Cxwhere x can be 1, 2 or 3 to select the I2C peripheral.
NewStatenew state of the Analog filter. This parameter can be: ENABLE or DISABLE.
Note
This function should be called before initializing and enabling the I2C Peripheral.
Return values
None

Definition at line 339 of file stm32f4xx_i2c.c.

void I2C_ARPCmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Enables or disables the specified I2C ARP.

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

Definition at line 712 of file stm32f4xx_i2c.c.

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
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
NewStatenew 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

Definition at line 618 of file stm32f30x_i2c.c.

ErrorStatus I2C_CheckEvent ( I2C_TypeDef I2Cx,
uint32_t  I2C_EVENT 
)

Checks whether the last I2Cx Event is equal to the one passed as parameter.

Parameters
I2Cxwhere x can be 1, 2 or 3 to select the I2C peripheral.
I2C_EVENTspecifies 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 stm32f4xx_i2c.h file.
Return values
AnErrorStatus enumeration value:
  • SUCCESS: Last event is equal to the I2C_EVENT
  • ERROR: Last event is different from the I2C_EVENT

Checks whether the last I2Cx Event is equal to the one passed as parameter.

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 applications 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 mentioned 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 defined 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
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
I2C_EVENTspecifies 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
AnErrorStatus enumeration value:
  • SUCCESS: Last event is equal to the I2C_EVENT
  • ERROR: Last event is different from the I2C_EVENT

Definition at line 1152 of file stm32f4xx_i2c.c.

void I2C_ClearFlag ( I2C_TypeDef I2Cx,
uint32_t  I2C_FLAG 
)

Clears the I2Cx's pending flags.

Parameters
I2Cxwhere x can be 1, 2 or 3 to select the I2C peripheral.
I2C_FLAGspecifies 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
Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
I2C_FLAGspecifies 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
Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
I2C_FLAGspecifies 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).

Definition at line 1332 of file stm32f4xx_i2c.c.

void I2C_ClearITPendingBit ( I2C_TypeDef I2Cx,
uint32_t  I2C_IT 
)

Clears the I2Cx's interrupt pending bits.

Parameters
I2Cxwhere x can be 1, 2 or 3 to select the I2C peripheral.
I2C_ITspecifies 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
NoneClears the I2Cx's interrupt pending bits.
Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
I2C_ITspecifies 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
Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
I2C_ITspecifies 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).

Definition at line 1426 of file stm32f4xx_i2c.c.

void I2C_ClockTimeoutCmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

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

Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
NewStatenew state of the I2Cx clock Timeout. This parameter can be: ENABLE or DISABLE.
Return values
None

Definition at line 976 of file stm32f30x_i2c.c.

void I2C_DigitalFilterConfig ( I2C_TypeDef I2Cx,
uint16_t  I2C_DigitalFilter 
)

Configures the Digital noise filter of I2C peripheral.

Parameters
I2Cxwhere x can be 1, 2 or 3 to select the I2C peripheral.
I2C_DigitalFilterCoefficient of digital noise filter. This parameter can be a number between 0x00 and 0x0F.
Note
This function should be called before initializing and enabling the I2C Peripheral.
Return values
None

Definition at line 365 of file stm32f4xx_i2c.c.

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

Enables or disables the I2C DMA interface.

Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
I2C_DMAReqspecifies 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
NewStatenew state of the selected I2C DMA transfer request. This parameter can be: ENABLE or DISABLE.
Return values
None

Definition at line 1301 of file stm32f30x_i2c.c.

void I2C_DMACmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Enables or disables the specified I2C DMA requests.

Parameters
I2Cxwhere x can be 1, 2 or 3 to select the I2C peripheral.
NewStatenew state of the I2C DMA transfer. This parameter can be: ENABLE or DISABLE.
Return values
None
Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
NewStatenew state of the I2C DMA transfer. This parameter can be: ENABLE or DISABLE.
Return values
None

Definition at line 904 of file stm32f4xx_i2c.c.

void I2C_DMALastTransferCmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Specifies that the next DMA transfer is the last one.

Parameters
I2Cxwhere x can be 1, 2 or 3 to select the I2C peripheral.
NewStatenew state of the I2C DMA last transfer. This parameter can be: ENABLE or DISABLE.
Return values
NoneSpecifies that the next DMA transfer is the last one.
Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
NewStatenew state of the I2C DMA last transfer. This parameter can be: ENABLE or DISABLE.
Return values
None

Definition at line 928 of file stm32f4xx_i2c.c.

void I2C_ExtendedClockTimeoutCmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

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

Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
NewStatenew state of the I2Cx Extended clock Timeout. This parameter can be: ENABLE or DISABLE.
Return values
None

Definition at line 1001 of file stm32f30x_i2c.c.

void I2C_FastModeDutyCycleConfig ( I2C_TypeDef I2Cx,
uint16_t  I2C_DutyCycle 
)

Selects the specified I2C fast mode duty cycle.

Parameters
I2Cxwhere x can be 1, 2 or 3 to select the I2C peripheral.
I2C_DutyCyclespecifies 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
Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
I2C_DutyCyclespecifies 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 622 of file stm32f4xx_i2c.c.

void I2C_GenerateSTART ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Generates I2Cx communication START condition.

Parameters
I2Cxwhere x can be 1, 2 or 3 to select the I2C peripheral.
NewStatenew state of the I2C START condition generation. This parameter can be: ENABLE or DISABLE.
Return values
None.
Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
NewStatenew state of the I2C START condition generation. This parameter can be: ENABLE or DISABLE.
Return values
None.
Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
NewStatenew state of the I2C START condition generation. This parameter can be: ENABLE or DISABLE.
Return values
None

Definition at line 393 of file stm32f4xx_i2c.c.

void I2C_GenerateSTOP ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Generates I2Cx communication STOP condition.

Parameters
I2Cxwhere x can be 1, 2 or 3 to select the I2C peripheral.
NewStatenew state of the I2C STOP condition generation. This parameter can be: ENABLE or DISABLE.
Return values
None.
Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
NewStatenew state of the I2C STOP condition generation. This parameter can be: ENABLE or DISABLE.
Return values
None.
Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
NewStatenew state of the I2C STOP condition generation. This parameter can be: ENABLE or DISABLE.
Return values
None

Definition at line 417 of file stm32f4xx_i2c.c.

uint8_t I2C_GetAddressMatched ( I2C_TypeDef I2Cx)

Returns the I2C slave matched address .

Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
Return values
Thevalue of the slave matched address .

Definition at line 822 of file stm32f30x_i2c.c.

FlagStatus I2C_GetFlagStatus ( I2C_TypeDef I2Cx,
uint32_t  I2C_FLAG 
)

Checks whether the specified I2C flag is set or not.

Parameters
I2Cxwhere x can be 1, 2 or 3 to select the I2C peripheral.
I2C_FLAGspecifies 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
Thenew state of I2C_FLAG (SET or RESET).

3) Flag-based state monitoring

Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
I2C_FLAGspecifies 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)"ENDA"
  • I2C_FLAG_SB: Start bit flag (Master mode)
Return values
Thenew state of I2C_FLAG (SET or RESET).
Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
I2C_FLAGspecifies 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).

Definition at line 1255 of file stm32f4xx_i2c.c.

ITStatus I2C_GetITStatus ( I2C_TypeDef I2Cx,
uint32_t  I2C_IT 
)

Checks whether the specified I2C interrupt has occurred or not.

Parameters
I2Cxwhere x can be 1, 2 or 3 to select the I2C peripheral.
I2C_ITspecifies 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
Thenew state of I2C_IT (SET or RESET).
Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
I2C_ITspecifies 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
Thenew state of I2C_IT (SET or RESET).
Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
I2C_ITspecifies 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).

Definition at line 1366 of file stm32f4xx_i2c.c.

uint32_t I2C_GetLastEvent ( I2C_TypeDef I2Cx)

Returns the last I2Cx Event.

Parameters
I2Cxwhere x can be 1, 2 or 3 to select the I2C peripheral.
Note
For detailed description of Events, please refer to section I2C_Events in stm32f4xx_i2c.h file.
Return values
Thelast event

2) Advanced state monitoring

Parameters
I2Cxwhere 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
Thelast event

Definition at line 1200 of file stm32f4xx_i2c.c.

uint16_t I2C_GetTransferDirection ( I2C_TypeDef I2Cx)

Returns the I2C slave received request.

Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
Return values
Thevalue of the received request.

Definition at line 836 of file stm32f30x_i2c.c.

void I2C_IdleClockTimeoutCmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

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

Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
NewStatenew state of the I2Cx Idle clock Timeout. This parameter can be: ENABLE or DISABLE.
Return values
None

Definition at line 1027 of file stm32f30x_i2c.c.

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

Enables or disables the specified I2C interrupts.

Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
I2C_ITspecifies 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
NewStatenew state of the specified I2C interrupts. This parameter can be: ENABLE or DISABLE.
Return values
None

Definition at line 334 of file stm32f30x_i2c.c.

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

Enables or disables the specified I2C interrupts.

Parameters
I2Cxwhere x can be 1, 2 or 3 to select the I2C peripheral.
I2C_ITspecifies 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
NewStatenew state of the specified I2C interrupts. This parameter can be: ENABLE or DISABLE.
Return values
None
Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
I2C_ITspecifies 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
NewStatenew state of the specified I2C interrupts. This parameter can be: ENABLE or DISABLE.
Return values
None

Definition at line 1093 of file stm32f4xx_i2c.c.

void I2C_MasterRequestConfig ( I2C_TypeDef I2Cx,
uint16_t  I2C_Direction 
)

Configures the type of transfer request for the master.

Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
I2C_Directionspecifies 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

Definition at line 696 of file stm32f30x_i2c.c.

void I2C_NACKPositionConfig ( I2C_TypeDef I2Cx,
uint16_t  I2C_NACKPosition 
)

Selects the specified I2C NACK position in master receiver mode.

Note
This function is useful in I2C Master Receiver mode when the number of data to be received is equal to 2. In this case, this function should be called (with parameter I2C_NACKPosition_Next) before data reception starts,as described in the 2-byte reception procedure recommended in Reference Manual in Section: Master receiver.
Parameters
I2Cxwhere x can be 1, 2 or 3 to select the I2C peripheral.
I2C_NACKPositionspecifies the NACK position. This parameter can be one of the following values:
  • I2C_NACKPosition_Next: indicates that the next byte will be the last received byte.
  • I2C_NACKPosition_Current: indicates that current byte is the last received byte.
Note
This function configures the same bit (POS) as I2C_PECPositionConfig() but is intended to be used in I2C mode while I2C_PECPositionConfig() is intended to used in SMBUS mode.
Return values
NoneSelects the specified I2C NACK position in master receiver mode.
Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
I2C_NACKPositionspecifies the NACK position. This parameter can be one of the following values:
  • I2C_NACKPosition_Next: indicates that the next byte will be the last received byte.
  • I2C_NACKPosition_Current: indicates that current byte is the last received byte.
Note
This function configures the same bit (POS) as I2C_PECPositionConfig() but is intended to be used in I2C mode while I2C_PECPositionConfig() is intended to used in SMBUS mode.
Return values
None

Definition at line 660 of file stm32f4xx_i2c.c.

void I2C_NumberOfBytesConfig ( I2C_TypeDef I2Cx,
uint8_t  Number_Bytes 
)

Configures the number of bytes to be transmitted/received.

Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
Number_Bytesspecifies the number of bytes to be programmed.
Return values
None

Definition at line 667 of file stm32f30x_i2c.c.

void I2C_OwnAddress2Config ( I2C_TypeDef I2Cx,
uint16_t  Address,
uint8_t  Mask 
)

Configures the I2C slave own address 2 and mask.

Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
Addressspecifies the slave address to be programmed.
Maskspecifies 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

Definition at line 444 of file stm32f30x_i2c.c.

void I2C_OwnAddress2Config ( I2C_TypeDef I2Cx,
uint8_t  Address 
)

Configures the specified I2C own address2.

Parameters
I2Cxwhere x can be 1, 2 or 3 to select the I2C peripheral.
Addressspecifies the 7bit I2C own address2.
Return values
None.
Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
Addressspecifies the 7bit I2C own address2.
Return values
None.

Definition at line 495 of file stm32f4xx_i2c.c.

void I2C_PECPositionConfig ( I2C_TypeDef I2Cx,
uint16_t  I2C_PECPosition 
)

Selects the specified I2C PEC position.

Parameters
I2Cxwhere x can be 1, 2 or 3 to select the I2C peripheral.
I2C_PECPositionspecifies 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
Note
This function configures the same bit (POS) as I2C_NACKPositionConfig() but is intended to be used in SMBUS mode while I2C_NACKPositionConfig() is intended to used in I2C mode.
Return values
None
Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
I2C_PECPositionspecifies 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
Note
This function configures the same bit (POS) as I2C_NACKPositionConfig() but is intended to be used in SMBUS mode while I2C_NACKPositionConfig() is intended to used in I2C mode.
Return values
None

Definition at line 825 of file stm32f4xx_i2c.c.

void I2C_PECRequestCmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Enables or disables I2C PEC transmission/reception request.

Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
NewStatenew state of the I2Cx PEC request. This parameter can be: ENABLE or DISABLE.
Return values
None

Definition at line 1132 of file stm32f30x_i2c.c.

uint32_t I2C_ReadRegister ( I2C_TypeDef I2Cx,
uint8_t  I2C_Register 
)

Reads the specified I2C register and returns its value.

Parameters
I2C_Registerspecifies 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
Thevalue of the read register.
Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
I2C_Registerspecifies 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.

Definition at line 1066 of file stm32f4xx_i2c.c.

uint8_t I2C_ReceiveData ( I2C_TypeDef I2Cx)

Returns the most recent received data by the I2Cx peripheral.

Parameters
I2Cxwhere x can be 1, 2 or 3 to select the I2C peripheral.
Return values
Thevalue of the received data.
Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
Return values
Thevalue of the received data.

Definition at line 763 of file stm32f4xx_i2c.c.

void I2C_ReloadCmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Enables or disables the I2C nbytes reload mode.

Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
NewStatenew state of the nbytes reload mode. This parameter can be: ENABLE or DISABLE.
Return values
None

Definition at line 643 of file stm32f30x_i2c.c.

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

Transmits the address byte to select the slave device.

Parameters
I2Cxwhere x can be 1, 2 or 3 to select the I2C peripheral.
Addressspecifies the slave address which will be transmitted
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.
Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
Addressspecifies the slave address which will be transmitted
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.

Definition at line 445 of file stm32f4xx_i2c.c.

void I2C_SendData ( I2C_TypeDef I2Cx,
uint8_t  Data 
)

Sends a data byte through the I2Cx peripheral.

Parameters
I2Cxwhere x can be 1, 2 or 3 to select the I2C peripheral.
DataByte to be transmitted..
Return values
None
Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
DataByte to be transmitted..
Return values
None

Definition at line 750 of file stm32f4xx_i2c.c.

void I2C_SlaveAddressConfig ( I2C_TypeDef I2Cx,
uint16_t  Address 
)

Configures the slave address to be transmitted after start generation.

Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
Addressspecifies the slave address to be programmed.
Note
This function should be called before generating start condition.
Return values
None

Definition at line 524 of file stm32f30x_i2c.c.

void I2C_SlaveByteControlCmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Enables or disables the I2C slave byte control.

Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
NewStatenew state of the I2C slave byte control. This parameter can be: ENABLE or DISABLE.
Return values
None

Definition at line 499 of file stm32f30x_i2c.c.

void I2C_SMBusAlertCmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Enables or disables I2C SMBus alert.

Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
NewStatenew state of the I2Cx SMBus alert. This parameter can be: ENABLE or DISABLE.
Return values
None

Definition at line 951 of file stm32f30x_i2c.c.

void I2C_SMBusAlertConfig ( I2C_TypeDef I2Cx,
uint16_t  I2C_SMBusAlert 
)

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

Parameters
I2Cxwhere x can be 1, 2 or 3 to select the I2C peripheral.
I2C_SMBusAlertspecifies 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
Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
I2C_SMBusAlertspecifies 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 688 of file stm32f4xx_i2c.c.

void I2C_SoftwareResetCmd ( I2C_TypeDef I2Cx)

Enables or disables the specified I2C software reset.

Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
Return values
None

Definition at line 302 of file stm32f30x_i2c.c.

void I2C_SoftwareResetCmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Enables or disables the specified I2C software reset.

Note
When software reset is enabled, the I2C IOs are released (this can be useful to recover from bus errors).
Parameters
I2Cxwhere x can be 1, 2 or 3 to select the I2C peripheral.
NewStatenew state of the I2C software reset. This parameter can be: ENABLE or DISABLE.
Return values
None
Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
NewStatenew state of the I2C software reset. This parameter can be: ENABLE or DISABLE.
Return values
None

Definition at line 572 of file stm32f4xx_i2c.c.

void I2C_StopModeCmd ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Enables or disables I2C wakeup from stop mode.

Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
NewStatenew state of the I2Cx stop mode. This parameter can be: ENABLE or DISABLE.
Return values
None

Definition at line 385 of file stm32f30x_i2c.c.

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
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
Timeoutspecifies the TimeoutA to be programmed.
Return values
None

Definition at line 1052 of file stm32f30x_i2c.c.

void I2C_TimeoutBConfig ( I2C_TypeDef I2Cx,
uint16_t  Timeout 
)

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

Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
Timeoutspecifies the TimeoutB to be programmed.
Return values
None

Definition at line 1079 of file stm32f30x_i2c.c.

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
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
Addressspecifies the slave address to be programmed.
Number_Bytesspecifies the number of bytes to be programmed. This parameter must be a value between 0 and 255.
ReloadEndModenew 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.
StartStopModenew 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

Definition at line 880 of file stm32f30x_i2c.c.

void I2C_TransmitPEC ( I2C_TypeDef I2Cx,
FunctionalState  NewState 
)

Enables or disables the specified I2C PEC transfer.

Parameters
I2Cxwhere x can be 1, 2 or 3 to select the I2C peripheral.
NewStatenew state of the I2C PEC transmission. This parameter can be: ENABLE or DISABLE.
Return values
None
Parameters
I2Cxwhere x can be 1 or 2 to select the I2C peripheral.
NewStatenew state of the I2C PEC transmission. This parameter can be: ENABLE or DISABLE.
Return values
None

Definition at line 794 of file stm32f4xx_i2c.c.



rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Thu Apr 15 2021 05:07:55