home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / SYSUTL / 16550S13.ZIP / 16550_T.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1991-03-29  |  5.0 KB  |  167 lines

  1. {**************************************************************************
  2.  
  3. 16550 - A TPBoard Sysop Utility
  4. by Jon Schneider & Rick Petersen
  5.  
  6. This program will toggle the state of a 16550 UART's FIFO buffer.
  7. It only seems to work with the Fossil driver X00.SYS version 1.09b.
  8. By toggling the buffer on, even 4.77 Mhz PC's are able to receive
  9. files at a fixed rate of 19,200 baud without error.
  10.  
  11. The code uses portions of the 'Turbo Professional' library. It
  12. will not compile without it.
  13.  
  14. v1.1 Oh yeah?
  15.      Toad Hall Tweak, 19 Apr 90
  16.   - Wrote the single stupid string-uppercasing function
  17.     that required the "Turbo Professional" library.
  18.   - Tightened up the code.
  19.   - Replaced "original" variable names with more "usual" ones
  20.     (like argc).
  21.   - Changed source case to my preferred standards.
  22.   - This code makes NO attempt to confirm if you have a 16550 UART or not.
  23.     (Heck, I donno HOW to make such a test.)
  24.     If you run this on your good old 8550 or whatever .. who know WHAT'll
  25.     happen, ne?
  26. v1.2 Another minor tweak.
  27. v1.3 29 Mar 91:
  28.     Finally found a UART-identifying function (FIDO Assembly Language Echo).
  29.     Integrating that code (tweaked, of course).
  30.  
  31.     David Kirschbaum
  32.     Toad Hall
  33.  
  34. **************************************************************************}
  35.  
  36. {$R-}    {Range checking off}
  37. {$B-}    {Boolean complete evaluation off}
  38. {$S-}    {Stack checking off}
  39. {$I+}    {I/O checking on}
  40. {$N-}    {No numeric coprocessor}
  41. {$M $4000, $4000, $A0000}
  42.  
  43.  
  44. PROGRAM a16550;
  45.  
  46. TYPE
  47.   uarttype = (u_unk,u8250,u16450,u16550,u16550A);  {v1.3}
  48.   Str6 = STRING[6];
  49.  
  50. CONST
  51.   UartStr : ARRAY[uarttype] OF Str6 =     {v1.3}
  52.             ('??????','  8250',' 16450',' 16550','16550A');
  53.  
  54. VAR
  55.    State : STRING;
  56.    comport : Word;
  57.    i,code : INTEGER;
  58.  
  59. PROCEDURE Usage;
  60. BEGIN
  61.    WRITELN;
  62.    WRITELN('16550 - A TPBoard utility for toggling the 16550''s FIFO buffer');
  63.    WRITELN;
  64.    WRITELN('USAGE:  16550 [1-4] [on/off/?]');
  65.    WRITELN;
  66.    WRITELN('Where ''1'' thru ''4'' is the COM port,  ''on'' or ''off'' will toggle');
  67.    WRITELN('the FIFO buffer''s state, and ''?'' will show its status. Turning');
  68.    WRITELN('the buffered mode on is guaranteed to lock up your system if you');
  69.    WRITELN('are using OpusCom, and may cause problems with other programs.');
  70.    WRITELN('It WILL work with X00 version 1.09b, TPBoard, and ProComm Plus.');
  71.    WRITELN;
  72.    HALT
  73. END;
  74.  
  75.  
  76. FUNCTION StUpcase(S : STRING) : STRING;
  77.   {v1.1 Return S uppercased}
  78.   VAR i : INTEGER;
  79.   BEGIN
  80.     FOR i := 1 TO LENGTH(S) DO
  81.       S[i] := Upcase(S[i]);
  82.     StUpcase := S;  {return the function}
  83.   END;   {of StUpcase}
  84.  
  85.  
  86. FUNCTION Type_Uart(comport : INTEGER) : uarttype;
  87.   {v1.03 Return type UART}
  88.   VAR
  89.     xbyte2,xbyte3 : BYTE;
  90.     temp : INTEGER;
  91.     u : uarttype;
  92.     p2,p7 : word;
  93.    BEGIN
  94.     p2 := comport+2;
  95.     p7 := comport+7;
  96.     xbyte2 := Port[p2];
  97.     Port[p2] := $C1;
  98.     FOR temp := 1 TO 2 DO;           {delay a tick}
  99.     xbyte3 := Port[p2];
  100.     Port[p2] := xbyte2;
  101.     CASE ((xbyte3 AND $C0) ShR 6) OF
  102.       0: BEGIN
  103.            xbyte2 := Port[p7];
  104.            Port[p7] := $FA;
  105.            FOR temp := 1 TO 2 DO;
  106.            IF Port[p7] = $FA THEN BEGIN
  107.              Port[p7] := $AF;
  108.              FOR temp := 1 TO 2 DO;
  109.              IF Port[p7] = $AF THEN BEGIN
  110.                 Port[p7] := xbyte2;
  111.                u := u16450;
  112.              END
  113.              ELSE u := u8250;
  114.            END
  115.            ELSE u := u8250;
  116.          END;
  117.       1: u := u_unk;
  118.       2: u := u16550;
  119.       3: u := u16550A;
  120.     END;  {case}
  121.     Writeln('UART type:  ',UartStr[u]);  {say something clever}
  122.     Type_Uart := u;  {return function}
  123.   END;  {of Type_Uart}
  124.  
  125.  
  126. BEGIN  { 16550 }
  127.    IF ParamCount < 2       {need 2 parms v1.2}
  128.    THEN Usage;             {dummy v1.2}
  129.  
  130. (* Old code
  131.    State := ParamStr(1);   {v1.2}
  132.    Ch := State[1];         {can't do this to ParamStr(),
  133.                             but CHAR comparisons are SO much faster v1.2}
  134.    IF      Ch = '1' THEN comport := $3fa
  135.    ELSE IF Ch = '2' THEN comport := $2fa
  136.    ELSE IF Ch = '3' THEN comport := $3ea
  137.    ELSE IF Ch = '4' THEN comport := $2ea
  138.    ELSE Usage;
  139. *)
  140.    {v1.2, v1.3: new code}
  141.    Val(ParamStr(1),i,code);       {Pick up 1..4}
  142.    IF (code <> 0)                 {not a number}
  143.    OR NOT (i IN [1..4])           {not in range COM1..COM4}
  144.    THEN Usage;                    {dummy}
  145.  
  146.    comport := MemW[$40 : Pred(i) ShL 1 ];  {40:00 = COM1,
  147.                                             40:02 = COM2, etc.}
  148.  
  149.    IF NOT (Type_Uart(comport) IN [u16550,u16550A])
  150.    THEN BEGIN
  151.      Writeln('Sorry: FIFO buffer only in the 16550 family');
  152.      Halt(1);
  153.    END;
  154.  
  155.    State := StUpcase(ParamStr(2));
  156.    IF      State = 'ON'  THEN Port[comport] := $07
  157.    ELSE IF State = 'OFF' THEN Port[comport] := $00
  158.    ELSE IF State = '?' THEN BEGIN
  159.        {v1.1 New code}
  160.        WRITE('FIFO buffer is turned ');
  161.        IF (Port[comport] AND $C0) = $C0
  162.        THEN WRITELN('ON.')
  163.        ELSE WRITELN('OFF.');
  164.    END
  165.    ELSE Usage;
  166. END.
  167.