|
@@ -12,7 +12,7 @@ void stm32_set_sda(void *data, rt_int32_t state)
|
|
void stm32_set_scl(void *data, rt_int32_t state)
|
|
void stm32_set_scl(void *data, rt_int32_t state)
|
|
{
|
|
{
|
|
if(state == 1)
|
|
if(state == 1)
|
|
- GPIO_SetBits(I2C1_GPIO , I2C1_GPIO_SCL); //GPIOB->BSRRL = I2C1_GPIO_SCL
|
|
|
|
|
|
+ GPIO_SetBits(I2C1_GPIO , I2C1_GPIO_SCL); //GPIOB->BSRRL = I2C1_GPIO_SCL
|
|
else if(state == 0)
|
|
else if(state == 0)
|
|
GPIO_ResetBits(I2C1_GPIO , I2C1_GPIO_SCL); //GPIOB->BSRRH = I2C1_GPIO_SCL
|
|
GPIO_ResetBits(I2C1_GPIO , I2C1_GPIO_SCL); //GPIOB->BSRRH = I2C1_GPIO_SCL
|
|
}
|
|
}
|
|
@@ -62,17 +62,17 @@ static void RCC_Configuration(void)
|
|
|
|
|
|
static void GPIO_Configuration(void)
|
|
static void GPIO_Configuration(void)
|
|
{
|
|
{
|
|
- GPIO_InitTypeDef GPIO_InitStructure;
|
|
|
|
- GPIO_InitStructure.GPIO_Pin = I2C1_GPIO_SDA | I2C1_GPIO_SCL;
|
|
|
|
- GPIO_InitStructure.GPIO_Mode =GPIO_Mode_Out_OD ;
|
|
|
|
- GPIO_InitStructure.GPIO_Speed =GPIO_Speed_50MHz;
|
|
|
|
- GPIO_Init(I2C1_GPIO, &GPIO_InitStructure);
|
|
|
|
|
|
+ GPIO_InitTypeDef GPIO_InitStructure;
|
|
|
|
+ GPIO_InitStructure.GPIO_Pin = I2C1_GPIO_SDA | I2C1_GPIO_SCL;
|
|
|
|
+ GPIO_InitStructure.GPIO_Mode =GPIO_Mode_Out_OD ;
|
|
|
|
+ GPIO_InitStructure.GPIO_Speed =GPIO_Speed_50MHz;
|
|
|
|
+ GPIO_Init(I2C1_GPIO, &GPIO_InitStructure);
|
|
}
|
|
}
|
|
|
|
|
|
int rt_hw_i2c_init(void)
|
|
int rt_hw_i2c_init(void)
|
|
{
|
|
{
|
|
static struct rt_i2c_bus_device stm32_i2c;
|
|
static struct rt_i2c_bus_device stm32_i2c;
|
|
-
|
|
|
|
|
|
+
|
|
RCC_Configuration();
|
|
RCC_Configuration();
|
|
GPIO_Configuration();
|
|
GPIO_Configuration();
|
|
|
|
|