首页 > 解决方案 > 我是否需要从嵌入式平台上的 GPIO 设备“取消绑定”pca953x 驱动程序才能从设备中读取?

问题描述

我在从嵌入式设备(usrp n310)上的 GPIO 设备读取时遇到问题。i2cdetect为我尝试访问的特定设备提供“UU”,表明这些设备已被芯片占用。/sys/bus/i2c/drivers显示链接到这些设备的驱动程序是 pca953x。以前,我能够从 zc706 平台上的 GPIO 设备 (tca6416) 读取和写入,但是,在比较/sys/bus/i2c/drivers时,我看不到任何与该芯片相关的驱动程序。我正在使用的代码如下

#include "i2c_dev.hpp" 

int main()  
{ 
  int i2cfd; 
  __s32 num; 

  // Opening i2c adapter 6  
  printf("Opening bus adapter\n");
  i2cfd = open("/dev/i2c-6", O_RDWR); 
  if ( i2cfd < 0 ) {
    printf("Failed to open /dev/i2c-6: %s\n", strerror(errno));
    return 1;
  }

  // Instatiating three objects of IO_Expander class 
  IO_Expander dba; 

  // Reading data from the IO Expander
  printf("Setting slave address of device\n");
  if (ioctl(i2cfd, I2C_SLAVE, 0x20) < 0) {
    printf("Error setting slave address:%s\n", strerror(errno));
    return 1;
  }

  printf("Reading data from the IO Expander for DB-A Object\n");

  num = dba.read_data(i2cfd, 0x00);
  if (num < 0) {
    printf("Error reading data: %s\n", strerror(errno));
  } else {
    printf("The input value is %d\n", num);
  }

  printf("Leaving DB-A Object\n\n\n");

  // Closing the adapter
  close(i2cfd);
}

那么,由于这个 pca953x 驱动程序,我无法从 n310 平台上的 GPIO 设备读取吗?如果是这样,正确的方法是将 pca953x 驱动程序与设备“解除绑定”以便从中读取值吗?

标签: linux-kernellinux-device-driverembedded-linuxi2cusrp

解决方案


推荐阅读