home *** CD-ROM | disk | FTP | other *** search
- Unit JRCOM201 ;
-
- (*╔═════════════════════════════════════════════════════════════════════════╗*)
- (*║ ║*)
- (*║ JR Unit Library - Version 2.01 - June xxrd 1988 ║*)
- (*║ ║*)
- (*║ Serial port functions and procedures ║*)
- (*║ ║*)
- (*╚═════════════════════════════════════════════════════════════════════════╝*)
-
- Interface
-
- (*───────────────────────────────────────────────────────────────────────────*)
-
- Uses Dos , JRBIT201 ;
-
- (*───────────────────────────────────────────────────────────────────────────*)
-
- Const _BIOSSerialService = $14 ;
-
-
- _COM1 = 0 ; _COM2 = 1 ;
-
- _110baud = $00 ; _150baud = $20 ; _300baud = $40 ; _600baud = $60 ;
- _1200baud = $80 ; _2400baud = $A0 ; _4800baud = $C0 ; _9600baud = $E0 ;
-
- _none = $00 ; _odd = $08 ; _even = $18 ;
-
- _one = $00 ; _two = $04 ;
-
- _7bit = $02 ; _8bit = $03 ;
-
- _on = 1 ; _off = 0 ;
-
- _portadr : Array(.0..1.) Of Word = ($3F8,$2F8) ;
-
- (*───────────────────────────────────────────────────────────────────────────*)
-
- Var _regs8086 : Registers ;
-
- (*───────────────────────────────────────────────────────────────────────────*)
-
- Procedure _InitComPort(_portnr , _baudrate , _parity ,
- _stopbit , _charsize : Byte ;
- Var _error : Integer) ;
- Procedure _Send1Char(_portnr : Word ;
- _char : Char ;
- Var _error : Byte) ;
- Procedure _Read1Char(_portnr : Word ;
- Var _char : Char ;
- Var _error : Byte) ;
- Function _SerialPortStatus(_portnr : Word) : Integer ;
- Procedure _SetDTR(_portnr,_mode : Word) ;
- Procedure _SetRTS(_portnr,_mode : Word) ;
- Function _CTS(_portnr : Word) : Boolean ;
- Function _DSR(_portnr : Word) : Boolean ;
- Function _RI(_portnr : Word) : Boolean ;
- Function _CD(_portnr : Word) : Boolean ;
-
-
- (*───────────────────────────────────────────────────────────────────────────*)
-
- Implementation
-
- (*───────────────────────────────────────────────────────────────────────────*)
-
- Procedure _InitComPort ;
- (* Version 1.01 *)
- (* Modified 1.02 *)
- Begin ;
- With _regs8086 Do Begin ;
- ah:=0 ; dx:=_portnr ;
- al:=_baudrate Or _parity Or _stopbit Or _charsize ;
- End ;
- Intr(_BIOSSerialService,_regs8086) ;
- _error:=_regs8086.ax ;
- End (* Procedure _InitComPort *) ;
-
- (*───────────────────────────────────────────────────────────────────────────*)
-
- Procedure _Send1Char ;
- (* Version 1.02 *)
- (* Ej kollad *)
- Begin ;
- With _regs8086 Do Begin ;
- ah:=1 ; (* Service 1 *)
- al:=Ord(_char) ; (* Character to be send *)
- dx:=_portnr ; (* Define com port *)
- End ;
- Intr(_BIOSSerialService,_regs8086) ;
- _error:=_regs8086.ah ;
- End (* Procedure Send1Char *) ;
-
- (*───────────────────────────────────────────────────────────────────────────*)
-
- Procedure _Read1Char ;
- (* Version 1.02 *)
- (* Ej kollad *)
- Begin ;
- With _regs8086 Do Begin ;
- ah:=2 ; (* Service 2 *)
- dx:=_portnr ; (* Define com port *)
- End ;
- Intr(_BIOSSerialService,_regs8086) ;
- _char:=Chr(_regs8086.al) ;
- _error:=_regs8086.ah ;
- End (* Procedure Read1Char *) ;
-
- (*───────────────────────────────────────────────────────────────────────────*)
-
- Function _SerialPortStatus ;
- (* Version 1.01 *)
- (* Modified 1.02 *)
- Begin ;
- With _regs8086 Do Begin ;
- ah:=3 ; dx:=_portnr ;
- End ;
- Intr(_BIOSSerialService,_regs8086) ;
- _SerialPortStatus:=_regs8086.ax ;
- End (* Function _SerialPortStatus *) ;
-
-
- (*───────────────────────────────────────────────────────────────────────────*)
-
- Procedure _SetDTR ;
- (* Version 2.01 *)
- Var _b : Byte ;
- Begin ;
- _b:=Port(._portadr(._portnr.)+5.) ;
- If (_mode=_on) Then _SetBit(_b,0) Else _ResetBit(_b,0) ;
- Port(._portadr(._portnr.)+5.):=_b ;
- End (* Procedure _SetDTR *) ;
-
- (*───────────────────────────────────────────────────────────────────────────*)
-
- Procedure _SetRTS ;
- (* Version 2.01 *)
- Var _b : Byte ;
- Begin ;
- _b:=Port(._portadr(._portnr.)+5.) ;
- If (_mode=_on) Then _SetBit(_b,1) Else _ResetBit(_b,1) ;
- Port(._portadr(._portnr.)+5.):=_b ;
- End (* Procedure _SetRTS *) ;
-
- (*───────────────────────────────────────────────────────────────────────────*)
-
- Function _CTS ;
- (* Version 2.01 *)
- Begin ;
- _CTS:=_Bit(Port(._portadr(._portnr.)+6.),4) ;
- End (* Function _CTS *) ;
-
- (*───────────────────────────────────────────────────────────────────────────*)
-
- Function _DSR ;
- (* Version 2.01 *)
- Begin ;
- _DSR:=_Bit(Port(._portadr(._portnr.)+6.),5) ;
- End (* Function _DSR *) ;
-
- (*───────────────────────────────────────────────────────────────────────────*)
-
- Function _RI ;
- (* Version 2.01 *)
- Begin ;
- _RI:=_Bit(Port(._portadr(._portnr.)+6.),6) ;
- End (* Function _RI *) ;
-
- (*───────────────────────────────────────────────────────────────────────────*)
-
- Function _CD ;
- (* Version 2.01 *)
- Var _b : Byte ;
- Begin ;
- _CD:=_Bit(Port(._portadr(._portnr.)+6.),7) ;
- End (* Function _CD *) ;
-
- (*───────────────────────────────────────────────────────────────────────────*)
-
- End (* Of Unit JRCOM201 *).
-