home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / ros / rosmisc.lbr / ROSAMPRO.MZH / ROSAMPRO.MCH
Encoding:
Text File  |  1986-07-28  |  5.0 KB  |  185 lines

  1. { ROS.MCH - Remote Operating System Machine Dependent Routines }
  2.  
  3. { File:        ROSAMPRO.MCH
  4.   Description: This driver set is designed to support the Ampro "Little Board".
  5.   Date:        7-Jan-86
  6.   Author:      Charles Blanchard
  7.  
  8.   Modified from BB2.MCH for the Ferguson BigBoard II
  9.   written by Steve Fox 03-Aug-85.
  10.  
  11.   Hardware supported :
  12.        AMPRO "Little Board" 
  13.        DART I/O and CTC timer 2.000 MHz
  14.   This version is for the AMPRO "Little Board" using channel "B" of the
  15.   Z80 DART.  The Z80-CTC is used as the baud rate generator.
  16.  
  17.        The AMPRO computer does not implement DTR or DCD
  18.        (CTS and RTS are used instead - however they take
  19.        the CTS to the AMPRO pin 20!)
  20.  
  21.        Make up a RS232 cable per the instructions below:
  22.  
  23.             Modem       Ampro
  24.             -----       -----
  25.             pin 2    -  pin 3
  26.             pin 3    -  pin 2
  27.             pin 7    -  pin 7
  28.             pin 8    -  pin 20
  29.             pin 20    -  pin 5
  30.  
  31.   Note: These pin assignments assume that your Little Board RS232 female
  32.   connector is wired the same as the Ampro assembled computers.
  33.  
  34. }
  35.  
  36. {** System routines **}
  37.  
  38. procedure system_init;
  39. { Initialization to be done once when ROS first starts }
  40.   begin
  41.   end;
  42.  
  43. procedure system_de_init;
  44. { De-initialization to be done once when ROS terminates }
  45.   begin
  46.   end;
  47.  
  48. procedure putstat(st: StrStd);
  49. { Display 'st' on status line }
  50.   const
  51.     status_line    =  1;                    { Line used for system status }
  52.     last_line      = 24;                    { Last line on screen }
  53.   begin
  54.     GotoXY(1, status_line);
  55.     ClrEol;
  56.     LowVideo;
  57.     write(st);
  58.     HighVideo;
  59.     GotoXY(1, last_line)
  60.   end;
  61.  
  62. {** Remote channel routines **}
  63.  
  64. const
  65.  
  66. { Port locations for a modem connected to the channel "B" of }
  67. { the Z80 DART }
  68.  
  69.   DataPort   = $88;                         { Data port }
  70.   StatusPort = $8C;                         { Status port }
  71.  
  72.   CTCrate    = $50;                         { CTC rate }
  73.  
  74. { StatusPort commands }
  75.  
  76.   RESSTA     = $10;                         { Reset ext/status }
  77.   RESCHN     = $18;                         { Reset channel }
  78.   RESERR     = $30;                         { Reset error }
  79.   WRREG1     = $00;                         { Value to write to register 1 }
  80.   WRREG3     = $C1;                         { 8 bits/char, RX enable }
  81.   WRREG4     = $84;                         { 32x, 1 stop bit, no parity }
  82.   DTROFF     = $68;                         { DTR off, RTS off }
  83.   DTRON      = $EA;                         { DTR on, 8 bits/char, TX enable, RTS on }
  84.  
  85. { StatusPort masks }
  86.  
  87.   DAV        = $01;                         { Data available }
  88.   TRDY       = $04;                         { Transmit buffer empty }
  89.   DCD        = $20;                         { Data carrier detect }
  90.   PE         = $10;                         { Parity error }
  91.   OE         = $20;                         { Overrun error }
  92.   FE         = $40;                         { Framing error }
  93.   ERR        = $70;                         { Parity, overrun and framing error }
  94.  
  95. { Rate setting commands }
  96.  
  97.   MODEW      = $47;
  98.   BD300      = $D0;                         {  300 bps }
  99.   BD1200     = $34;                         { 1200 bps }
  100.   BD2400     = $1A;                         { 2400 bps }
  101.  
  102. procedure ch_init;
  103. { Initialize the remote channel }
  104.   const
  105.     sio_init: array[1..8] of byte =
  106.       (0, RESCHN, 4, WRREG4, 1, WRREG1, 3, WRREG3);
  107.   var
  108.     i: integer;
  109.   begin
  110.     for i := 1 to 8 do
  111.       port[StatusPort] := sio_init[i]
  112.   end;
  113.  
  114. procedure ch_on;
  115. { Turn on remote channel (usually by enabling DTR) }
  116.   begin
  117.     port[StatusPort] := 5;
  118.     port[StatusPort] := DTRON
  119.   end;
  120.  
  121. procedure ch_off;
  122. { Turn on remote channel (usually by disabling DTR) }
  123.   begin
  124.     port[StatusPort] := 5;
  125.     port[StatusPort] := DTROFF
  126.   end;
  127.  
  128. function ch_carck: boolean;
  129. { Check to see if carrier is present }
  130.   begin
  131.     port[StatusPort] := 0;
  132.     port[StatusPort] := RESSTA;
  133.     ch_carck := ((DCD and port[StatusPort]) <> 0)
  134.   end;
  135.  
  136. function ch_inprdy: boolean;
  137. { Check for ready to input from port }
  138. var
  139.   bt: byte;
  140. begin
  141.   if (DAV and port[StatusPort]) <> 0
  142.     then
  143.       begin
  144.         port[StatusPort] := 1;
  145.         if (ERR and port[StatusPort]) <> 0
  146.           then
  147.             begin
  148.               port[StatusPort] := RESERR;
  149.               bt := port[DataPort];
  150.               ch_inprdy := FALSE
  151.             end
  152.           else ch_inprdy := TRUE
  153.       end
  154.     else ch_inprdy := FALSE
  155. end;
  156.  
  157. function ch_inp: byte;
  158. { Input a byte from port - no wait - assumed ready }
  159.   begin
  160.     ch_inp := port[DataPort]
  161.   end;
  162.  
  163. procedure ch_out(bt: byte);
  164. { Output a byte to port - wait until ready }
  165.   begin
  166.     repeat
  167.     until ((TRDY and port[StatusPort]) <> 0);
  168.     port[DataPort] := bt
  169.   end;
  170.  
  171. procedure ch_set(r: integer);
  172. { Set the bps rate }
  173. var speed : integer;
  174.   begin
  175.     rate := r;
  176.     case rate of
  177.        300: speed := BD300;
  178.       1200: speed := BD1200;
  179.       2400: speed := BD2400
  180.     end;
  181.     port[CTCrate]   := MODEW;
  182.     port[CTCrate]   := speed;
  183.   end;
  184.  
  185.