如何利用I2C总线,冻结摄像头影像.(100分)

  • 主题发起人 主题发起人 wcny
  • 开始时间 开始时间
W

wcny

Unregistered / Unconfirmed
GUEST, unregistred user!
; 我现在有I2C总线的读写入口,但仍不知如何利用它在dos下冻结摄像头影像.
入口源程序如下,希望高手指点.

>> #include <bios.h>
>> #include <stdlib.h>
>> #include <stdio.h>
>> #include <dos.h>
>> #include <ctype.h>
>>
>> int loopcount;
>> unsigned int lptdata=0x3cf;
>> unsigned int lptindex=0x3ce;
>> unsigned char predata;
>> unsigned char portdata;
>> void delay(unsigned int tm)
>> {unsigned int i,j;
>> for(i=0;i<tm;i++) for(j=0;j<=100;j++) inportb(0x71);
>> }
>>
>> void start()
>> {outportb(lptindex,0xb6);
>> predata=inportb(lptdata)&0x0f;
>> portdata=predata;
>> delay(1);
>> portdata&=0xef;
>> portdata|=0x40;
>> outportb(lptindex,0xb6);
>> outportb(lptdata,portdata);
>> delay(1);
>> portdata|=0x10;
>> outportb(lptindex,0xb6);
>> outportb(lptdata,portdata);
>> delay(1);
>>
>> for(loopcount=1000;loopcount>0;loopcount--)
>> {outportb(lptindex,0xb6);
>> if (inportb(lptdata)&0x20) break;
>> }
>>
>> portdata&=0xbf;
>> outportb(lptindex,0xb6);
>> outportb(lptdata,portdata);
>> delay(1);
>> portdata&=0xef;
>> outportb(lptindex,0xb6);
>> outportb(lptdata,portdata);
>> delay(1);
>> portdata&=0xaf;
>> outportb(lptindex,0xb6);
>> outportb(lptdata,portdata);
>> delay(1);
>> }
>>
>>
>> #include <bios.h>
>> #include <stdlib.h>
>> #include <stdio.h>
>> #include <dos.h>
>> #include <ctype.h>
>>
>> int loopcount;
>> unsigned int lptdata=0x3cf;
>> unsigned int lptindex=0x3ce;
>> unsigned char predata;
>> unsigned char portdata;
>> void delay(unsigned int tm)
>> {unsigned int i,j;
>> for(i=0;i<tm;i++) for(j=0;j<=100;j++) inportb(0x71);
>> }
>>
>> void start()
>> {outportb(lptindex,0xb6);
>> predata=inportb(lptdata)&0x0f;
>> portdata=predata;
>> delay(1);
>> portdata&=0xef;
>> portdata|=0x40;
>> outportb(lptindex,0xb6);
>> outportb(lptdata,portdata);
>> delay(1);
>> portdata|=0x10;
>> outportb(lptindex,0xb6);
>> outportb(lptdata,portdata);
>> delay(1);
>>
>> for(loopcount=1000;loopcount>0;loopcount--)
>> {outportb(lptindex,0xb6);
>> if (inportb(lptdata)&0x20) break;
>> }
>>
>> portdata&=0xbf;
>> outportb(lptindex,0xb6);
>> outportb(lptdata,portdata);
>> delay(1);
>> portdata&=0xef;
>> outportb(lptindex,0xb6);
>> outportb(lptdata,portdata);
>> delay(1);
>> portdata&=0xaf;
>> outportb(lptindex,0xb6);
>> outportb(lptdata,portdata);
>> delay(1);
>> }
>>
>>
>> void stop()
>> {outportb(lptindex,0xb6);
>> predata=inportb(lptdata)&0x0f;
>> portdata=predata;
>> delay(1);
>> portdata&=0xaf;
>> outportb(lptindex,0xb6);
>> outportb(lptdata,portdata);
>> delay(1);
>> portdata|=0x10;
>> outportb(lptindex,0xb6);
>> outportb(lptdata,portdata);
>> delay(1);
>>
>> for(loopcount=1000;loopcount>0;loopcount--)
>> {outportb(lptindex,0xb6);
>> if (inportb(lptdata)&0x20) break;
>> }
>>
>> portdata|=0x40;
>> outportb(lptindex,0xb6);
>> outportb(lptdata,portdata);
>> delay(1);
>> portdata&=0xef;
>> outportb(lptindex,0xb6);
>> outportb(lptdata,portdata);
>> delay(1);
>> portdata&=0xaf;
>> outportb(lptindex,0xb6);
>> outportb(lptdata,portdata);
>> delay(1);
>> }
>>
>>
>> unsigned char abit(unsigned char data)
>> {unsigned char rbt;
>> portdata=predata;
>> portdata&=0xaf;
>> portdata|=(data&1)?0x40:0;
>> delay(1);
>> outportb(lptindex,0xb6);
>> outportb(lptdata,portdata);
>> delay(1);
>> portdata|=0x10;
>> outportb(lptindex,0xb6);
>> outportb(lptdata,portdata);
>> delay(1);
>>
>> for(loopcount=1000;loopcount>0;loopcount--)
>> {outportb(lptindex,0xb6);
>> if (inportb(lptdata)&0x20) break;
>> }
>>
>> portdata&=0xef;
>> outportb(lptindex,0xb6);
>> rbt=(((inportb(lptdata))&0x80)?1:0);
>> outportb(lptdata,portdata);
>> delay(1);
>> return(rbt);
>> }
>>
>> unsigned char writeabyte(unsigned char data)
>> {int i;
>> for(i=7;i>=0;i--) abit(data>>i);
>> return(!abit(1));
>> }
>>
>> unsigned char readabyte()
>> {int i;
>> unsigned char data=0;
>> for(i=7;i>=0;i--) data|=(abit(1)<<i);
>> abit(1);
>> return(data);
>> }
>>
>> int readfrom711x(unsigned char sladdw,unsigned char sladdr,unsigned char
>subadd)
>> {int rt;
>> start();
>> if (!writeabyte(sladdw)) {stop();return(-1);}
>> if (!writeabyte(subadd)) {stop();return(-1);}
>> start();
>> if (!writeabyte(sladdr)) {stop();return(-1);}
>> rt=(int)readabyte();
>> stop();
>> return(rt);
>> }
>>
>> int write2711x(unsigned char sladdw,unsigned char subadd,unsigned char
>data)
>> {int rt;
>> start();
>> if (!writeabyte(sladdw)) {stop();return(-1);}
>> if (!writeabyte(subadd)) {stop();return(-1);}
>> if (!writeabyte(data)) {stop();return(-1);}
>> stop();
>> return(1);
>> }
>>
>> int read7111(unsigned char subaddr)
>> {return(readfrom711x(0x48,0x49,subaddr));
>> }
>>
>> int write7111(unsigned char subaddr,unsigned char data)
>> {return(write2711x(0x48,subaddr,data));
>> }
>>
 
请结束或继续!
 
接受答案了.
 

Similar threads

I
回复
0
查看
644
import
I
I
回复
0
查看
830
import
I
I
回复
0
查看
586
import
I
I
回复
0
查看
742
import
I
后退
顶部