亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ana_io.c

?? _計算實用教程Visual C++6.0實用教程
?? C
字號:
/*ana_io.c*/

/*12bit, 8 channel ADC and 8 bit 8 channel DAC interface
Uses MAX186 and MAX521
Dhananjay V. Gadre*/

#include<stdio.h>
#include<dos.h>
#include<time.h>
#include <conio.h>
#include <process.h>

/* D5 is SDA = data; D6 is SCL=clock */
#define H_H 0xff
#define H_L 0xdf
#define L_H 0xbf
#define L_L 0x9f

#define TRUE 1
#define FALSE 0

/*ADC control bytes for the 8 channels*/
unsigned char adc_con_byte[8];

/* Global variable has address of DATA port of LPT1 */
unsigned int dport_lpt1; /* data port address*/
unsigned char dport_value, cport_value; /*data and control port status*/

/*Check if LPT1 is present*/
int chk_lpt(void);

/* This generates the SLAVE address for the MAX-521 */
void set_up(void);

/*MAX521 start sequence*/
void st_seq(void);

/*MAX521 end sequence*/
void end_seq(void);

/* sets DAC address & the corresponding value */
void out_to_dac(unsigned int dac_number, unsigned int dac_value);

/*check if ADC is connected*/
int chk_adc(void);

/*start ADC conversion and get the result*/
int read_adc(int channel_number);

void st_seq(void)
{
unsigned int tempa;
tempa=inportb(dport_lpt1) & 0x9f;
tempa=tempa | (0x60 & H_H);
		/* Generate start sequence for MAX-521*/
		outportb(dport_lpt1, tempa);
		tempa= tempa & 0x9f;
		tempa= tempa | (H_L & 0x60);
		outportb(dport_lpt1, tempa);
		tempa=tempa & L_L;
		outportb(dport_lpt1, tempa);
}

void end_seq(void)
{
unsigned char tempb;
tempb=inportb(dport_lpt1) & 0x9f;
tempb=tempb | (0x60 & H_L);
		/* generate stop sequence */
		outportb(dport_lpt1, tempb);
		tempb=tempb | (0x60 & H_H);
		outportb(dport_lpt1, tempb);
}

int chk_lpt(void)
{
/*Get LPT1 port addresses */
dport_lpt1 = peek(0x40,0x08);
if(dport_lpt1 == 0) return FALSE;
return TRUE;
}

int chk_adc(void)
{
unsigned char temp1;
outportb(dport_lpt1+2, 0x01);
temp1=inportb(dport_lpt1);
temp1=temp1 & 0x7e;
outportb(dport_lpt1, temp1);
temp1=inportb(dport_lpt1+2);
temp1=temp1 & 0xfe;
outportb(dport_lpt1+2, temp1);
delay(10);
temp1=inportb(dport_lpt1+1);
temp1=temp1 & 0x80;
if(temp1 ) return FALSE;
temp1=inportb(dport_lpt1+2);
temp1=temp1 | 0x01;
outportb(dport_lpt1+2, temp1);
delay(10);
temp1=inportb(dport_lpt1+1);
temp1=temp1 & 0x80;
if(!temp1) return FALSE;
adc_con_byte[0]=0x8f;
adc_con_byte[1]=0xcf;
adc_con_byte[2]=0x9f;
adc_con_byte[3]=0xdf;
adc_con_byte[4]=0xaf;
adc_con_byte[5]=0xef;
adc_con_byte[6]=0xbf;
adc_con_byte[7]=0xff;
return TRUE;
}

/*start ADC conversion and get the result*/
int read_adc(int channel_number)
{
int  adc_val, temp_val;
unsigned char temp1, temp2, temp3, data[20];
long loop;
outportb(dport_lpt1+2, 0x01);
temp1=adc_con_byte[channel_number];
for(temp2=0; temp2<8; temp2++)
{
temp3= (temp1 << temp2) & 0x80;
temp3=temp3 & 0x81;
dport_value=inportb(dport_lpt1);
dport_value=dport_value & 0x7e;
dport_value=dport_value | temp3;
outportb(dport_lpt1, dport_value);
dport_value=dport_value | 1;
outportb(dport_lpt1, dport_value);
outportb(dport_lpt1, dport_value);
/* this is to make the clk 50% duty cycle*/
/* Duty cycle as measured with a 66 MHz 486 is 48% */
dport_value=dport_value & 0xfe;
outportb(dport_lpt1, dport_value);
}
dport_value=dport_value & 0x7f;
outportb(dport_lpt1, dport_value);
for(temp2=0; temp2<16; temp2++)
{
dport_value = dport_value & 0x7e;
dport_value=dport_value | 0x01;
outportb(dport_lpt1, dport_value);
data[temp2]=( inportb(dport_lpt1+1) & 0x80);
dport_value=dport_value & 0xfe;
outportb(dport_lpt1, dport_value);
outportb(dport_lpt1, dport_value);
}
adc_val=0;
for(temp2=0; temp2<16; temp2++)
{
temp_val=( (unsigned int) data[temp2] & 0x00ff) << 8;
adc_val= adc_val | ( (temp_val ^ 0x8000) >> temp2);
}
adc_val=adc_val>> 3;
return adc_val;
}

void set_up(void)
{
unsigned char temp, sda_val=0x50, tempx;
/*sda_val is set for AD1=AD0=0*/
unsigned int lp_count;

/* Read DATA port */
temp=inportb(dport_lpt1);

/* Send Slave address byte */
for (lp_count=0; lp_count<8; lp_count++)
	{
	/* Send SDA */
	temp=temp & L_L;
	tempx=sda_val & 0x80;
	tempx = (tempx >> 2) & 0x20;
	temp = tempx | temp;
	outportb(dport_lpt1, temp);

	/* setup SCL */
	temp = temp | 0x40 ;
	outportb(dport_lpt1, temp);

	/* reset SCL */
	temp = temp &  L_H;
	outportb(dport_lpt1, temp);

	/* get new value for SDA */
	sda_val = sda_val <<1;
	}

/* Send ack */
	temp = temp & 0x9f;
	outportb(dport_lpt1, temp);
	temp = temp | 0x40;
	outportb(dport_lpt1, temp);
	temp = temp & 0x9f;
	outportb(dport_lpt1, temp);
}

void out_to_dac(unsigned int dac_number, unsigned int dac_value)
{
unsigned char dac_address, tempy;
unsigned int counter, value, temp1;

		temp1=inportb(dport_lpt1);
		dac_address = 0x07 & ( (char) dac_number) ;
		value = (char) dac_value;

/* Send command byte to MAX-521 */
		/* Set DAC address into MAX-521 */
		for(counter=0; counter<8; counter++)
		{
		temp1 = temp1 & L_L;
		tempy=dac_address & 0x80;
		tempy = (tempy >> 2) & 0x20;
		temp1 = tempy | temp1;
		outportb(dport_lpt1, temp1);
		temp1 = temp1 | 0x40;
		outportb(dport_lpt1, temp1);
		temp1 = temp1 & L_H;
		outportb(dport_lpt1, temp1);
		dac_address = dac_address << 1;
		}
/* Send ack */
	temp1 = temp1 & 0x9f;
	outportb(dport_lpt1, temp1);
	temp1 = temp1 | 0x40;
	outportb(dport_lpt1, temp1);
	temp1 = temp1 & 0x9f;
	outportb(dport_lpt1, temp1);

/* Send value to the selected DAC */
		for(counter=0; counter<8; counter++)
		{
		temp1 = temp1 & L_L;
		tempy = value & 0x80;
		tempy = (tempy >> 2) & 0x20;
		temp1 = tempy | temp1;
		outportb(dport_lpt1, temp1);
		temp1 = temp1 | 0x40;
		outportb(dport_lpt1, temp1);
		temp1 = temp1 & L_H;
		outportb(dport_lpt1, temp1);
		value = value << 1;
		}
/* Send ack */
	temp1 = temp1 & 0x9f;
	outportb(dport_lpt1, temp1);
	temp1 = temp1 | 0x40;
	outportb(dport_lpt1, temp1);
	temp1 = temp1 & 0x9f;
	outportb(dport_lpt1, temp1);
}

void main(void)
{
clrscr();
printf("\nMulti-channel Analog I/O for the PC");
printf("\n8 Channel 12-bit ADC");
printf("\n8 Channel 8-bit DACs");
printf("\nDhananjay V. Gadre, 1996.\n\n");
if( chk_lpt() == FALSE)
{printf("\nNo Parallel Port. Aborting..."); exit(1);}
outportb(dport_lpt1, 0xff);

if( chk_adc() == FALSE)
{printf("\nNo ADC Connected. Aborting..."); exit(1);}

/*Convert voltage on  ADC channel*/
printf("\nADC Channel 2 Value = %d mV", read_adc(2) );
printf("\n\nProgramming the 8 DACs..");
/*Program the DACs*/
		/* Generate start sequence for MAX-521*/
		st_seq();
		/*setup address*/
		set_up();
		/*output to the DACs*/
		out_to_dac(0, 0);
		out_to_dac(1, 0x20);
		out_to_dac(2, 0x40);
		out_to_dac(3, 0x60);
		out_to_dac(4, 0x80);
		out_to_dac(5, 0xa0);
		out_to_dac(6, 0xc0);
		out_to_dac(7, 0xe0);
		/* generate stop sequence */
		end_seq();
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人午夜激情影院| 色综合久久六月婷婷中文字幕| 久久99精品久久久久久久久久久久| 极品少妇xxxx精品少妇| 国产成人午夜精品影院观看视频 | 美女一区二区久久| 国产乱人伦偷精品视频不卡| 91麻豆精品视频| 日韩美女天天操| 中文字幕一区二区三区视频| 视频一区在线播放| 福利电影一区二区| 欧美中文字幕亚洲一区二区va在线 | 日韩理论在线观看| 免费在线一区观看| 一本一道波多野结衣一区二区| 67194成人在线观看| 国产精品天美传媒| 免费av网站大全久久| www.av精品| 欧美大片一区二区| 亚洲va韩国va欧美va| 成人激情开心网| 精品久久久久久久久久久久久久久久久 | 国产精品色噜噜| 久久综合综合久久综合| 色综合中文综合网| 99久久99久久精品免费看蜜桃| ㊣最新国产の精品bt伙计久久| 亚洲三级在线看| 韩国毛片一区二区三区| 色噜噜偷拍精品综合在线| 日韩欧美精品在线视频| 亚洲一区二区三区四区在线免费观看 | 激情亚洲综合在线| 成人激情小说乱人伦| wwwwww.欧美系列| 日韩黄色免费网站| 欧美视频一区在线| 亚洲精品欧美激情| 成人黄色综合网站| 国产日韩欧美在线一区| 久久精品国内一区二区三区| 在线电影院国产精品| 一区二区三区成人在线视频| 92精品国产成人观看免费| 99riav一区二区三区| 亚洲欧洲制服丝袜| 91一区在线观看| 亚洲视频图片小说| a在线播放不卡| 国产精品国产精品国产专区不蜜 | 极品少妇xxxx偷拍精品少妇| 日韩一区二区三区视频| 日本aⅴ精品一区二区三区| 欧美日韩成人一区| 日本女人一区二区三区| 欧美一级高清大全免费观看| 日韩精品三区四区| 日韩欧美电影一区| 黑人精品欧美一区二区蜜桃| 欧美精品一区二区三区四区| 久久99精品久久久久久国产越南| 日韩一级免费观看| 国产美女一区二区三区| 久久先锋影音av| 国产福利精品导航| 国产精品久久久久影院| 91丨porny丨中文| 亚洲国产精品一区二区久久| 欧美精品久久久久久久多人混战 | 国产精品99久久久久久有的能看| 欧美精品一区二区三区在线 | 久久久精品天堂| 国产精品一区二区在线播放 | 国产女人18水真多18精品一级做| 成人一级片在线观看| 亚洲人成精品久久久久| 91精品国产一区二区三区| 久久精品国产亚洲高清剧情介绍| 久久久精品日韩欧美| 欧美在线视频全部完| 久久99热国产| 久久久精品综合| 欧美在线一区二区三区| 国内成+人亚洲+欧美+综合在线| 国产午夜久久久久| 日本久久精品电影| 久久精品99国产国产精| 日本一区二区电影| 欧美精品乱码久久久久久| 国产成人av一区二区三区在线| 亚洲一卡二卡三卡四卡无卡久久| 日韩欧美在线综合网| 99在线视频精品| 美女视频黄a大片欧美| 综合电影一区二区三区| 日韩欧美精品在线| 色欧美片视频在线观看在线视频| 轻轻草成人在线| 中文字幕一区二区三区av| 91精品综合久久久久久| 99riav久久精品riav| 国精产品一区一区三区mba桃花 | 久久亚洲欧美国产精品乐播 | 国产精品一区三区| 日韩有码一区二区三区| 亚洲欧洲av在线| 久久久久久夜精品精品免费| 91国偷自产一区二区三区成为亚洲经典| 美女一区二区三区在线观看| 亚洲制服丝袜一区| 国产精品美女久久久久久久 | 99视频一区二区| 欧美a级理论片| 亚洲成精国产精品女| 亚洲视频一区在线观看| 欧美国产日韩a欧美在线观看| 337p亚洲精品色噜噜噜| 欧美在线观看一区| 99久久精品免费看国产| 丰满白嫩尤物一区二区| 国产精品亚洲成人| 国产盗摄一区二区| 奇米888四色在线精品| 亚洲私人影院在线观看| 国产日韩欧美精品综合| 欧美亚洲一区二区在线| av不卡一区二区三区| 国产一区91精品张津瑜| 久久99九九99精品| 亚洲成年人影院| 亚洲欧洲一区二区三区| 亚洲欧洲日韩一区二区三区| 国产精品免费视频观看| 自拍偷拍亚洲欧美日韩| 亚洲人成人一区二区在线观看| 国产欧美日本一区视频| 国产精品午夜在线观看| 国产欧美日韩不卡| 最新日韩在线视频| 一区二区三区加勒比av| 亚洲精品成人在线| 亚洲第一福利视频在线| 性久久久久久久久| 久久草av在线| 国产精品一区二区91| 成人综合在线网站| 99精品视频在线观看免费| 91色九色蝌蚪| 欧洲精品在线观看| 欧美一区二区在线不卡| 精品国产成人在线影院 | 国产.欧美.日韩| av不卡在线播放| 欧美在线色视频| 欧美精品免费视频| 久久久www成人免费无遮挡大片| 国产欧美一区在线| 亚洲精品一二三| 捆绑调教一区二区三区| 高清shemale亚洲人妖| 99精品视频在线免费观看| 制服.丝袜.亚洲.另类.中文| 久久美女艺术照精彩视频福利播放 | 一区二区三区中文在线| 亚洲一区二区视频在线| 免费在线观看不卡| 国产精品18久久久久久久久| 成人激情图片网| 色婷婷综合在线| 欧美一区二区在线免费播放| 日韩视频国产视频| 亚洲精品在线三区| 26uuu亚洲| 一区av在线播放| 韩国欧美国产1区| 91麻豆免费观看| 精品日韩一区二区三区免费视频| 国产欧美日韩在线看| 日欧美一区二区| 国产成人av一区二区三区在线 | 激情六月婷婷综合| 色拍拍在线精品视频8848| www久久精品| 五月综合激情婷婷六月色窝| 国产精品18久久久久| 欧美在线影院一区二区| 国产精品美女久久久久久久网站| 日韩精品亚洲一区二区三区免费| 成人动漫av在线| 欧美va在线播放| 亚洲高清视频的网址| 91小视频在线免费看| 久久久久久久久一| 久久国产精品99久久久久久老狼 | 日韩一区在线免费观看| 波多野结衣精品在线| 国产精品亲子乱子伦xxxx裸| 不卡的av网站|