Firefly开源社区

i2c警示訊息

350

积分

0

威望

0

贡献

技术达人

Rank: 2

积分
350
发表于 2016-9-5 19:32:47     
<4>[15811.846689] rockchip_i2c 20056000.i2c: Warning: addr[0x0008] msg[0].scl_rate( = 3037725Khz) is too high!

請教大神, 何解??
回复

使用道具 举报

2918

积分

56

威望

46

贡献

高级创客

Rank: 6Rank: 6

积分
2918

优秀版主论坛元老

发表于 2016-9-6 09:28:36     
i2c通信的时候,把scl_rate配置上
回复

使用道具 举报

350

积分

0

威望

0

贡献

技术达人

Rank: 2

积分
350
发表于 2016-9-6 09:46:24     
我用下面的func去讀i2c1的device reg內容,

static int get_i2c_register(int file,
                            unsigned char addr,
                            unsigned char reg,
                            unsigned char *val) {
    unsigned char inbuf, outbuf = 0x01;
    struct i2c_rdwr_ioctl_data packets;
    struct i2c_msg messages[2];

    /*
     * In order to read a register, we first do a "dummy write" by writing
     * 0 bytes to the register we want to read from.  This is similar to
     * the packet in set_i2c_register, except it's 1 byte rather than 2.
     */
    outbuf = reg;
    messages[0].addr  = addr;
    messages[0].flags = 0;
    messages[0].len   = sizeof(outbuf);
    messages[0].buf   = &outbuf;

    /* The data will get returned in this structure */
    messages[1].addr  = addr;
    messages[1].flags = I2C_M_RD/* | I2C_M_NOSTART*/;
    messages[1].len   = sizeof(inbuf);
    messages[1].buf   = &inbuf;

    /* Send the request to the kernel and get the result back */
    packets.msgs      = messages;
    packets.nmsgs     = 2;
    if(ioctl(file, I2C_RDWR, &packets) < 0) {
        perror("Unable to send data");
        return 1;
    }
    *val = inbuf;

    return 0;
}
就會印
<4>[15811.846689] rockchip_i2c 20056000.i2c: Warning: addr[0x0008] msg[0].scl_rate( = 3037725Khz) is too high!
或是
<4>[  463.032272] rockchip_i2c 20056000.i2c: Warning: addr[0x0008] msg[0].scl_rate( = 0Khz) is too low!
==========================分隔線===============================
但是, 用 read 就不會印訊息
    if (read(i2c1_fd, &dat, 1) != 1)
    {
      /* ERROR HANDLING: i2c transaction failed */
      printf("%s %d FAIL @ i2c-1 read\n", __func__, __LINE__);
    }

請教大神, 何解??
回复

使用道具 举报

350

积分

0

威望

0

贡献

技术达人

Rank: 2

积分
350
发表于 2016-9-6 11:07:15     
參考 i2c-tools-3.1.2/tools/i2cget.c

    int res = i2c_smbus_read_byte_data(file, reg);

用這個也是可以的

持續不解@@
回复

使用道具 举报

34

积分

0

威望

0

贡献

游客

积分
34
发表于 2017-2-25 11:25:35     
rk i2c msg 添加了 变量scl_rate ,来设置速率! 执行i2c写不会有问题;读操作2个msg,在应该是结构体cp出问题了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

友情链接 : 爱板网 电子发烧友论坛 云汉电子社区 粤ICP备14022046号-2
快速回复 返回顶部 返回列表