home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / ros / rosmisc.lbr / ROSINTR4.MZH / ROSINTR4.MCH
Encoding:
Text File  |  1986-07-28  |  3.6 KB  |  139 lines

  1. { ROS.MCH - Remote Operating System Machine Dependent Routines }
  2.  
  3. { File:        COMPUPRO.MCH
  4.   Description: This driver set is designed to support the CompuPro Interfacer-4
  5.   Date:        9/16/85
  6.   Author:      Paul Traina
  7. }
  8.  
  9. {** System routines **}
  10.  
  11. procedure system_init;
  12. { Initialization to be done once when ROS first starts }
  13.   begin
  14.   end;
  15.  
  16. procedure system_de_init;
  17. { De-initialization to be done once when ROS terminates }
  18.   begin
  19.     write(esc,'h');
  20.   end;
  21.  
  22. procedure putstat(st: StrStd);
  23. { Display 'st' on status line }
  24.   begin
  25.     write(esc,'f',^S,st,cr,esc,'g');
  26.   end;
  27.  
  28. {** Remote channel routines **}
  29.  
  30. { Port locations }
  31.  
  32. const
  33.   DataPort   = $10;          { Data port }
  34.   StatusPort = $11;          { Status port }
  35.   ModePort   = $12;          { Mode port }
  36.   CtrlPort   = $13;          { Control port }
  37.   UserPort   = $17;          { Chip select port }
  38.   Chip       =   6;          { Chip to send to for modem }
  39.  
  40. { ModePort commands }
  41.  
  42.   B8NO1      = $4E;          { 8 data bits, no parity, 1 stop bit  }
  43.   B8NO2      = $EE;          { 8 data bits, no parity, 2 stop bits }
  44.   BD110      = $32;          { 110  baud }
  45.   BD300      = $35;          { 300  baud }
  46.   BD600      = $36;          { 600  baud }
  47.   BD1200     = $37;          { 1200 baud }
  48.   BD2400     = $3A;          { 2400 baud }
  49.  
  50. { ControlPort commands }
  51.  
  52.   MDMON      = $27;          { Turn on DTR & RTS }
  53.   RESERR     = $30;          { Reset error condition }
  54.   MDMOFF     = $00;          { Turn off everything }
  55.  
  56. { StatusPort status masks }
  57.  
  58.   TBMT       = $01;          { transmit buffer empty }
  59.   DAV        = $02;          { data available }
  60.   PE         = $08;          { parity error }
  61.   OE         = $10;          { overrun error }
  62.   FE         = $20;          { framing error }
  63.   ERR        = $38;          { PE + OE + FE }
  64.   DCD        = $80;          { data carrier detect (using DSR line) }
  65.  
  66. {----------------------------------------------------------------}
  67.  
  68. procedure ch_init;
  69. { Initialize the remote channel }
  70.   begin
  71.   end;
  72.  
  73. procedure ch_on;
  74. { Turn on remote channel (usually by enabling DTR) }
  75.   begin
  76.     port[UserPort] := Chip;
  77.     port[CtrlPort] := MDMON
  78.   end;
  79.  
  80. procedure ch_off;
  81. { Turn on remote channel (usually by disabling DTR) }
  82.   begin
  83.     port[UserPort] := Chip;
  84.     port[CtrlPort] := MDMOFF
  85.   end;
  86.  
  87. function ch_carck: boolean;
  88. { Check to see if carrier is present }
  89.   begin
  90.     port[UserPort] := Chip;
  91.     ch_carck := (DCD and port[StatusPort]) <> 0
  92.   end;
  93.  
  94. function ch_inprdy: boolean;
  95. { Check for ready to input from port }
  96.   var
  97.     bt: byte;
  98.   begin
  99.     port[UserPort] := Chip;
  100.     ch_inprdy := (DAV and port[StatusPort]) <> 0
  101.   end;
  102.  
  103. function ch_inp: byte;
  104. { Input a byte from port - no wait - assumed ready }
  105.   begin
  106.     port[UserPort] := Chip;
  107.     ch_inp := port[DataPort]
  108.   end;
  109.  
  110. procedure ch_out(bt: byte);
  111. { Output a byte to port - wait until ready }
  112.   var ok : boolean;
  113.       xx : byte;
  114.   begin
  115.     repeat
  116.       port[UserPort] := Chip;
  117.     until (port[StatusPort] and TBMT) <>0;
  118.     port[DataPort] := bt
  119.   end;
  120.  
  121. procedure ch_set(rate: integer);
  122. { Set the bps rate }
  123.   var
  124.     dummy : byte;
  125.   begin
  126.     port[UserPort] := Chip;
  127.     dummy := port[CtrlPort];
  128.     if rate = 110
  129.       then port[ModePort] := B8NO2
  130.       else port[ModePort] := B8NO1;
  131.     case rate of
  132.       110:  port[ModePort] := BD110;
  133.       300:  port[ModePort] := BD300;
  134.       600:  port[ModePort] := BD600;
  135.       1200: port[ModePort] := BD1200;
  136.       2400: port[ModePort] := BD2400
  137.     end
  138.   end;
  139.