添加AHT10温湿度传感器无法通讯

本帖最后由 kiswih 于 2019-10-29 11:01 编辑

使用AHT10温湿度传感器接入在AIO-3399C(AI)的I2C7号通道,设备寄存器地址是0x38,但是我调用i2c_master_send函数时返回-6(没有设备)错误,请问各位大神我应该如何正确使用呢?
DTS配置如下:

&i2c7 {
     status = "okay";

     aht10: aht10@38 {
              status = "okay";
              compatible = "thinary,aht10";
              reg = <0x38>;
      };
};

驱动代码:

static AHT10_R writeandread(const const char *cmd, size_t cmdsize, uint8_t *buffer, int readsize)
{
    int rtn;
    struct i2c_client *client = this_client;
    if (!client)
        return AHT10_BAD;

    rtn = i2c_master_send(client, cmd, cmdsize); //返回-6
    if (rtn != cmdsize)
    {
        printk("ERROR sending command %d\n", rtn);
        return AHT10_WRITE_FAILED;
    }

    if (readsize > 0)
    {
        mdelay(100);
        rtn = i2c_master_recv(client, buffer, readsize);
        if (rtn < readsize)
            return AHT10_READ_FAILED;
    }
    return AHT10_OK;
}