⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sensor.c

📁 Vc0558 backend IC COMS sensor drive program
💻 C
📖 第 1 页 / 共 5 页
字号:
	{                         
		0x0, sizeof(IspRegVal) / sizeof(V558_SENSORREGVALUE), 
		IspRegVal,        
		{                 
			//tgt, yfldstp,lck,ulck,gain,gadly,gmax,gainrange[4],yfldmstp,steptime,inlck, gmin, etdem, etnum,reserved1,2,3;
			{0x80, 0x40, 0x0a, 0x14, 0x60, 1, 0xe0, {0x20, 0x20, 0xb, 0x10}, 0x20, 4, 0, 0x20, 4, 3, 0, 0, 0},	//ae
			//flkcnt,flklinemode,flkstep,flklst,outthd,lighttype,freqtype,timeinout,reserved1,2
			{0x39   ,0x1        ,0x0    ,0xd0  ,3     ,0        ,FREQ    , 98, 0, 0},	//aflk
			//enae,enflk,intfrq,maxexp,defexp,minexp,exppoint,dpcthd,enlight,reserved1,2
			1, AUTO_FLK, 0     ,2000  ,400   ,80    ,1000    ,1000    ,1      ,0,0
		},                
		{
			32, 32 //brightness
		},
		{
			0x00,0x13,0x38,0x59,0x79,0x92,0xa7,0xb9,0xc8,0xd4,0xdf,0xe7,0xee,0xf4,0xf9,0xfc,0xff	//gamma table
		}
	}                         
};                                
                                  
/********************************************************************************
  Description:	Write sensor register to change exposure time
  Parameter: t -- exposure time clock num 
*********************************************************************************/
void V558_SifSetSnrTime(UINT8 freqtype, UINT32 t)
{
	UINT16 uTemp = 0;

	V558_I2C_BATCH AeData;

	uTemp = (UINT16)(t/900); 
	AeData.RegBytes = 2;
	AeData.RegAddr = 0x1a;
	AeData.RegVal[0]= (UINT8)(uTemp>>8);
	AeData.RegVal[1]= (UINT8)uTemp;
	V558_SifI2cAeBatch(1, &AeData);
}

/********************************************************************************
  Description:	Write sensor register when change freq
  Parameter: freqflag -- freq type (0)50hz,else 60hz 
*********************************************************************************/
void V558_SifSetFlkParam(UINT8 freqflag)
{
}
                                  
#endif                            



#if SELECT_PIXART302BCW_BAYER

const V558_SENSORREGVALUE	SifRegVal[] =
{
//	{0x800, 0x20,	1},
//	{0x800, 0x22,	1},
//	{0x805, 0x00,	0},
//	{0x806, 0x01,	0},
	{0x801, 0x05,	0},
	{0x803, 0x1b,	0},
	{0x804, 0x01,	0},
	{0x814, 0x00,	0},
	{0x815, 0x01,	0},
	{0x816, 0x02,	0},
	{0x817, 0x7f,	0},
	{0x821, 0x04,	0},
	{0x823, 0xe4,	0},
	{0x81d, 0x50,	0},
	{0x81f, 0x52,	0},

	{0x840, 0x01,	0},
	{0x841, 0xd0,	0},
	{0x842, 0x01,	0},
	{0x843, 0xe0,	0}

//	{0x800, 0x20,	0}
};

const V558_SENSORREGVALUE	SensorRegVal[] =
{
	{0x22,	0x02,	1},
	{0x21,	0x04,	1},
	
	{0x02,	0x02,	1},
	{0x03,	0xad,	1},
	{0x04,	0x07,	1},
	{0x05,	0x23,	1},
	{0x07,	0x05,	1},
	{0x09,	0x02,	1},
	
	{0x0c,	0x06,	1},
	{0x0d,	0x01,	1},
	{0x10,	0x04,	1},
	{0x12,	0x07,	1},

	{0x19,	0x03,	1},
	
	{0x1b,	0x03,	1},
	{0x1c,	0xa0,	1},
	{0x1d,	0x01,	1},
	{0x1e,	0xf1,	1},
	{0x21,	0x0c,	1},
	{0x22,	0x10,	1},
	{0x23,	0x00,	1},
	
//	{0x0e,	0x00,	1},
//	{0x0f,	0x3c,	1},

	{0x26,	0x02,	1},
	{0x27,	0x22,	1},
	{0x28,	0xcb,	1},
	{0x29,	0x90,	1},
	{0x2a,	0x26,	1},
	{0x2b,	0x70,	1},
	{0x2c,	0x04,	1},
	{0x2d,	0x00,	1},
	
	{0x11,	0x01,	0},		
};

const V558_SENSORREGVALUE	IspRegVal[] =
{
	{0x2000,	0x31,	0},
	{0x2001,	0x7d,	0},
	{0x2027,	0x20,	0},
	{0x2026,	0x70,	0},
	{0x200a,	0x40,	0},
	{0x200b,	0x60,	0},
	{0x200c,	0x05,	0},
	{0x200d,	0x0f,	0},
	{0x200e,	0x05,	0},
	{0x200f,	0x0f,	0},
	{0x2022,	0x40,	0},
	{0x2023,	0x40,	0},
	{0x2024,	0x40,	0},

	{0x202c,	0x46,	0},
	{0x202d,	0xfd,	0},
	{0x202e,	0xfd,	0},
	{0x202f,	0xfd,	0},
	{0x2030,	0x46,	0},
	{0x2031,	0xfd,	0},
	{0x2032,	0xfd,	0},
	{0x2033,	0xfd,	0},
	{0x2034,	0x46,	0},

	{0x208b,	0xff,	0},
	{0x2081,	0x01,	0}
};                                
                                  
const V558_SENSORINFO SensorInfo =      
{                                 
	"Pixart302BCW bayer mode",   
	{640, 480},               
	0,	//bayer mode
	0x1,	//pixel rate
	0x0,	//sensor mast clock count
	12000,	//sif clock
	V558_SNRC_I2C,            
	PIXART302BCW_BAYER,          
	{0,0,0,0,0},	//PwrOn,SnrEn,PltEn,PltMd,SnrRe              
	{sizeof(SifRegVal) / sizeof(V558_SENSORREGVALUE), SifRegVal},
	{0, 0x80, 0, sizeof(SensorRegVal) / sizeof(V558_SENSORREGVALUE), SensorRegVal},
	{                         
		0x0, sizeof(IspRegVal) / sizeof(V558_SENSORREGVALUE), 
		IspRegVal,        
		{                 
			//tgt, yfldstp,lck,ulck,gain,gadly,gmax,gainrange[4],yfldmstp,steptime,inlck, gmin, etdem, etnum,reserved1,2,3;
			{0x80, 0x40, 0x0a, 0x14, 0x70, 1, 0xe0, {0x20, 0x20, 0xb, 0x10}, 0x20, 4, 8, 0x20, 8, 7, 0, 0, 0},	//ae
			//flkcnt,flklinemode,flkstep,flklst,outthd,lighttype,freqtype,timeinout,reserved1,2
			{0x39   ,0x1        ,0x0    ,0xd0  ,3     ,0        ,FREQ    , 95, 0, 0},	//aflk
			//enae,enflk,intfrq,maxexp,defexp,minexp,exppoint,dpcthd,enlight,reserved1,2
			1, AUTO_FLK, 0     ,2000  ,400   ,66    ,1000    ,1000    ,1      ,0,0
		},                
		{
			32, 32 //brightness
		},
		{
			0x00,0x13,0x38,0x59,0x79,0x92,0xa7,0xb9,0xc8,0xd4,0xdf,0xe7,0xee,0xf4,0xf9,0xfc,0xff
			//0x00,0x20,0x4b,0x6e,0x8d,0xa3,0xb5,0xc5,0xd2,0xdc,0xe5,0xec,0xf2,0xf6,0xfa,0xfd,0xff	//gamma table
		}
	}                         
};                                
                                  
/********************************************************************************
  Description:	Write sensor register to change exposure time
  Parameter: t -- exposure time clock num 
*********************************************************************************/
void V558_SifSetSnrTime(UINT8 freqtype, UINT32 t)
{
	UINT16 uTemp = 0;
	UINT16 times = 0;
	UINT16 lpf;

	V558_I2C_BATCH AeData;

	if(freqtype) //60hz
	{
		times = t/100000;
		if(times > 3)
		{
			uTemp = 1;
			lpf = t/827;
		}
		else
		{
			lpf = 483;
			uTemp = lpf+1-t/827;
		}
	}
	else //50hz
	{
		times = t/120000;
		if(times > 3)
		{
			uTemp = 1;
			lpf = t/991;
		}
		else
		{
			lpf = 483;
			uTemp = lpf+1-t/991;
		}
		
	}

	V558_SifI2cWriteByte(0x4 ,(UINT8)(lpf>>6&0xff)); 
	V558_SifI2cWriteByte(0x5 ,(UINT8)lpf&0x3f); 
	V558_SifI2cWriteByte(0xe ,(UINT8)(uTemp&0x1)); 
	V558_SifI2cWriteByte(0xf ,(UINT8)(uTemp>>1));

	AeData.RegBytes = 1;
	AeData.RegAddr = 0x11;
	AeData.RegVal[0]= 1;
	V558_SifI2cAeBatch(1, &AeData);
}

/********************************************************************************
  Description:	Write sensor register when change freq
  Parameter: freqflag -- freq type (0)50hz,else 60hz 
*********************************************************************************/
void V558_SifSetFlkParam(UINT8 freqflag)
{
	if(freqflag) //60hz
	{
		V558_SifI2cWriteByte(0x3, 0x5b);
		V558_SifI2cWriteByte(0x11, 0x1);
	}
	else //50hz
	{
		V558_SifI2cWriteByte(0x3, 0xad);
		V558_SifI2cWriteByte(0x11, 0x1);
	}
}

#endif 

                         

#if SELECT_SAMSUNG437_BAYER 

const V558_SENSORREGVALUE	SifRegVal[] =
{
//	{0x800, 0x24,	1},
//	{0x800, 0x25,	1},
//	{0x805, 0x00,	0},
//	{0x806, 0x01,	0},
	{0x801, 0x41,	0},
	{0x803, 0x0b,	0},
	{0x804, 0x04,	0},
	{0x815, 0x2a,	0},
	{0x816, 0x02,	0},
	{0x817, 0x7f,	0},
	{0x821, 0x01,	0},
	{0x823, 0xe1,	0},
	{0x81d, 0x01,	0},
	{0x81f, 0x06,	0},

//	{0x840, 0x01,	0},
//	{0x841, 0xd0,	0},
//	{0x842, 0x01,	0},
//	{0x843, 0xe0,	0}

//	{0x800, 0x27,	0}
};

const V558_SENSORREGVALUE	SensorRegVal[] =
{
	{0x00,	0x26,	1},
	{0x01,	0x10,	1},
	{0x03,	0x0e,	1},
	{0x05,	0x0e,	1},
	{0x06,	0x01,	1},
	{0x07,	0xe0,	1},
	{0x08,	0x02,	1},
	{0x09,	0x80,	1},  	
	{0x0d,	0x01,	1},
	{0x0e,	0xce,	1}, 
//	{0x14,	0x04,	1},
//	{0x15,	0x2c,	1}, 	
	{0x21,	0x60,	1},  	
};

const V558_SENSORREGVALUE	IspRegVal[] =
{
	{0x2000,  0x01,	0},
	{0x2001,  0x5d,	0},
	{0x2027,  0x20,	0},
	{0x2026,  0x60,	0},
	{0x200a,  0x40,	0},
	{0x200b,  0x60,	0},
	{0x200c,  0x05,	0},
	{0x200d,  0x0f,	0},
	{0x200e,  0x0f,	0},
	{0x200f,  0x0f,	0},

	{0x2022,  0x40,	0},
	{0x2023,  0x40,	0},
	{0x2024,  0x40,	0},

	{0x202c,  0x3d,	0},
	{0x202d,  0x06,	0},
	{0x202e,  0xf5,	0},
	{0x202f,  0xfc,	0},
	{0x2030,  0x36,	0},
	{0x2031,  0x08,	0},
	{0x2032,  0xfa,	0},
	{0x2033,  0xf2,	0},
	{0x2034,  0x4c,	0},
/*
	{0x202c,  0x41,	0},
	{0x202d,  0x09,	0},
	{0x202e,  0xe9,	0},
	{0x202f,  0xf8,	0},
	{0x2030,  0x3c,	0},
	{0x2031,  0x01,	0},
	{0x2032,  0xf4,	0},
	{0x2033,  0xf1,	0},
	{0x2034,  0x4e,	0},
*/

	{0x208b,  0xff,	0},
	{0x2081,  0x01,	0}
};                                
                                  
const V558_SENSORINFO SensorInfo =      
{                                 
	"Samsung437 bayer mode",   
	{640, 480},               
	0,	//bayer mode
	0x1,	//pixel rate
	0x0,	//sensor mast clock count
	12000,	//sif clock
	V558_SNRC_I2C,            
	SAMSUNG437_BAYER,          
	{1,1,0,0,1},	//PwrOn,SnrEn,PltEn,PltMd,SnrRe              
	{sizeof(SifRegVal) / sizeof(V558_SENSORREGVALUE), SifRegVal},
	{0, 0x22, 0, sizeof(SensorRegVal) / sizeof(V558_SENSORREGVALUE), SensorRegVal},
	{                         
		0x0, sizeof(IspRegVal) / sizeof(V558_SENSORREGVALUE), 
		IspRegVal,        
		{                 
			//tgt, yfldstp,lck,ulck,gain,gadly,gmax,gainrange[4],yfldmstp,steptime,inlck, gmin, etdem, etnum,reserved1,2,3;
			{0x78, 0x40, 0x0a, 0x14, 0x60, 1, 0xe0, {0x18, 0x16, 0x0, 0x0}, 0x20, 4, 0, 0x40, 4, 3, 0, 0, 0},	//ae
			//flkcnt,flklinemode,flkstep,flklst,outthd,lighttype,freqtype,timeinout,reserved1,2
			{0x39   ,0x1        ,0x0    ,0xd0  ,3     ,0        ,FREQ    , 98, 0, 0},	//aflk
			//enae,enflk,intfrq,maxexp,defexp,minexp,exppoint,dpcthd,enlight,reserved1,2
			1, AUTO_FLK, 0     ,2000  ,400   ,80    ,1000    ,1000    ,1      ,0,0
		},                
		{
			32, 32 //brightness
		},
		{
			//0x00,0x01,0x0c,0x1f,0x3a,0x53,0x6d,0x85,0x9c,0xb0,0xc2,0xd1,0xde,0xe9,0xf2,0xf9,0xff 
			//0x00,0x13,0x38,0x59,0x79,0x92,0xa7,0xb9,0xc8,0xd4,0xdf,0xe7,0xee,0xf4,0xf9,0xfc,0xff 
			0x00,0x04,0x16,0x30,0x4e,0x68,0x81,0x98,0xac,0xbe,0xcd,0xda,0xe4,0xed,0xf5,0xfb,0xff //gamma table			
		}
	}                         
};                                

/********************************************************************************
  Description:	Write sensor register to change exposure time
  Parameter: t -- exposure time clock num 
*********************************************************************************/
void V558_SifSetSnrTime(UINT8 freqtype, UINT32 t)
{
	UINT16 uTemp = 0;

	UINT16 vBlank = 0;
	UINT16 times = 0;

	V558_I2C_BATCH AeData;

	if(freqtype) //60hz
	{
		times = t/100000;
	}
	else //50hz
	{
		times = t/120000;
	}

	if(times > 3)
	{
		vBlank = t/780-470;
	}
	else
	{
		vBlank = 0x2d;
	}
	
	V558_SifI2cWriteByte(0x14,(UINT8)(vBlank>>8)); 
	V558_SifI2cWriteByte(0x15,(UINT8)(vBlank)); 
	V558_Delay(50); 

	uTemp = (UINT16)(t/780+1); 
	AeData.RegBytes = 2;
	AeData.RegAddr = 0xd;
	AeData.RegVal[0]= (UINT8)(uTemp>>8);
	AeData.RegVal[1]= (UINT8)(uTemp);
	V558_SifI2cAeBatch(1, &AeData);
}

/********************************************************************************
  Description:	Write sensor register when change freq
  Parameter: freqflag -- freq type (0)50hz,else 60hz 
*********************************************************************************/
void V558_SifSetFlkParam(UINT8 freqflag)
{
}



#endif    

              

#if SELECT_SAMSUNG532_YUV

const V558_SENSORREGVALUE	SifRegVal[] =
{
//	{0x800, 0x64,	1},
//	{0x800, 0x65,	1},
//	{0x805, 0x00,	0},
//	{0x806, 0x01,	0},

	{0x802, 0x02,	0},
	{0x801, 0x41,	0},
	{0x803, 0x0a,	0},
	{0x804, 0x05,	0},

	{0x815, 0x68,	0},
	{0x816, 0x02,	0},
	{0x817, 0x7f,	0},

	{0x821, 0x02,	0},
	{0x822, 0x01,	0},
	{0x823, 0xe2,	0},

	{0x81d, 0x01,	0},
	{0x81f, 0x02,	0},
	
//	{0x800, 0x67,	0}
};

const V558_SENSORREGVALUE	SensorRegVal[] =
{
	//page 0
	{0xec,	0x00,	1},
	{0x26,	0x01,	1},  //AE mode
	{0x31,	0x01,	1},
	{0x72,	0xd2,	1},
	{0x74,	0x03,	1},
	{0x76,	0x90,	1},
	{0x77,	0x80,	1},
	{0x7e,	0x40,	1},
	

	//page 1
	{0xec,	0x01,	1},
	{0x00,	0x23,	1},
	{0x0a,	0x08,	1},
	{0x10,	0x07,	1},
	
	{0x6d,	0x11,	1},
	{0x70,	0x0e,	1},
	{0x71,	0xd6,	1},
	{0x72,	0x30,	1},
	{0x73,	0xdb,	1},
	{0x74,	0x0e,	1},
	{0x75,	0xd6,	1},
	{0x76,	0x18,	1},
	{0x77,	0xf2,	1},
	{0x78,	0x0e,	1},
	{0x79,	0xd6,	1},
	{0x7a,	0x28,	1},
	{0x7b,	0xe6,	1},
	{0xc0,	0xe6,	1},
	{0xc1,	0xaa,	1},
	{0xc2,	0x8c,	1},
	{0xc3,	0x82,	1},
	{0xc4,	0x82,	1},
	{0xc5,	0x8c,	1},
	{0xc6,	0xaa,	1},
	{0xc7,	0xe6,	1},
	{0xc8,	0xc8,	1},
	{0xc9,	0xa0,	1},
	{0xca,	0x8c,	1},
	{0xcb,	0x82,	1},
	{0xcc,	0x82,	1},
	{0xcd,	0x8c,	1},
	{0xce,	0xa0,	1},
	{0xcf,	0xc8,	1},

	//page 2
	{0xec,	0x02,	1},
	{0x01,	0xa0,	1},
	{0x30,	0x29,	1},
	{0x38,	0x04,	1},

	//page 5
	{0xec,	0x05,	1},
	{0x04,	0x04,	1},
	{0x08,	0x59,	1},
	{0x0a,	0x75,	1},
	{0x0c,	0x90,	1},
	{0x0e,	0x3a,	1},
   	{0x22,   0x09,	1},
	{0x2a,   0x00,	1},
	{0x2d,   0x04,	1},

	//page 0
	{0xec,	0x00,	1},
	{0x75,	0x02,	5},

};

const V558_SENSORREGVALUE	IspRegVal[] =
{
	{0x00,	0x00,	1},	
};

const V558_SENSORINFO SensorInfo = 
{
	"Samsung532 yuv mode",
	{640, 480},
	1,	//YUV mode
	0x1,	//pixel rate
	0x0,	//sensor mast clock count
	12000,	//sif clock
	V558_SNRC_I2C,
	SAMSUNG532_YUV,
	{0,1,0,0,1},
	{sizeof(SifRegVal) / sizeof(V558_SENSORREGVALUE), SifRegVal},
	{0, 0x5a, 0, sizeof(SensorRegVal) / sizeof(V558_SENSORREGVALUE), SensorRegVal},
	{
		0x0, sizeof(IspRegVal) / sizeof(V558_SENSORREGVALUE), 
		IspRegVal,
		{
			//tgt, yfldstp,lck,ulck,gain,gadly,gmax,gainrange[4],yfldmstp,steptime,inlck, gmin, etdem, etnum,reserved1,2,3;
			{0x78, 0x40, 0x0a, 0x14, 0x60, 1, 0xe0, {0x20, 0x20, 0xb, 0x10}, 0x20, 4, 0, 0x40, 4, 3, 0, 0, 0},	//ae
			//flkcnt,flklinemode,flkstep,flklst,outthd,lighttype,freqtype,timeinout,reserved1,2
			{0x39   ,0x1        ,0x0    ,0xd0  ,3     ,0        ,FREQ    , 98, 0, 0},	//aflk
			//enae,enflk,intfrq,maxexp,defexp,minexp,exppoint,dpcthd,enlight,reserved1,2
			1, AUTO_FLK, 0     ,1000  ,400   ,80    ,1000    ,1000    ,1      ,0,0
		},
		{
			32, 32 //brightness
		},
		{
			0x00,0x13,0x38,0x59,0x79,0x92,0xa7,0xb9,0xc8,0xd4,0xdf,0xe7,0xee,0xf4

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -