Developing the I2C driver
Let’s develop the I2C driver. Create a copy of your previous project in your IDE and rename this copied project I2C
. Next, create a new file named i2c.c
in the Src
folder and another file named i2c.h
in the Inc
folder.
The initialization function
Let’s populate the i2c.c
file, starting with the macros and initialization function:
#include "stm32f4xx.h" #define GPIOBEN (1U<<1) #define I2C1EN (1U<<21) #define I2C_100KHZ 80 #define SD_MODE_MAX_RISE_TIME 17 #define CR1_PE (1U<...