home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
kermit.columbia.edu
/
kermit.columbia.edu.tar
/
kermit.columbia.edu
/
archives
/
ucsdmagiscan2.zip
/
rs232.text
< prev
next >
Wrap
Text File
|
2011-08-11
|
3KB
|
162 lines
(*$S+*)
{ This unit contains the subroutines necessary for
accessing/using the RS232 interface of the Magiscan }
Unit RS232;
Written by H Balen 1-Aug-85
Modified by H Balen 23-Sep-85
Interface
Uses
M2Types,M2IpRoot,M2Sys;
var
MuxDelay : integer;
procedure InitM;
function ISTATR : boolean;
function ISTBRR : boolean;
function ISTBOR : boolean;
function ISTBFE : boolean;
function ISTBTR : boolean;
procedure SNDBBT( BT : char );
procedure SNDABT( BT : char );
function RCVBBT : Char;
Implementation
{ All the routines below have the same function as those
in the text file WDPROCS for the UCM version of kermit }
const
RxBit = 4;
TxBit = 5;
Uart = 56;
Control = 57;
Status = 57;
{ RS232 dependant constants for the status registar }
OverError = 4;
FrameError = 5;
type
RegByte = record
case Boolean of
True : ( Value : integer );
(* ---------------------------------------------------- *)
function ISTBOR;
Is it true that data OverRun occurred ?,
var
Byte : RegByte;
begin
Byte.Value := IORead(Status);
ISTBOR := Byte.B[OverError]
end{ISTBOR};
(* ---------------------------------------------------- *)
function ISTBFE;
Is it true that Framing-Error occured?
var
Byte : RegByte;
begin
Byte.Value := IORead(Status);
ISTBFE := Byte.B[FrameError]
end{ISTBFE};
(* ---------------------------------------------------- *)
function ISTBTR;
Is it true that transmit is ready ?
begin
ISTBTR := not IOStatus(TxBit)
end{ISTBR};
(* ---------------------------------------------------- *)
procedure InitM;
This initialises the RS232 port
begin
IOWrite(64,Control); { Internal Reset }
IOWrite(78,Control); { Set the mode }
IOWrite(55,Control); { Error Reset }
BaudRate(1200);
MuxDelay := 0;
end{RSInit};
(* ---------------------------------------------------- *)
procedure SNDBBT;
{ After getting back a TRUE result from isttr, this function
SNDBBT is used to actually send the byte of data from the
CPU to the device. Note that any attempt to call SNDBBT before
getting TRUE from isttr can result in clobering the previous
data }
var
i : integer;
begin
for i := 0 to (10 * MuxDelay) do;
[UnitWrite(8,i,1);
IOWrite(ord(BT),Uart);
end{SendToUART};
(* ---------------------------------------------------- *)
procedure SNDABT;
Same as the SNDBBT except this is for the keyboard
const
Ret = 13;
LF = 10;
begin
if ord(BT) <> Ret then
if ord(BT) = LF then{ If we have a LF then }
write(chr(Ret)) { send a CR instead }
else
write(BT) { else send the character itself }
end{SNABT};
(* ---------------------------------------------------- *)
function RCVBBT;
var
Ch : char;
begin
RCVBBT := chr( IORead(Uart) )
{UnitRead(7,Ch,1);
RCVBBT := Ch}
end{RxUART};
(* ---------------------------------------------------- *)
end{RS232}.