luat_soc_sdk_2024 V1.0
luat_i2c.h
浏览该文件的文档.
1#ifndef LUAT_I2C_H
2#define LUAT_I2C_H
3
4#include "luat_base.h"
16int luat_i2c_exist(int id);
17
25int luat_i2c_setup(int id, int speed);
26
34int luat_i2c_close(int id);
46int luat_i2c_send(int id, int addr, void* buff, size_t len, uint8_t stop);
47
57int luat_i2c_recv(int id, int addr, void* buff, size_t len);
58
70int luat_i2c_write_reg(int id, int addr, int reg, void* buff, size_t len, uint8_t stop);
81int luat_i2c_read_reg(int id, int addr, int reg, void* buff, size_t len);
93int luat_i2c_transfer(int id, int addr, uint8_t *reg, size_t reg_len, uint8_t *buff, size_t len);
94
110int 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);
111
119int luat_i2c_set_iomux(int id, uint8_t value);
120
121int luat_i2c_set_polling_mode(int id, uint8_t on_off);
124#define LUAT_EI2C_TYPE "EI2C*"
125
126typedef struct luat_ei2c {
127 int8_t sda;
128 int8_t scl;
129 int16_t udelay;
130} luat_ei2c_t;//软件i2c
131
133char i2c_soft_recv(luat_ei2c_t *ei2c, unsigned char addr, char *buff, size_t len);
134char i2c_soft_send(luat_ei2c_t *ei2c, unsigned char addr, char *data, size_t len, uint8_t stop);
135
136
137#define toei2c(L) ((luat_ei2c_t *)luaL_checkudata(L, 1, LUAT_EI2C_TYPE))
138
139#endif
int luat_i2c_transfer(int id, int addr, uint8_t *reg, size_t reg_len, uint8_t *buff, size_t len)
I2C 收发数据
int luat_i2c_write_reg(int id, int addr, int reg, void *buff, size_t len, uint8_t stop)
I2C 写寄存器
int luat_i2c_read_reg(int id, int addr, int reg, void *buff, size_t len)
I2C 读寄存器
int luat_i2c_exist(int id)
检查i2c是否存在
int luat_i2c_setup(int id, int speed)
初始化i2c
int luat_i2c_set_polling_mode(int id, uint8_t on_off)
int luat_i2c_send(int id, int addr, void *buff, size_t len, uint8_t stop)
I2C 发送数据
int luat_i2c_set_iomux(int id, uint8_t value)
设置i2c复用
int luat_i2c_close(int id)
关闭 i2c
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)
I2C 收发数据(异步)
int luat_i2c_recv(int id, int addr, void *buff, size_t len)
I2C 接受数据
char i2c_soft_recv(luat_ei2c_t *ei2c, unsigned char addr, char *buff, size_t len)
void i2c_soft_start(luat_ei2c_t *ei2c)
struct luat_ei2c luat_ei2c_t
char i2c_soft_send(luat_ei2c_t *ei2c, unsigned char addr, char *data, size_t len, uint8_t stop)
int16_t udelay