Did you think of dynamic / static loading of the i2c driver?
1) dynamic: http://www.gevawebsolutions.com/wiki/index.php?
title=FB_General_Issues
2) static: uncomment //#undef  DYNAMIC_MAJOR_I2CDEV_NUMBER_ALLOC in 
i2c.c

Hope it helps...

--- In [email protected], Luca <[EMAIL PROTECTED]> wrote:
>
> 
> Hello to all, 
> 
> 
> I was trying to make to go the pcf8591 with the driver i2c of the
> kernel, but with outcome negative. Then I have changed the pin dell 
i2c
> from 0 to 1 I have put 6 for SDA and 7 for SCL therefore pin 38 and 
37
> of j6. I even enclose you the code I have forgotten something;) 
> 
> thanks 
> 
> 
> #include "stdio.h"
> #include "unistd.h" 
> #include "sys/types.h"
> #include "sys/stat.h"
> #include "fcntl.h"
> #include "sys/ioctl.h"
> #include "linux/i2c.h"
> #include "asm/etraxi2c.h"
> 
> #define ADDR 0x09
> 
> /*
> EXAMPLE usage:
> 
> i2c_arg = I2C_WRITEARG(STA013_WRITE_ADDR, reg, val);
> ioctl(fd, _IO(ETRAXI2C_IOCTYPE, I2C_WRITEREG), i2c_arg);
> 
> i2c_arg = I2C_READARG(STA013_READ_ADDR, reg);
> val = ioctl(fd, _IO(ETRAXI2C_IOCTYPE, I2C_READREG), i2c_arg);
> 
> */
> 
> int main(void) {
> int value;
> int ch, i2c_arg;
> 
> int i2c_fd = open("/dev/i2c", O_RDWR);
> if (!i2c_fd) return -1;
> 
> // PCF8591 address scheme
> // | 1 | 0 | 0 | 1 | A2 | A1 | A0 | R/W |
> // | i2c_fixed | i2c_addr | 1/0 |
> // ADDR
> int i2c_fixed=0x09;
> int i2c_addr=0x01;
> 
> printf("Reading from 4 ch 8 bit A/D converter PCF8591\n");
> 
> 
> for (ch =0; ch <=4 ; ch++){
> // Select the channel number 
> i2c_arg = I2C_WRITEARG(ADDR, (ADDR<<4)|(i2c_addr<<1)|0, ch);
> ioctl(i2c_fd, _IO(ETRAXI2C_IOCTYPE, I2C_WRITEREG), i2c_arg);
> 
> // Read the A/D value
> i2c_arg = I2C_READARG(ADDR, (ADDR<<4)|(i2c_addr<<1)|1);
> value = ioctl(i2c_fd, _IO(ETRAXI2C_IOCTYPE, I2C_READREG), i2c_arg);
> 
> // Show the voltage level
> printf("CH%d = %.2fv (%02X hex)\n",ch,value*0.012941,value);
> } 
> 
> 
> return 0;
> }
> 
> 
> 
> Chiacchiera con i tuoi amici in tempo reale! 
>  http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com
>


Reply via email to