This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

i2c with DM368

 

 

Dear all,

 

I am looking for tutorials/docs on how can i interface image sensors with DM368 using i2c.

Also if possible please point me to any docs/tutorials on how can i use i2c bus on DM368.

Thanks and Regards,

Mayank

  • if you want to write a kernel drive for your sensor, you can refer to mt9p031 driver on how to access the sensor through i2c.

    You can also write user space code to access i2c device. for example, writing to a i2c device:

    int i2c_write(unsigned char addr, unsigned char* buffer, int len){

       int result,fd;
       struct i2c_msg msg[1] = {
            { .addr = addr, .flags = 0, .buf = buffer, .len = len },
       };

       struct i2c_rdwr_ioctl_data ioctl_data = {
              .msgs = msg, .nmsgs = 0x01            
       };
     
       if(len<=0) return -1;
       fd=open("/dev/i2c-1",O_RDWR);
       if(fd<0){
          fprintf(stderr,"I2C: Failed to open device.\r\n"); 
          return -1;
       }
       result=ioctl(fd,I2C_RDWR,&ioctl_data);
       if(result<0){
          fprintf(stderr," I2C Write Failed: %s, addr=0x%02x cmd=0x%02x, write_len=%d\r\n",
              strerror( errno ), addr,buffer[0],len);
       }
       close(fd);
       return result;
    }