74 lines
1.9 KiB
C
74 lines
1.9 KiB
C
/*
|
|
* Copyright (c) 2006-2018, RT-Thread Development Team
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*
|
|
* Change Logs:
|
|
* Date Author Notes
|
|
* 2018-11-08 balanceTWK first version
|
|
*/
|
|
|
|
#ifndef __DRV_I2C__
|
|
#define __DRV_I2C__
|
|
|
|
#include <rtthread.h>
|
|
#include <rthw.h>
|
|
#include <rtdevice.h>
|
|
|
|
#ifdef RT_USING_I2C
|
|
|
|
/* stm32 config class */
|
|
struct stm32_soft_i2c_config
|
|
{
|
|
rt_uint8_t scl;
|
|
rt_uint8_t sda;
|
|
const char *bus_name;
|
|
};
|
|
/* stm32 i2c dirver class */
|
|
struct stm32_i2c
|
|
{
|
|
struct rt_i2c_bit_ops ops;
|
|
struct rt_i2c_bus_device i2c2_bus;
|
|
};
|
|
|
|
#ifdef BSP_USING_I2C1
|
|
#define I2C1_BUS_CONFIG \
|
|
{ \
|
|
.scl = BSP_I2C1_SCL_PIN, \
|
|
.sda = BSP_I2C1_SDA_PIN, \
|
|
.bus_name = "i2c1", \
|
|
}
|
|
#endif
|
|
|
|
#ifdef BSP_USING_I2C2
|
|
#define I2C2_BUS_CONFIG \
|
|
{ \
|
|
.scl = BSP_I2C2_SCL_PIN, \
|
|
.sda = BSP_I2C2_SDA_PIN, \
|
|
.bus_name = "i2c2", \
|
|
}
|
|
#endif
|
|
|
|
#ifdef BSP_USING_I2C3
|
|
#define I2C3_BUS_CONFIG \
|
|
{ \
|
|
.scl = BSP_I2C3_SCL_PIN, \
|
|
.sda = BSP_I2C3_SDA_PIN, \
|
|
.bus_name = "i2c3", \
|
|
}
|
|
#endif
|
|
|
|
#ifdef BSP_USING_I2C4
|
|
#define I2C4_BUS_CONFIG \
|
|
{ \
|
|
.scl = BSP_I2C4_SCL_PIN, \
|
|
.sda = BSP_I2C4_SDA_PIN, \
|
|
.bus_name = "i2c4", \
|
|
}
|
|
#endif
|
|
int rt_hw_i2c_init(void);
|
|
|
|
#endif
|
|
|
|
#endif /* RT_USING_I2C */
|