Firefly开源社区

打印 上一主题 下一主题

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

48

积分

0

威望

0

贡献

技术小白

积分
48

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

发表于 2019-10-29 11:00:10      浏览:3079 | 回复:0        打印      只看该作者   [复制链接] 楼主
本帖最后由 kiswih 于 2019-10-29 11:01 编辑

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

  3.      aht10: aht10@38 {
  4.               status = "okay";
  5.               compatible = "thinary,aht10";
  6.               reg = <0x38>;
  7.       };
  8. };
复制代码

驱动代码:
  1. static AHT10_R writeandread(const const char *cmd, size_t cmdsize, uint8_t *buffer, int readsize)
  2. {
  3.     int rtn;
  4.     struct i2c_client *client = this_client;
  5.     if (!client)
  6.         return AHT10_BAD;

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

  13.     if (readsize > 0)
  14.     {
  15.         mdelay(100);
  16.         rtn = i2c_master_recv(client, buffer, readsize);
  17.         if (rtn < readsize)
  18.             return AHT10_READ_FAILED;
  19.     }
  20.     return AHT10_OK;
  21. }
复制代码




回复

使用道具 举报

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

本版积分规则

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