Camera读取ID方法总结

1.首先明确I2c读写函数访问register的数据位宽,是8bit还是16bit. 
2.其次明确power是高还是低有效。
3.在open时如果读id失败就重新设置一下相关gpio。




/*************************************************************************
* FUNCTION
*     GT2005Close
*
* DESCRIPTION
*     This function is to turn off sensor module power.
*
* PARAMETERS
*     None
*
* RETURNS
*     None
*
* GLOBALS AFFECTED
*
*************************************************************************/
UINT32 GT2005GetSensorID(UINT32 *sensorID)
{
     volatile signed char i;
     kal_uint16 sensor_id=0;
     mt_set_gpio_out( GPIO_CAMERA_CMRST_PIN, 1 );
     mDELAY(10);
     mt_set_gpio_out( GPIO_CAMERA_CMRST_PIN, 0 );
     mDELAY(10);
     mt_set_gpio_out( GPIO_CAMERA_CMRST_PIN, 1 );
    
     mt_set_gpio_out( GPIO_CAMERA_CMPDN1_PIN, 1 );//sub low action
     mDELAY(10);
     mt_set_gpio_out( GPIO_CAMERA_CMPDN_PIN, 1 );//main
     mDELAY(10);
//    
//          mt_set_gpio_out( GPIO_CAMERA_CMPDN1_PIN, 1 );
//          mDELAY(10);
     SENSORDB("yuanwei GT2005GetSensorID ");
     SENSORDB("yuanwei in GPIO_CAMERA_CMPDN_PIN=%d,GPIO_CAMERA_CMPDN1_PIN=%d\n",mt_get_gpio_out(GPIO_CAMERA_CMPDN_PIN),mt_get_gpio_out(GPIO_CAMERA_CMPDN1_PIN));
     for(i=0;i<3;i++)
     {
          sensor_id = (GT2005_read_cmos_sensor(0x0000) << 8) | GT2005_read_cmos_sensor(0x0001);
          printk("%s sensor_id=%x\n", __func__, sensor_id);
          if(sensor_id != GT2005_SENSOR_ID)
          {
               return ERROR_SENSOR_CONNECT_FAIL;
          }
     }
    
     return ERROR_NONE;
}

转载于:https://www.cnblogs.com/yuzaipiaofei/archive/2012/04/27/4124214.html

你可能感兴趣的:(Camera读取ID方法总结)