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

Re: RE: programming I2C



Hi Pieter,  
  this is my code:  
  
#include <string.h>  
#include <stdlib.h>  
#include <stdio.h>  
#include <fcntl.h>  
#include <time.h>  
#include <linux/i2c.h>  
#include <linux/i2c-dev.h>  
  
int main(void)  
{  
  int  descriptor;  
  int  direccion_adaptador = 52; // i2c address device  
  
  // open i2c device  
  sprintf(fichero,"/dev/i2c");  
  if ((descriptor = open(fichero,O_RDWR)) < 0)  
  {  
    printf("Error al abrir el dispositivo %s\n",fichero);  
    exit(1);  
  }  
  
  // setting the address  
  if (ioctl(descriptor,I2C_SLAVE,direccion_adaptador) < 0)  
  {  
    printf("Error al especificar direccion del dispositivo i2c\n");  
    exit(1);  
  }  
  return 0;  
}  
  
  
This works until "setting the address". Here it gives error.  
 
Maybe i have setting wrong the i2c configuration. 
  
thanks,  
   Francisco