/************************************************************************ Title: 超音波送信、受信 File : T_SSS.C Ver.1.0 written on Feb.7,1996 by M.M. *************************************************************************/ #include "m9401.h" #include "mathf.h" extern int Tmc; extern int Seg[]; extern int Dist[]; extern int inportb(); extern int outportb(); int t_sss(sss_no) int sss_no; { int i,j,k; /* int dist; */ int h,m,l; int h1,m1,l1; int underflg; if (Tmc != 0){ outportb(TCR2,0xb2); h1=inportb(CNTR2 +2); m1=inportb(CNTR2 +4); l1=inportb(CNTR2 +6); h=(h1 & 0xff); m=(m1 & 0xff); l=(l1 & 0xff); Dist[sss_no]=(SSS_LIMIT-((h<<16)+(m<<8)+l))*32/(double)8000000*340/2*100+52; underflg=inportb(PADR2); if ((underflg & 0x04)==0x04) Dist[sss_no]=999; } outportb(TCR2,0xb3); outportb(PADR2,sss_no); outportb(PACR2,0x28); /* H2 asert */ outportb(PACR2,0x20); /* H2 negate and H1 interrupt disable */ return(ON); } interrupt void ssint() { }