I want to drive SRF08 using I2C Philips' Style Adapter

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I made an I2C Philips' Style Adapter. I want to use it to drive a
SRF08. After insert 2 module i2c-dev and i2c-philips-par by commands:
       modprobe i2c-dev
       modprobe i2c-philips-par

I found 2 files in the /proc/bus folder: i2c and i2c-0. In the i2c
file I see this line:
       i2c-0     i2c      Philips' Style Adapter      Bit-shift Algorithm

But in i2c-0 file, I see nothing. I know that just because there is no
device register to this adapter. So I wrote a C program to open
/dev/i2c-0 file and want to register a SRF08 have address 0xE4 to the
adapter, this is the code:

#include <fcntl.h>
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
#include <stdio.h>
int main(int argc, char *argv){
 int file;
 int adapter_nr = 2;
 char filename[20];
 sprintf(filename,"/dev/i2c-0",adapter_nr);
 if ((file = open(filename,O_RDWR)) < 0) {
  printf("1_ERROR HANDLING; you can check errno to see what went wrong\n");
  exit(1); }

 int addr = 0xE4; 
if (ioctl(file,I2C_SLAVE,addr) < 0) {
  printf("2_ERROR HANDLING; you can check errno to see what went wrong\n");
  exit(1); }
 }


Openning i2c-0 file is OK. But i got the error message in the second
if clause. Please help me how to register a device to adapter, any
inserting module needed by this task? I'm waiting advises from all of
you. Thanks....

PS: My English is not good enough. Forgive me...

-- 
Shrike-list mailing list
Shrike-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/shrike-list

[Index of Archives]     [Fedora Users]     [Centos Users]     [Kernel Development]     [Red Hat Install]     [Red Hat Watch]     [Red Hat Development]     [Red Hat Phoebe Beta]     [Yosemite Forum]     [Fedora Discussion]     [Gimp]     [Stuff]     [Yosemite News]

  Powered by Linux