|
楼主 |
发表于 2010-12-13 13:18:01
|
显示全部楼层
这是经过我注释的:
/(140,16,640,480) is good for VGA
//(272,16,320,240) is good for QVGA
/* config_OV7660_window */
void OV7660_config_window(uint startx,uint starty,uint width, uint height)
{
uint endx=(startx+width);
uint endy=(starty+height*2);// "v*2"必须
uchar temp_reg1, temp_reg2;
uchar state,temp;
state = rdOV7660Reg(0x03, &temp_reg1 );
temp_reg1 &= 0xC0;
state = rdOV7660Reg(0x32, &temp_reg2 );
temp_reg2 &= 0xC0;
// Horizontal -水平
temp = temp_reg2|((endx&0x7)<<3)|(startx&0x7);//取水平像素开始和结束的低三位并且结束低三位取完后左移三位
state = wrOV7660Reg(0x32, temp );//设置水平像素开始和结束低三位,开始低三位在2~0,结束低三位在5~3
temp = (startx&0x7F8)>>3;
state = wrOV7660Reg(0x17, temp ); //设置水平像素开始高八位
temp = (endx&0x7F8)>>3;
state = wrOV7660Reg(0x18, temp ); //设置水平像素结束高八位
// Vertical-垂直
/*temp = temp_reg1|((endy&0x7)<<3)|(starty&0x7);
state = wrOV7660Reg(0x03, temp );
temp = (starty&0x7F8)>>3;
state = wrOV7660Reg(0x19, temp );
temp = (endy&0x7F8)>>3;
state = wrOV7660Reg(0x1A, temp );*/
temp = temp_reg1|((endy&0x3)<<2)|(starty&0x3);//取垂直像素开始和结束的低两位并且结束低两位取完后左移两位
state = wrOV7660Reg(0x03, temp );//设置垂直像素开始和结束低两位,开始低两位在1~0,结束低三位在3~2
temp = (starty&0x7FC)>>2;
state = wrOV7660Reg(0x19, temp );//设置垂直像素开始高八位
temp = (endy&0x7FC)>>2;
state = wrOV7660Reg(0x1A, temp ); //设置垂直像素结束高八位
} |
|