Inter-integrated circuit interface (I2C)
ï€ Connect the pin to the desired peripherals' Alternate Function (AF) using
GPIO_PinAFConfig() function.
ï€ Configure the desired pin in alternate function by: GPIO_InitStruct->GPIO_Mode
= GPIO_Mode_AF
ï€ Select the type, OpenDrain and speed via GPIO_PuPd, GPIO_OType and
GPIO_Speed members
ï€ Call GPIO_Init() function.
4. Program the Mode, Timing , Own address, Ack and Acknowledged Address using the
I2C_Init() function.
5. Optionally you can enable/configure the following parameters without re-initialization
(i.e there is no need to call again I2C_Init() function):
ï€ Enable the acknowledge feature using I2C_AcknowledgeConfig() function.
ï€ Enable the dual addressing mode using I2C_DualAddressCmd() function.
ï€ Enable the general call using the I2C_GeneralCallCmd() function.
ï€ Enable the clock stretching using I2C_StretchClockCmd() function.
ï€ Enable the PEC Calculation using I2C_CalculatePEC() function.
ï€ For SMBus Mode:
ï€ Enable the SMBusAlert pin using I2C_SMBusAlertCmd() function.
6. Enable the NVIC and the corresponding interrupt using the function I2C_ITConfig() if
you need to use interrupt mode.
7. When using the DMA mode
ï€ Configure the DMA using DMA_Init() function.
ï€ Active the needed channel Request using I2C_DMACmd() function.
8. Enable the I2C using the I2C_Cmd() function.
9. Enable the DMA using the DMA_Cmd() function when using DMA mode in the
transfers.
When using I2C in Fast Mode Plus, SCL and SDA pin 20mA current drive
capability must be enabled by setting the driving capability control bit in SYSCFG.
13.2.2 Initialization and Configuration functions
This section provides a set of functions allowing to initialize the I2C Mode, I2C Timing, I2C
filters, I2C Addressing mode, I2C OwnAddress1.
The I2C_Init() function follows the I2C configuration procedures (these procedures are
available in reference manual).
When the Software Reset is performed using I2C_SoftwareResetCmd() function, the
internal states machines are reset and communication control bits, as well as status bits
come back to their reset value.
Before enabling Stop mode using I2C_StopModeCmd() I2C Clock source must be set to
HSI and Digital filters must be disabled.
Before enabling Own Address 2 via I2C_DualAddressCmd() function, OA2 and mask
should be configured using I2C_OwnAddress2Config() function.
I2C_SlaveByteControlCmd() enable Slave byte control that allow user to get control of
each byte in slave mode when NBYTES is set to 0x01.
ï‚· I2C_DeInit()
ï‚· I2C_Init()
ï‚· I2C_StructInit()