home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / bbs / picssup.ark / SBC-I.MCH < prev    next >
Encoding:
Text File  |  1986-10-18  |  4.1 KB  |  157 lines

  1. { ROS.MCH - Remote Operating System Machine Dependent Routines }
  2.  
  3. { File:        SBC-I.MCH
  4.   Description: This driver set is designed to support the Teletek SBC-I.
  5.   Date:        8/27/85
  6.   Author:      Steve Davis - Sysop Dragon RCP/M  (505)344-3171
  7.  
  8.   Description: Comment update and code cleanup.
  9.   Date:        9/7/85
  10.   Author:      Steve Fox
  11. }
  12.  
  13. {** System routines **}
  14.  
  15. procedure system_init;
  16. { Initialization to be done once when ROS first starts }
  17.   begin
  18.   end;
  19.  
  20. procedure system_de_init;
  21. { De-initialization to be done once when ROS terminates }
  22.   begin
  23.   end;
  24.  
  25. procedure putstat(st: StrStd);
  26. { Display 'st' on status line }
  27.   const
  28.     status_line    =  1;                    { Line used for system status }
  29.     last_line      = 25;                    { Last line on screen }
  30.   begin
  31.     GotoXY(1, status_line);
  32.     ClrEol;
  33.     LowVideo;
  34.     write(st);
  35.     HighVideo;
  36.     GotoXY(1, last_line)
  37.   end;
  38.  
  39. {** Remote channel routines **}
  40.  
  41. const
  42. { Machine specific constants }
  43.  
  44.   DataPort   = $00;          { Data port }
  45.   StatusPort = $01;          { Status port }
  46.   RatePort   = $08;          { Data rate (bps) port }
  47.  
  48.   RESCHN     = $18;          { reset channel }
  49.   RESSTA     = $14;          { reset ext/status }
  50.   WRREG1     = $00;          { value to write to register 1 }
  51.   WRREG3     = $C1;          { 8 bits/char, rx enable }
  52.   WRREG4     = $44;          { 16x, 1 stop bit, no parity }
  53.   DTROFF     = $68;          { dtr off, rts off }
  54.   DTRON      = $EA;          { dtr on, 8 bits/char, tx enable, rts on }
  55.   RESERR     = $30;          { error reset }
  56.  
  57. { StatusPort status masks }
  58.  
  59.   DAV        = $01;          { data available }
  60.   TRDY       = $04;          { transmit buffer empty }
  61.   DCD        = $20;          { data carrier detect }
  62.   PE         = $10;          { parity error }
  63.   OE         = $20;          { overrun error }
  64.   FE         = $40;          { framing error }
  65.   ERR        = $60;          { parity, overrun and framing error }
  66.  
  67. { Rate setting commands }
  68.   BDSET300   = 7;
  69.   BD300      = 52;            { 300 bps }
  70.   BDSET1200  = 71;
  71.   BD1200     = 64;            { 1200 bps }
  72.  
  73. procedure ch_init;
  74. { Initialize the remote channel }
  75. Const
  76.   sio_init: array[1..9] of byte = (RESCHN, 4, WRREG4, 1, WRREG1, 3, WRREG3, 5, DTROFF);
  77. var
  78.   i: integer;
  79. begin
  80.   for i := 1 to 9 do
  81.     port[StatusPort] := sio_init[i];        { initialize the SIO channel }
  82. end;
  83.  
  84. procedure ch_on;
  85. { Turn on remote channel (usually by enabling DTR) }
  86.   begin
  87.     port[StatusPort] := 5;
  88.     port[StatusPort] := DTRON
  89.   end;
  90.  
  91. procedure ch_off;
  92. { Turn on remote channel (usually by disabling DTR) }
  93.   begin
  94.     port[StatusPort] := 5;
  95.     port[StatusPort] := DTROFF
  96.   end;
  97.  
  98. function ch_carck: boolean;
  99. { Check to see if carrier is present }
  100.   begin
  101.     port[StatusPort] := 0;
  102.     port[StatusPort] := RESSTA;
  103.     ch_carck := ((DCD and port[StatusPort]) <> 0)
  104.   end;
  105.  
  106. function ch_inprdy: boolean;
  107. { Check for ready to input from port }
  108. var
  109.   bt: byte;
  110. begin
  111.   if (DAV and port[StatusPort]) <> 0
  112.     then
  113.       begin
  114.         port[StatusPort] := 1;
  115.         if (ERR and port[StatusPort]) <> 0
  116.           then
  117.             begin
  118.               port[StatusPort] := RESERR;
  119.               bt := port[DataPort];
  120.               ch_inprdy := FALSE
  121.             end
  122.           else ch_inprdy := TRUE
  123.       end
  124.     else ch_inprdy := FALSE
  125. end;
  126.  
  127. function ch_inp: byte;
  128. { Input a byte from port - no wait - assumed ready }
  129.   begin
  130.     ch_inp := port[DataPort]
  131.   end;
  132.  
  133. procedure ch_out(bt: byte);
  134. { Output a byte to port - wait until ready }
  135.   begin
  136.     repeat
  137.     until ((TRDY and port[StatusPort]) <> 0);
  138.     port[DataPort] := bt
  139.   end;
  140.  
  141. procedure ch_set(r: integer);
  142. { Set the bps rate }
  143.   begin
  144.     rate := r;
  145.     case rate of
  146.        300: begin
  147.               port[RatePort] := BDSET300;
  148.               port[RatePort] := BD300
  149.             end;
  150.       1200: begin
  151.               port[RatePort] := BDSET1200;
  152.               port[RatePort] := BD1200
  153.             end
  154.     end
  155.   end;
  156.  
  157.