您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 管理学资料 > ov9650Preview实现流程图全文案例分析电子版
OV9650裸机arm9实现过程具体实现的功能:通过摄像头OV9650采集视频图像,并与arm9的camerainterface相连接,把采集到的数据放入内存的某段区域中,将该段区域同时设置成LCD的数据缓存区,这样采集到的数据就可以直接在LCD显示屏上显示了实现该功能主要完成的工作:设置OV9650的内部寄存器(寄存器很多,最好直接网上下载个对应功能的寄存器设置表),CameraInterface的各个寄存器配置,arm9的LCD各个寄存器配置实现流程:(1)初始化摄像头硬件接口和时钟CamReset();//摄像软件重启rCLKCON|=(119);//设置时钟控制寄存器使能Camera,控制HCLK进入Camera块CamPortSet();//配置各个引脚的功能GPJ和GPGChangeUPllValue(56,2,1);//UPLLclock=96MHz,PLLinput12MHzrCLKDIVN|=(13);//根据UPLL为96MHz设置UCLK为48MHzSetCAMClockDivider(CAMCLK24000000);//设置摄像头时钟为24MHz(2)检测OV9650与arm9接上与否,接上则配置OV9650的寄存器Test_OV9650(void)intret;CamModuleReset();//重启外接CameraOV9650_init();//本程序是模拟IIC,所以GPE14、15两个引脚根据程序情况设置为输入输出模式,而非IIC模式printk(CheckcameraID\n);ret=check_OV9650();//通过模拟IIC来读取OV9650摄像头的厂商ID和产品ID的寄存器,来判断是否检测到设备,返回0,则检测到if(ret){printk(Can'tfindcamera!\n);returnret;}//Uart_Printf(\nshentuhongfengtest11\n);printk(InitialCameranow,Pleasewaitseveralminutes...\n);OV9650_config();//OV9650的寄存器配置,由于OV9650的寄存器很多,一般下载配置表配置就行return0;voidCamReset(void){rCIGCTRL|=(131);//CameraInterface全局控制寄存器Delay(10);rCIGCTRL&=~(131);}voidCamPortSet(void){save_GPJCON=rGPJCON;//保存GPJ的初始设置save_GPJDAT=rGPJDAT;save_GPJUP=rGPJUP;rGPJCON=0x2aaaaaa;//配置GPJ的引脚功能,使GPJ0~GPJ7为CAMDATA[0]~CAMDATA[7]rGPJDAT=0;//GPJ8为CAMPCLK,GPJ9为CAMVSYNC,GPJ10为CAMHREF,GPJ11为CAMCLKOUT,GPJ12为CAMRESETrGPJUP=0;//将管脚数据初始为0,上拉电阻使能rGPGCON&=~(322);//GPG11引脚设置为input功能,而不是EINT[19]rGPGCON|=122;rGPGUP|=111;rGPGDAT&=~(111);}voidChangeUPllValue(intmdiv,intpdiv,intsdiv){rUPLLCON=(mdiv12)|(pdiv4)|sdiv;}voidSetCAMClockDivider(intdivn){rCAMDIVN=(rCAMDIVN&~(0xf))|(14)|(divn);//CAMCLKisdivided..}staticvoidCamModuleReset(void){//bit30isexternalresetrCIGCTRL|=(130);//externalcameraresethighDelay(30);rCIGCTRL&=~(130);//externalcameraresetlowDelay(30);}void__inlineOV9650_init(void){CFG_WRITE(SIO_C);//定义SIO_C为14,SIO_C为15CFG_WRITE(SIO_D);mdelay(10);}#defineCFG_WRITE(_x)set_gpio_ctrl(_x|GPIO_PULLUP_DIS|GPIO_MODE_OUT)//GPIO_PULLUP_DIS为130,GPIO_MODE_OUT为1UL31static__inlinevoidset_gpio_ctrl(unsignedintgpio){rGPECON&=~(3((gpio&0xf)*2));//将GPE14或者GPE15设置为input模式if(gpio&GPIO_MODE_OUT)rGPECON|=1((gpio&0xf)*2);//如果是GPIO_MODE_OUT,则设置为GPE14或者GPE15为output模式if(gpio&GPIO_PULLUP_DIS)rGPEUP|=1(gpio&0xf);//应为GPE14、15为漏极开路,所以上拉电阻不用设置,这步不是必须的elserGPEUP&=~(1(gpio&0xf));}int__inlinecheck_OV9650(void){intret=0;intOV9650_mid=0;inttry_count=0;//2timestry_again:OV9650_mid=(OV9650_sccb_receivebyte(0x1c)8);//OV9650的寄存器ox1c和ox1d存放了厂商的ID信息OV9650_mid|=OV9650_sccb_receivebyte(0x1d);//OV9650的厂商ID值0x7FA2(已知的),判断上面读取的ID值是否与已知值相同if(OV9650_mid!=OV9650_PRODUCT_ID){if(!try_count++)gototry_again;printk(InvalidmanufactureID(0x%04X).thereisnoOV9650(0x%04X)\n,OV9650_mid,OV9650_PRODUCT_ID);ret=-ENODEV;}else{printk(OV9650MACHINE(0x%04X)detected.\n,OV9650_mid);//Uart_Printf(\nshentuhongfengtest10\n);}OV9650_mid=0;//读取OV9650的产品ID的寄存器0x0a和0x0b,该值读取为0x9652(本摄像头)OV9650_mid=(OV9650_sccb_receivebyte(0x0a)8);OV9650_mid|=OV9650_sccb_receivebyte(0x0b);printk(ProductIDis0x%04x\n,OV9650_mid);returnret;}void__inlineOV9650_config(void){inti;for(i=0;iOV9650_REGS;i++){if(ov9650_reg[i].subaddr==CHIP_DELAY)Delay(ov9650_reg[i].value);elseOV9650_sccb_sendbyte(ov9650_reg[i].subaddr&0xff,ov9650_reg[i].value&0xff);}}由前面的(1)(2)两部分,我们已经把外围摄像头内部的寄存器初始化了,并设置了相应的管脚和时钟。i=Test_OV9650();if(i){Uart_Printf(\nTestisfailed!!!\n);return;}Uart_Printf(Initializingend...\n);#ifndef_TQ2440_OV9650_H_#define_TQ2440_OV9650_H_#defineCHIP_DELAY0xFF#defineBUSHI_DEF0staticstructOV9650_t{intsubaddr;intvalue;}ov9650_reg[]={{0x12,0x80},//CameraSoftreset.Selfclearedafterreset.{CHIP_DELAY,10},//change0x11[0x81-0x80],0x15[0x02-0x10],hzh//{0x12,0x80},{0x11,0x80},{0x6a,0x3e},{0x3b,0x09},{0x13,0xe0},{0x01,0x80},{0x02,0x80},{0x00,0x00},{0x10,0x00},{0x13,0xe5},{0x39,0x43},{0x38,0x12},{0x37,0x00},{0x35,0x91},{0x0e,0xa0},{0x1e,0x04},{0xA8,0x80},{0x12,0x40},{0x04,0x00},{0x0c,0x04},{0x0d,0x80},{0x18,0xc6},{0x17,0x26},{0x32,0xad},{0x03,0x00},{0x1a,0x3d},{0x19,0x01},{0x3f,0xa6},{0x14,0x2e},{0x15,0x10},{0x41,0x02},{0x42,0x08},{0x1b,0x00},{0x16,0x06},{0x33,0xe2},{0x34,0xbf},{0x96,0x04},{0x3a,0x00},{0x8e,0x00},{0x3c,0x77},{0x8B,0x06},{0x94,0x88},{0x95,0x88},{0x40,0xc1},{0x29,0x3f},{0x0f,0x42},{0x3d,0x92},{0x69,0x40},{0x5C,0xb9},{0x5D,0x96},{0x5E,0x10},{0x59,0xc0},{0x5A,0xaf},{0x5B,0x55},{0x43,0xf0},{0x44,0x10},{0x45,0x68},{0x46,0x96},{0x47,0x60},{0x48,0x80},{0x5F,0xe0},{0x60,0x8c},{0x61,0x20},{0xa5,0xd9},{0xa4,0x74},{0x8d,0x02},{0x13,0xe7},{0x4f,0x3a},{0x50,0x3d},{0x51,0x03},{0x52,0x12},{0x53,0x26},{0x54,0x38},{0x55,0x40},{0x56,0x40},{0x57,0x40},{0x58,0x0d},{0x8C,0x23},{0x3E,0x02},{0xa9,0xb8},{0xaa,0x92},{0xab,0x0a},{0x8f,0xdf},{0x90,0x00},{0x91,0x00},{0x9f,0x00},{0xa0,0x00},{0x3A,0x01},{0x24,0x70},{0x25,0x64},{0x26,0xc3},{0x2a,0x00},{0x2b,0x00},{0x6c,0x40},{0x6d,0x30},{0x6e,0x4b},{0x6f,0x60},{0x70,0x70},{0x71,0x70},{0x72,0x70},{0x73,0x70},{0x74,0x60},{0x75,0x60},{0x76,0x50},{0x77,0x48},{0x78,0x3a},{0x79,0x2e},{0x7a,0x28},{0x7b,0x22},{0x7c,0x04},{0x7d,0x07},{0x7e,0x10},{0x7f,0x28},{0x80,0x36},{0x81,0x44},{0x82,0x52},{0x83,0x60},{0x84,0x6c},{0x
本文标题:ov9650Preview实现流程图全文案例分析电子版
链接地址:https://www.777doc.com/doc-6833910 .html