I've attached the code that I fail to compile.
--
Rafael Rodr�guez Velilla [EMAIL PROTECTED]
Telef�nica I+D http://www.tid.es
Telf: +34 - 91 337 4270
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
int main(void)
{
int file;
int addr = 0x54; // The I2C address
__u8 registro = 0; // Device register to access
__s32 res;
char buf[10];
int adapter_nr = 0; /* probably dynamically determined */
char filename[20];
sprintf(filename,"/dev/i2c-%d",adapter_nr);
if ((file = open(filename,O_RDWR)) < 0) {
/* ERROR HANDLING; you can check errno to see what went wrong */
printf("Error al abrir el dispositivo\n");
exit(1);
}
if (ioctl(file,I2C_SLAVE,addr) < 0) {
/* ERROR HANDLING; you can check errno to see what went wrong */
printf("Error al n");
exit(1);
}
for (registro=0;registro<=0x18;registro++) {
res = i2c_smbus_read_byte_data(file,registro);
if (res < 0) {
/* ERROR HANDLING: i2c transaction failed */
printf("Falla al leer el registro %d\n",registro);
} else {
printf("Registro %d = %d\n",registro,res);
/* res contains the read word */
}
}
close (file);
}