uint read2543(uchar port) { uint ad=0; uchar i; P1=0xeb; CLOCK = 0; AD_CS = 0; port<<=4; for(i=0;i<8;i++) //读高8位 { if(D_OUT) ad|=0x01; D_IN=(bit)(port&0x80); CLOCK=1; CLOCK=0; port<<=1; ad<<=1; } for(i=8;i<12;i++) //读低4位 { if(D_OUT) ad|=0x01; CLOCK=1; CLOCK=0; ad<<=1; } AD_CS=1; ad>>=1; return(ad); } |