XBusRS232Impl.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Last Edited by: Gasbarro February 10, 1986 7:47:58 pm PST
DIRECTORY
Basics, Process, XBus, XBusRS232;
XBusRS232Impl: CEDAR PROGRAM
IMPORTS Basics, Process, XBus
EXPORTS XBusRS232
[Indigo]<Dicentra>11.1>Heads>Private>TTYPortHeadDicentra.mesa
[Indigo]<Dicentra>11.1>Heads>Friends>MultibusAddresses.mesa
scc0: LONG CARDINAL = 9000H; -- MultibusAddresses.scc0, the connector near the fan
scc0: LONG CARDINAL = 29000H; -- MultibusAddresses.scc2, the middle connector
chanB: LONG POINTER TO Words = LOOPHOLE[scc0 + 00H];
chanA: LONG POINTER TO Words = LOOPHOLE[scc0 + 10H];
chan: LONG POINTER TO Words ← chanA; -- Line 0
Words: TYPE = RECORD [r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15: WORD];
initialized: BOOL ← FALSE;
PutChar:
PUBLIC PROCEDURE [char:
CHARACTER] =
TRUSTED {
IF ~initialized THEN Init[];
UNTIL ReadyToPut[] DO Process.CheckForAbort[]; ENDLOOP;
IOWrite[@chan.r8, LOOPHOLE[char]];
};
ReadyToPut:
PROCEDURE
RETURNS [
BOOLEAN] =
TRUSTED {
bits: WORD = IORead[@chan.r0];
RETURN[Basics.BITAND[bits, 4] # 0]; -- Tx Buffer Empty
};
GetChar:
PUBLIC PROCEDURE
RETURNS [char:
CHARACTER] =
TRUSTED {
IF ~initialized THEN Init[];
UNTIL ReadyToGet[] DO Process.CheckForAbort[]; ENDLOOP;
char ← LOOPHOLE[Basics.BITAND[IORead[@chan.r8], 177B]];
};
ReadyToGet:
PROCEDURE
RETURNS [
BOOLEAN] =
TRUSTED {
bits: WORD = IORead[@chan.r0];
RETURN[Basics.BITAND[bits, 1] # 0]; -- Rx Character Available
};
Init:
PUBLIC PROCEDURE =
TRUSTED {
IOWrite[@chanB.r0, 002H]; -- Shift Left (ADR0 is ignored)
IOWrite[@chan.r9, 0C0H]; -- Hardware Reset
IOWrite[@chan.r1, 000H]; -- No interrupts
IOWrite[@chan.r3, 0C1H]; -- 8bits/char, RxE
IOWrite[@chan.r4, 04AH]; -- 16xClock, 1.5 Stop Bits
IOWrite[@chan.r5, 0EAH]; -- DTR, 8bits/char, TxE, RTS
IOWrite[@chan.r11, 050H]; -- Clocks from BR Gen
IOWrite[@chan.r12, 31]; -- Low byte of time constant
IOWrite[@chan.r13, 000H]; -- High byte of time constant
IOWrite[@chan.r14, 003H]; -- Enable Baud Rate Gen from PClk
initialized ← TRUE;
};
IORead:
PROCEDURE [adr:
LONG
POINTER]
RETURNS [data:
CARDINAL] =
TRUSTED {
data ← XBus.IORead[LOOPHOLE[2*LOOPHOLE[adr, LONG CARDINAL]]];
};
IOWrite:
PROCEDURE [adr:
LONG
POINTER, data:
CARDINAL] =
TRUSTED {
XBus.IOWrite[LOOPHOLE[2*LOOPHOLE[adr, LONG CARDINAL]], data];
};
END.