-- JasmineDefs.Mesa
--DIRECTORY
--
StreamDefs: FROM "StreamDefs";

JasmineDefs: DEFINITIONS =
BEGIN
JasmineCommand:
TYPE = {SETDELAY,WE3,WE2,WE1,SPARE,MOTORCTL,LOAD,SCANSTART};
JasmineCBCommand:
TYPE = {CommandREAD,CommandDELAY,CommandFORWARD,CommandBACK};

dataOut
: TYPE = MACHINE DEPENDENT RECORD
[
blank: [0..377B],
enable: BOOLEAN,
command: JasmineCommand,
data: [0..17B]
];

ScanCB: TYPE = MACHINE DEPENDENT RECORD
[
link: POINTER TO ScanCB,
blank: [0..37777B],
command: JasmineCBCommand,
status: JasmineCBStatus,
buffer: POINTER TO PACKED ARRAY OF [0..377B]
];

ScanHead: TYPE = MACHINE DEPENDENT RECORD
[ firstCB: POINTER TO ScanCB,
nBlocks,nextBlock,nCBsPerBlock: CARDINAL,
nScanLines: INTEGER
];

RAMval: TYPE = MACHINE DEPENDENT RECORD
[
q1: [0..17B],
q2: [0..17B],
q3: [0..17B],
q4: [0..17B]
];

--location constants
Outport: POINTER TO dataOut = LOOPHOLE [177016B];
ScanTime: POINTER TO CARDINAL = LOOPHOLE [526B];
ScanCBHead: POINTER TO POINTER TO JasmineDefs.ScanCB = LOOPHOLE [736B];
StartCommand: POINTER TO dataOut = LOOPHOLE [737B];

--status flags
JasmineCBStatus: TYPE = INTEGER;
StatusINUSE: JasmineCBStatus = 1;--in general, all positive numbers are "in use" flags
StatusFREE: JasmineCBStatus = 0;
StatusDONE: JasmineCBStatus = -1;
StatusDATALATE: JasmineCBStatus = -2;

--from JasmineUtil
JasmineInit: PROCEDURE;
JasmineSetDelay: PROCEDURE [delay: [0..15]];
JasmineSetResolution: PROCEDURE [skips: [0..15]];
JasmineSetTime: PROCEDURE [ticks: CARDINAL];--(ticks = 38usecond units)
JasmineLoadRam: PROCEDURE [ramvals: POINTER TO ARRAY [0..1024) OF RAMval];
JasmineScanInit: PROCEDURE RETURNS [POINTER TO ScanHead];
JasmineScanClose: PROCEDURE [s: POINTER TO ScanHead];
JasmineReadLine: PROCEDURE [s: POINTER TO ScanHead,continue: BOOLEAN ← TRUE]
RETURNS [POINTER TO PACKED ARRAY OF [0..377B]];
JasmineSetReadMode: PROCEDURE [readMode: [1..3]];
--readOnly=1, readAndStep=2, readStepAndDelay=3
JasmineStep: PROCEDURE [nSteps: INTEGER,forward: BOOLEAN];
JasmineSetWindow: PROCEDURE [xStart,xLen,yStart,yLen: CARDINAL];--in full resolution coords (250 microns)
JasmineCoord: PROCEDURE [c: CARDINAL] RETURNS [CARDINAL];--(coord) returns # samples
JasmineNewPage: PROCEDURE [pageLen: CARDINAL];--(>100 = 250u, <100=inches)
JasmineEject: PROCEDURE;
JasmineMotorOff: PROCEDURE;

--low level stuff: don’t touch
JasmineControllerOn: PROCEDURE;
JasmineControllerOff: PROCEDURE;
JasmineSendCommand: PROCEDURE [command: JasmineCommand,data: [0..17B]];

--from JasmineCalibrate
JasmineCalibrate: PROCEDURE;

END.