Ну да. Несколько штук таких платок осталось валяться. Были куплены
в Митино. Нужно было срочно изобразить некие терминальчики (ЖКИ,
клава от PC, токовая петля 1 км). Платки АОН на i51 послужили
донорами для скорости. Это уже второй вариант, первый был вообще
наколенный - в телефонах с АОН на Z80 :) PLM рулил ;)
Contr: do;
$nolist
$include(c:\phiton\Intel\reg51.dcl)
$include(c:\phiton\Examples\310io.inc)
Declare
NeSpi(*) byte constant('HE C',138,145,' - ',134,'AMEP',134,'HE',132,146,'!',0),
Error1(*) byte constant('HET CB',143,134,145,' C IBM-PC !',0),
Error2(*) byte constant('KO',140,' HE C',130,133,'ECTB',130,'ET ! ',0),
SOOB1(*) byte constant('(C) 1996 C',145,'M',138,139,'EKC #'),
NumContr Byte constant ('1'),
End_N byte constant (0),
SOOB2(*) byte constant(145,140,'ET ',138,'EPE',
140,'A',144,'A ',140,'AHH',137,'X',0),
SOOB4(*) byte constant('VOL ',0),
SOOB3(*) byte constant(138,'EPE',140,'AHO HAK.: ',0);
Declare
PoleChr(*) byte constant('HAK',139,'A',140,'HA',143,' :' ,
'CBEK',139,'OC',140,'AT',144,145,'K:',
147,'P',145,131,'.',138,'O',139,'E.',134,'B :',
'KO',140,' BO',140,145,'TE',139,143,' :',
'TP.CPE',140,'CTBO :',
'T',145,138,' CBEK',139,137,' :',
'HOMEP KA',131,'ATA :',
'B',137,131,'P',130,134,144,145,'K :',
147,'P',130,'TTO (K',131,') :',
'TAPA (K',131,') :',
'HETTO (K',131,') :');
Declare
Patt(*) byte constant( 00000110b,
00000110b,
01000101b,
10000100b,
00000001b,
00000001b,
00000010b,
00000010b,
00000101b,
00000101b);
Declare Delay byte constant(20);
Declare (RusCnt,LcdPtr) byte External;
Declare Level byte External;
Declare (Vygr,Ekod,FlUp,FlSound, Fl_N, Fl_L, Fl_Z) bit;
Declare CntNak word;
Declare Buf(66)byte;
Declare Pole byte;
Sound: procedure(Num) external;
Declare Num byte;
end Sound;
Beep:procedure(T,L) external;
Declare(T,L) byte;
end Beep;
Kbd: procedure Byte external;
end Kbd;
TstRd: procedure External;
End TstRd;
OutCtl: procedure(Ctl) External;
Declare Ctl byte;
end OutCtl;
OutSym: procedure(Sym) External;
Declare Sym byte;
End OutSym;
OutStr: procedure(Pnt,Cnt,Typ) External;
Declare
Pnt word,
Typ bit,
Cnt byte;
End OutStr;
InitLcd: procedure external;
End InitLcd;
/*----------------------------------------------------*/
OutPole: procedure;
RusCnt=0;
LcdPtr=0;
Call OutStr(.PoleChr+Pole*14,14,0);
Call OutStr(.Buf+Pole*6,6,1);
end OutPole;
ClrPole: procedure;
Declare i byte;
Do i=0 to 5;
Buf(i+Pole*6)=' ';
end;
Buf(i-1+Pole*6)='0';
End ClrPole;
ClrBuf: procedure;
Declare (i) byte;
Do i=0 to 65;
Buf(i)=' ';
if (i mod 6)=5 then Buf(i)='0';
end;
end ClrBuf;
BeepErr: procedure;
Call Beep(200,50);
end BeepErr;
BeepOK: procedure;
Call Beep(100,80);
Call Beep(70,100);
end BeepOK;
/*-------------CALC-----------*/
Calc: procedure bit;
Declare (i,n1,n2,Ex) byte;
Declare c bit;
call ClrPole;
Ex=0;
c=0;
i=5;
do while Buf(48+i)<>' ';
n1=Buf(48+i)-48;
n2=Buf(54+i);
if n2=' ' then n2='0';
n2=n2-48+expand(c);
if ((n2) > n1) then do;
c=1;
Ex=10;
end;
else c=0;
Buf(60+i)=n1+Ex-n2+48;
Ex=0;
i=i-1;
end;
if Buf(54+i)<>' 'then c=1;
i=0;
do while Buf(60+i)< '1';
Buf(60+i)=' ';
i=I+1;
if i=4 then do; /* << 2 à §à冷¢ */
c=1;
goto ZZ;
end;
end;
ZZ:
return c;
end Calc;
OutC: procedure;
LcdPtr=0;
RusCnt=0;
call OutStr(.Soob3,-1,0);
LcdPtr=19;
call OutSym((CntNak mod 10) +48 );
LcdPtr=18;
call OutSym((CntNak mod 100)/10 +48 );
LcdPtr=17;
call OutSym((CntNak mod 1000)/100 +48 );
LcdPtr=16;
call OutSym((CntNak mod 10000)/1000 +48 );
LcdPtr=Kbd;
call OutPole;
end OutC;
/*--------------------SERIAL PORT ROUTINES ------------------*/
InitUSART: Procedure;
/*-----------------------------*/
/* áâனª USART â ª, ª ª íâ® ¨á¯®«ì§ã¥âáï ¢ १¨¤¥â®¬ ®â« ¤ç¨ª¥
€á¨åà®ë©= 1200, Start + 8 bits + 1 Stop
*/
/*¨¨æ¨ «¨§ æ¨ï T1,ª®â®àë© ®¯à¥¤¥«ï¥â ᪮à®áâì ¯à¨¥¬ /¯¥à¥¤ ç¨*/
TMOD=00100000B; /* ’1 ¢ ०¨¬¥ 2 */
TH1=256-24 ; /* § £à㧪 áç¥â稪 â ©¬¥à 1200 ¡/á, ¯à¨ XTAL=11mHz*/
TR1=1; IT0=0;
/* ¨¨æ¨ «¨§ æ¨ï ¯®á«¥¤®¢ ⥫쮣® ª « */
Pcon=01110000b;
SM0=0; SM1=1; /*०¨¬ 1*/
SM2=0;
REn=1; /* à §à¥è¨âì ¯à¨¥¬*/
TI=0; RI=0;
end InitUSART;
/*à®æ¥¤ãàë ®¦¨¤ ¨ï ¯à¨å®¤ /ã室 ¡ ©â ¢/¨§ ¯à¨¥¬®¯¥à¥¤ â稪 */
WaitRI: Procedure;
Do while not TestClear(RI);;end;
call time(1);
End waitRI;
WaitTI: Procedure;
Do while not TestClear(TI);;end;
call time(1);
End WaitTI;
SendB: procedure(B);
Declare B byte;
Sbuf=B;call WaitTI;
end SendB;
Send: procedure(Typ);
Declare (i,b,cnt) byte,
CSm word,
Typ bit;
call OutCtl(0eh);
Cnt=0;
i= delay+(NumContr-48)*2;
REP:
do b = 0 to i;
Do Csm=0 to 300;
if RXD=0 then do;
Csm=0;
b=0;
end;
end;
end;
If Typ=0 then do;
CSm=NumContr;
call SendB(NumContr);
do i=0 to 59;
b=Buf(i);
If B=' ' then B='0';
call SendB(B);
CSm=Csm+B;
end;
call SendB(Low(Csm));
call SendB(High(Csm));
end;
else do;
call SendB(16h);/*---§ ¯à®á ª®¤ ---*/
do i=0 to 5;
b=Buf(6+i);
If B=' ' then B='0';
call SendB(B);
end;
end;
Call Time(20);
if RXD<>0 then do;
i=Delay;
call OutCtl(10h);
Cnt=Cnt+1;
if Cnt=20 then do;
cnt=0;
call OutCtl(80h+19);
end;
goto REP;
end;
call OutCtl(0ch);
end Send;
Que: procedure;
declare (i) byte;
RusCnt=0;
call send(1);
do while RXD=0;
end;
RI=0;
i=Sbuf;
call WaitRI;
i=Sbuf;
if (i and 00000001b)=0 then Vygr=0;
else Vygr=1;
if (i and 00000010b)=0 then FlSound=0;
else FlSound=1;
if (i and 00000100b)=0 then Fl_Z=0;
else Fl_Z=1;
if (i and 10000000b)<>0 then do;
EKod=1;
LcdPtr=0;
call OutStr(.Error2,-1,0);
Call BeepErr;
end;
else do;
EKod=0;
do LcdPtr =0 to 19;
call WaitRI;
call OutSym(Sbuf);
end;
call BeepOK;
end;
end Que;
/*------------------------------------------------------*/
$list
Input: procedure byte;
Declare Ptr word;
Declare (Key,i) byte,
Arr based Ptr(1) byte;
Ptr=.Buf+Pole*6;
do i=0 to 5;
if Arr(5-i)=' ' then goto QQ;
end;
QQ: if ((i=1) and (Arr(5)='0')) then i=0;
Fl_N=0;
do while 1;
Key= Kbd;
iF ((FL_n=1) and (Key<>'N') and (Key<>'-')) then do;
call OutPole;
Fl_n=0;
Key=0;
end;
if ((Key='N') and (Fl_Z=1)) then do;
LcdPtr=0;
RusCnt=0;
call OutStr(.NeSpi,-1,0);
call Sound(0);
call Sound(0);
call Sound(0);
Fl_N=1;
end;
if Key='+' then call OutC;
if Key='-' then do;
if FL_L then do;
Level=Level+1;
if Level=15 then FL_L=0;
end;
else do;
Level=Level-1;
if Level=0 then FL_L=1;
end;
LcdPtr=0;
RusCnt=0;
call OutStr(.Soob4,-1,0);
do LcdPtr= 4 to 19;
if Level=LcdPtr-4 then call OutSym(149);
else call OutSym('=');
end;
Fl_N=1;
end;
if Key='U' then do;
FlUp=1;
if Pole=0 then call BeepErr;
else do;
If ((Pole=8) and (Vygr=0)) then return -2;
return -1;
end;
end;
else FlUp=0;
if Key='C' then do;
call ClrPole;
i=0;
Call OutPole;
end;
If (((Key>='0') and (Key<='9')) or (Key='.')) then do;
if ((Key='.') and ((Patt(Pole) and 01000000b)=0)) then call BeepErr;
else do;
if i>=(Patt(Pole) and 0fh) then call BeepErr;
else do;
if not ((Key='0') and (i=0)) then do;
If i=0 then Arr(5)=' ';
i=i+1;
Arr(0)=Arr(1);
Arr(1)=Arr(2);
Arr(2)=Arr(3);
Arr(3)=Arr(4);
Arr(4)=Arr(5);
Arr(5)=Key;
Call OutPole;
end;
end;
end;
end;
If Key='L' then do;
If i=1 then do;
i=0;
Call ClrPole;
Call OutPole;
end;
if i>1 then do;
i=i-1;
Arr(5)=Arr(4);
Arr(4)=Arr(3);
Arr(3)=Arr(2);
Arr(2)=Arr(1);
Arr(1)=Arr(0);
Arr(0)=' ';
Call OutPole;
end;
end;
If Key='E' then do;
if(not((Patt(Pole) and 10000000b)=0) and (i<(Patt(Pole) and 0fh))) then call BeepErr;
else if (((Pole=8) or (Pole=9) or(Pole=1)) and (i<4)) then call BeepErr;
else if (((Pole=8) or (Pole=9)) and (Buf(Pole*6+1)>'5')) then call BeepErr;
else Return 1;
end;
end;
end Input;
/*-----------------------Begin Program------------------------*/
CWR55=10000011b; /* PB ‚‚Ž„, ‘(0-3) ‚‚Ž„, ®á⠫쮥 ¢ë¢®¤ */
DISABLE;
Level=7;
Fl_l=0;
FlSound=0;
Fl_Z=1;
CntNak=0;
Call InitLcd;
call INITUSART;
RusCnt=0;
LcdPtr=0;
call OutStr(.Soob1,-1,0);
Call Sound(1);
do Pole =0 to 30;
call Time(200);
end;
If RxD=0 then do;
RusCnt=0;
LcdPtr=0;
call OutStr(.Error1,-1,0);
Call Sound(0);
end;
else goto BGN;
Do while RXD=0;
do Pole =0 to 50;
call Time(200);
end;
call beep(10,10);
end;
Call Sound(2);
BGN:
Vygr=0;
Call InitLcd;
Call ClrBuf;
Pole=0;
do while 1;
Call OutPole;
Pole=Pole+Input;
If ((Pole=7) and (Vygr=0)) then Pole=Pole+1;
/*---------------------------*/
If ((Pole=2) and (FlUp=0)) then do;
call Que;
if ((Kbd<>'E') or (Ekod=1)) then Pole=1;
end;
/*-------------------------------*/
/*--------SEND REQUEST------*/
if Pole=10 then do;
if Calc=1 then do; /* ¥á«¨ ¢¥á ¥ ᮮ⢥âáâ¢ã¥â*/
Pole=9;
call BeepErr;
end;
else do;
Call OutPole;
REPIN: Pole =Kbd;
if Pole='E' then do;
RusCnt=0;
LcdPtr=0;
call OutStr(.Soob2,-1,0);
Call Send(0);
If FlSound<>0 then Call Sound(2);
else call BeepOK;
CntNak=CntNak+1;
goto BGN;
end;
If Pole='U' then Pole=9;
else goto REPIN;
end;
end;
/*-----------------------------*/
end;
end Contr;