Firefly开源社区

标题: i2c警示訊息 [打印本页]

作者: woody.lee    时间: 2016-9-5 19:32
标题: i2c警示訊息
<4>[15811.846689] rockchip_i2c 20056000.i2c: Warning: addr[0x0008] msg[0].scl_rate( = 3037725Khz) is too high!

請教大神, 何解??

作者: zhansb    时间: 2016-9-6 09:28
i2c通信的时候,把scl_rate配置上
作者: woody.lee    时间: 2016-9-6 09:46
我用下面的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__);
    }

請教大神, 何解??
作者: woody.lee    时间: 2016-9-6 11:07
參考 i2c-tools-3.1.2/tools/i2cget.c

    int res = i2c_smbus_read_byte_data(file, reg);

用這個也是可以的

持續不解@@
作者: xuwj2009    时间: 2017-2-25 11:25
rk i2c msg 添加了 变量scl_rate ,来设置速率! 执行i2c写不会有问题;读操作2个msg,在应该是结构体cp出问题了




欢迎光临 Firefly开源社区 (https://dev.t-firefly.com/) Powered by Discuz! X3.1