183#define RT_I2C_WR 0x0000
184#define RT_I2C_RD (1u << 0)
185#define RT_I2C_ADDR_10BIT (1u << 2)
186#define RT_I2C_NO_START (1u << 4)
187#define RT_I2C_IGNORE_NACK (1u << 5)
188#define RT_I2C_NO_READ_ACK (1u << 6)
189#define RT_I2C_NO_STOP (1u << 7)
191#define RT_I2C_DEV_CTRL_10BIT (RT_DEVICE_CTRL_BASE(I2CBUS) + 0x01)
192#define RT_I2C_DEV_CTRL_ADDR (RT_DEVICE_CTRL_BASE(I2CBUS) + 0x02)
193#define RT_I2C_DEV_CTRL_TIMEOUT (RT_DEVICE_CTRL_BASE(I2CBUS) + 0x03)
194#define RT_I2C_DEV_CTRL_RW (RT_DEVICE_CTRL_BASE(I2CBUS) + 0x04)
195#define RT_I2C_DEV_CTRL_CLK (RT_DEVICE_CTRL_BASE(I2CBUS) + 0x05)
196#define RT_I2C_DEV_CTRL_UNLOCK (RT_DEVICE_CTRL_BASE(I2CBUS) + 0x06)
197#define RT_I2C_DEV_CTRL_GET_STATE (RT_DEVICE_CTRL_BASE(I2CBUS) + 0x07)
198#define RT_I2C_DEV_CTRL_GET_MODE (RT_DEVICE_CTRL_BASE(I2CBUS) + 0x08)
199#define RT_I2C_DEV_CTRL_GET_ERROR (RT_DEVICE_CTRL_BASE(I2CBUS) + 0x09)
262 const struct rt_i2c_device_id *id;
270struct rt_i2c_device_id
278 struct rt_driver parent;
280 const struct rt_i2c_device_id *ids;
281 const struct rt_ofw_node_id *ofw_ids;
283 rt_err_t (*probe)(
struct rt_i2c_client *client);
284 rt_err_t (*remove)(
struct rt_i2c_client *client);
285 rt_err_t (*shutdown)(
struct rt_i2c_client *client);
288rt_err_t rt_i2c_driver_register(
struct rt_i2c_driver *driver);
291#define RT_I2C_DRIVER_EXPORT(driver) RT_DRIVER_EXPORT(driver, i2c, BUILIN)
314 const char *bus_name);
rt_err_t rt_i2c_bus_device_register(struct rt_i2c_bus_device *bus, const char *bus_name)
I2C Bus Device Register
rt_err_t rt_i2c_bus_device_device_init(struct rt_i2c_bus_device *bus, const char *name)
I2C Bus Device Initialization
rt_ssize_t rt_i2c_master_send(struct rt_i2c_bus_device *bus, rt_uint16_t addr, rt_uint16_t flags, const rt_uint8_t *buf, rt_uint32_t count)
I2C Master Send
rt_ssize_t rt_i2c_master_recv(struct rt_i2c_bus_device *bus, rt_uint16_t addr, rt_uint16_t flags, rt_uint8_t *buf, rt_uint32_t count)
I2C Master Receive
struct rt_i2c_bus_device * rt_i2c_bus_device_find(const char *bus_name)
I2C Bus Device Find
rt_err_t rt_i2c_control(struct rt_i2c_bus_device *bus, int cmd, void *args)
I2C Control
rt_ssize_t rt_i2c_transfer(struct rt_i2c_bus_device *bus, struct rt_i2c_msg msgs[], rt_uint32_t num)
I2C data transmission.
rt_inline rt_err_t rt_i2c_bus_unlock(struct rt_i2c_bus_device *bus)
rt_inline rt_err_t rt_i2c_bus_lock(struct rt_i2c_bus_device *bus, rt_tick_t timeout)
rt_err_t rt_mutex_take(rt_mutex_t mutex, rt_int32_t time)
rt_err_t rt_mutex_release(rt_mutex_t mutex)
This function will release a mutex. If there is thread suspended on the mutex, the thread will be res...
unsigned short rt_uint16_t
I2C Bus Device Operations
rt_err_t(* i2c_bus_control)(struct rt_i2c_bus_device *bus, int cmd, void *args)
rt_ssize_t(* master_xfer)(struct rt_i2c_bus_device *bus, struct rt_i2c_msg msgs[], rt_uint32_t num)
rt_ssize_t(* slave_xfer)(struct rt_i2c_bus_device *bus, struct rt_i2c_msg msgs[], rt_uint32_t num)
const struct rt_i2c_bus_device_ops * ops
struct rt_i2c_bus_device * bus