@@ -28,13 +28,13 @@ void i2cInit()
|
||||
I2C_DeInit(I2C);
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_InitStructure.GPIO_Pin = I2C_GPIO_PIN_WP;
|
||||
GPIO_InitStructure.GPIO_Pin = I2C_WP_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
||||
GPIO_Init(I2C_GPIO, &GPIO_InitStructure);
|
||||
GPIO_ResetBits(I2C_GPIO, I2C_GPIO_PIN_WP);
|
||||
GPIO_Init(I2C_WP_GPIO, &GPIO_InitStructure);
|
||||
GPIO_ResetBits(I2C_WP_GPIO, I2C_WP_GPIO_PIN);
|
||||
|
||||
I2C_InitTypeDef I2C_InitStructure;
|
||||
I2C_InitStructure.I2C_ClockSpeed = I2C_SPEED;
|
||||
@@ -46,15 +46,15 @@ void i2cInit()
|
||||
I2C_Init(I2C, &I2C_InitStructure);
|
||||
I2C_Cmd(I2C, ENABLE);
|
||||
|
||||
GPIO_PinAFConfig(I2C_GPIO, I2C_SCL_GPIO_PinSource, I2C_GPIO_AF);
|
||||
GPIO_PinAFConfig(I2C_GPIO, I2C_SDA_GPIO_PinSource, I2C_GPIO_AF);
|
||||
GPIO_PinAFConfig(I2C_SPI_GPIO, I2C_SCL_GPIO_PinSource, I2C_GPIO_AF);
|
||||
GPIO_PinAFConfig(I2C_SPI_GPIO, I2C_SDA_GPIO_PinSource, I2C_GPIO_AF);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = I2C_SCL_GPIO_PIN | I2C_SDA_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
||||
GPIO_Init(I2C_GPIO, &GPIO_InitStructure);
|
||||
GPIO_Init(I2C_SPI_GPIO, &GPIO_InitStructure);
|
||||
}
|
||||
|
||||
#define I2C_TIMEOUT_MAX 1000
|
||||
|
||||
Reference in New Issue
Block a user