一.IIC读写接口
/* bh1750读数据 */
static int bh1750_read_regs(struct bh1750_device *dev, void *val, int len)
{int ret = 0;struct i2c_client *client = (struct i2c_client *)dev->private_data; struct i2c_msg msgs[1] = {[0] = { //寄存器的值.addr = client->addr,.flags = I2C_M_RD,.buf = val,.len = len,}};ret = i2c_transfer(client->adapter, msgs, 1);if (ret != 1) {printk("i2c rd failed=%d len=%d\n",ret, len);ret = -EINVAL;} else {ret = 0;}return ret;
}/* bh1750写数据 */
static int bh1750_write_regs(struct bh1750_device *dev, u8 *buf, u8 len)
{struct