您尚未登录。

楼主 #1 2020-04-08 16:44:19

chendong
会员
注册时间: 2019-07-22
已发帖子: 93
积分: 94

v3s i2c 写地址

大家好最近弄v3s 的i2c ,发现在内核对从地址是这么处理的
/ 7-1bits addr, xxxx_xxx0 /
addr = (i2c->msg[i2c->msg_idx].addr & 0x7f) << 1;
,这要是我的从地址是0x70 , 写的时候变成了0xe0, 没法控制设备啊。我把地址强制成0x70,就可以了,这什么意思?这驱动有问题?按理说不应该啊。

static void sunxi_i2c_addr_byte(struct sunxi_i2c *i2c)
{
unsigned char addr = 0;
unsigned char tmp = 0;

if (i2c->msg[i2c->msg_idx].flags & I2C_M_TEN) {
/ 0111_10xx,ten bits address--9:8bits /
tmp = 0x78 | ( ( (i2c->msg[i2c->msg_idx].addr)>>8 ) & 0x03);
addr = tmp << 1;//1111_0xx0
/ how about the second part of ten bits addr? Answer: deal at twi_core_process() /
}
else {
/ 7-1bits addr, xxxx_xxx0 /
addr = (i2c->msg[i2c->msg_idx].addr & 0x7f) << 1;
}

/ read, default value is write /
if (i2c->msg[i2c->msg_idx].flags & I2C_M_RD) {
addr |= 1;
}

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn


东莞哇酷科技有限公司开发