zoukankan      html  css  js  c++  java
  • 摄像头ov2685中关于sensor id 设置的相关的寄存器地址【转】

    本文转载自:http://blog.csdn.net/morixinguan/article/details/51220992

    OV2685 :

         CHIP_ID 

         address : 0x300A    default : 0x26

         address : 0x300B    default : 0x85

         address : 0x300C    defailt  : 0x00

    回到早上的话题,如果我想查看摄像头的ID,我的代码可以这么写,在GPL329A-sensor-ID设置那里有完整的代码,这里我只给出小部分:

    [cpp] view plain copy
     
     print?
    1. sensor_info.write_data[0] = 0x30;    
    2. sensor_info.write_data[1] = 0x0a;    
    3. sensor_info.write_size = 2;  
    4. sensor_info.read_size = 2;  
    5. ret = ioctl(fd, I2C_BUS_WRITE_READ, &sensor_info);  
    6. if(ret < 0)  
    7. {  
    8. <span style="white-space:pre">    </span>perror("ioctl set i2c arg ");  
    9.     continue;  
    10.  }    
    11.     readdevice = (sensor_info.read_data[0] << 8) + sensor_info.read_data[1];  
    12.   
    13.     //  if( readdevice == 0x2656)  
    14.     if(readdevice == 0x2685)  
    15.     {  
    16.         DEBUG("I2C_BUS_WRITE_READ data = 0x%02x ", readdevice);  
    17.         i = MAX_DEVICE + 1;  
    18.     <span style="white-space:pre">    </span>deviceno = 2;  
    19.     }  
    20.     else  
    21.     {  
    22.         printf("Error I2C_BUS_WRITE_READ data = 0x%02x ", readdevice);  
    23.     }  

    从代码上看:

    [cpp] view plain copy
     
     print?
    1. sensor_info.write_data[0] = 0x30;    
    2. sensor_info.write_data[1] = 0x0a;  

    这个结构体数组的含义就是为了存储这两个寄存器的值,然后后面通过I2C总线去读取地址所对应的值,如果读出来的值为0x2685,这就说明设备已经被驱动了,同时也读出了相应的ID号。

  • 相关阅读:
    hdoj 2586 How far away?(最近公共祖先)
    poj 1330 A-Nearest Common Ancestors
    心形图
    B1928 日期差值
    B1022 D进制的A+B
    B1009 说反话
    hihocoder 1498 签到
    51Nod 1082 与7无关的数
    51Nod 1015 水仙花数
    51Nod 1283 最小周长
  • 原文地址:https://www.cnblogs.com/zzb-Dream-90Time/p/7605389.html
Copyright © 2011-2022 走看看