1

I have an application that I have cross-compiled for the USRP N310 that uses the TCA9548 I²C switch to read and write data to and from the TCA6408 I/O Expander on the daughterboard using the built-in Linux I2C driver. To do this, I've been following the tutorial Implementing I2C drivers in UserSpace. I've been able to test out this functionality successfully using the ZC706 embedded platform,however, I'm having issues reading data on the USRP platform. My code is the following

#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); 


} 

The printout I receive when running this application is a string error No such device or address when trying to read data from the I/O Expander. The slave address of the device is the 7 bit address of 010 0000 or hex 20 and the address of the input register is 0x00 according to the data sheet. At the moment, I'm unclear as to what's going wrong. I'm a bit of a newbie so I'm unsure of what to try next.

TCA9548 data sheet

TCA6408 data sheet

phuclv
  • 37,963
  • 15
  • 156
  • 475
  • 1
    Given that you have said that you are certain of the address then you know you are talking to it if you write its address on the bus and you get an ack. – Tom V Sep 29 '21 at 19:29
  • @TomV these functions I'm utilizing return a 0 when successful or a negative value when unsuccessful. Since the functions to open the adapter and set the slave address don't fail I'm assuming that I'm at least able to accomplish those things. – Tellrell White Sep 30 '21 at 16:09
  • And why you don't use the Linux kernel driver for your I/O expander? https://elixir.bootlin.com/linux/latest/source/drivers/gpio/gpio-pca953x.c#L103 – 0andriy Oct 02 '21 at 08:46

0 Answers0