6 * @defgroup luatos_device_i2c I2C接口
16 int luat_i2c_exist(int id
);
25 int luat_i2c_setup(int id
, int speed
);
34 int luat_i2c_close(int id
);
46 int luat_i2c_send(int id
, int addr
, void* buff
, size_t len
, uint8_t stop
);
57 int luat_i2c_recv(int id
, int addr
, void* buff
, size_t len
);
70 int luat_i2c_write_reg(int id
, int addr
, int reg
, void* buff
, size_t len
, uint8_t stop
);
81 int luat_i2c_read_reg(int id
, int addr
, int reg
, void* buff
, size_t len
);
88 * @param reg_len 寄存器长度
89 * @param buff 如果reg,reg_len 不为NULL,buff 为读的数据保存缓冲区,反之为写的缓冲区
93 int luat_i2c_transfer(int id
, int addr
, uint8_t *reg
, size_t reg_len
, uint8_t *buff
, size_t len
);
100 * @param is_read 是否为读写
102 * @param reg_len 寄存器长度
103 * @param buff 如果reg,reg_len 不为NULL,buff 为读的数据保存缓冲区,反之为写的缓冲区
107 * @param pParam 回调函数参数
110 int luat_i2c_no_block_transfer(int id
, int addr
, uint8_t is_read
, uint8_t *reg
, size_t reg_len
, uint8_t *buff
, size_t len
, uint16_t Toms
, void *CB
, void *pParam
);
119 int luat_i2c_set_iomux(int id
, uint8_t value
);
121 int luat_i2c_set_polling_mode(int id
, uint8_t on_off
);
124 #define LUAT_EI2C_TYPE "EI2C*"
126 typedef struct luat_ei2c
{
130 } luat_ei2c_t
;//软件i2c
132 void i2c_soft_start(luat_ei2c_t
*ei2c
);
133 char i2c_soft_recv(luat_ei2c_t
*ei2c
, unsigned char addr
, char *buff
, size_t len
);
134 char i2c_soft_send(luat_ei2c_t
*ei2c
, unsigned char addr
, char *data
, size_t len
, uint8_t stop
);
137 #define toei2c(L) ((luat_ei2c_t *)luaL_checkudata(L, 1, LUAT_EI2C_TYPE))