home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Crawly Crypt Collection 2
/
crawlyvol2.bin
/
program
/
pascal
/
pasdox
/
port.txt
< prev
next >
Wrap
Text File
|
1985-11-18
|
6KB
|
172 lines
{ -----------------------------------------------------------------------------
NOTICE:
THESE MATERIALS are UNSUPPORTED by OSS! If you do not understand how to
use them do not contact OSS for help! We will not teach you how to
program in Pascal. If you find an error in these materials, feel free
to SEND US A LETTER explaining the error, and how to fix it.
THE BOTTOM LINE:
Use it, enjoy it, but you are on your own when using these materials!
DISCLAIMER:
OSS makes no representations or warranties with respect to the contents
hereof and specifically disclaim all warranties of merchantability or
fitness for any particular purpose. This document is subject to change
without notice.
OSS provides these materials for use with Personal Pascal. Use them in
any way you wish.
-------------------------------------------------------------------------- }
Port Configuration Page 1
Configuring the I/O Ports
If you are writing a program which performs I/O to one of the devices that
connect to the back of the ST (i.e., a printer or a modem), you will probably
want to set the configuration at some time or other. If you are writing a GEM
application and you are content to use the desk accessories to allow the user
to configure the ports, you can skip this section. However, the desk
accessories don't always set up the configuration properly, so be careful! In
any case, if you want to set the configuration of the RS232 port or the
parallel port, you need to know a few calls:
Set the printer configuration.
We'll investigate the printer configuration first, since there are fewer
parameters to explain. The following XBIOS call allows you to configure the
printer:
FUNCTION setprt( config : integer ) : integer ;
XBIOS( 33 ) ;
In order to set or get the current printer configuration, you should use this
call. If config is -1, the current configuration is passed back as the return
value. Otherwise, config specifies the desired configuration of the printer.
The various bits within config specify the configuration as follows:
bit# when 0 when 1
---- ---------------- -----------------
0 dot matrix daisy wheel
1 color printer monochrome
2 Atari printer Epson compatible
3 draft mode final mode
4 parallel port RS232 port
5 continuous paper single sheet
6 reserved
7 reserved
8 reserved
9 reserved
10 reserved
11 reserved
12 reserved
13 reserved
14 reserved
15 MUST BE ZERO!
Configure the RS232 port.
OK, on to the RS232 configuration. The following XBIOS call sets the various
parameters controlling the RS232 port:
PROCDURE rsconf( speed, flowctl, ucr, rsr, tsr, scr : integer ) ;
XBIOS( 15 ) ;
If any of the parameters is -1, the corresponding RS232 parameter is left
unchanged from its previous value. You will mostly be dealing with setting
the baud rate, which is governed by the speed parameter:
Port Configuration Page 2
speed rate
----- -----
0 19200
1 9600
2 4800
3 3600
4 2400
5 2000
6 1800
7 1200
8 600
9 300
10 200
11 150
12 134
13 110
14 75
15 50-
The last value, 15, may not generate an accurate (as if you'll ever need it!).
You may also need to change the flow-control option of the RS232 port. It is
specified in the flow parameter as follows:
flow flow-control
---- ------------
0 No flow control
1 XON/XOFF (control-S/control-Q)
2 RTS/CTS
3 XON/XOFF and RTS/CTS
The value 3 doesn't represent a very useful condition, but it should work.
The other four parameters set registers within the 68901 chip (for a more
complete, but still sketchy, discussion, see the book ST Internals). These
registers perform the following functions:
register function
-------- --------
ucr USART control register
rsr Receiver status register
tsr Transmitter status register
scr Synchronous character register
If you are transmitting in asynchronous mode (i.e, almost always), you will
probably only use the ucr parameter, which has the following meanings:
ucr bits function
-------- --------
0 unused
1 parity type: 0=odd 1=even
2 parity enable: 0=no parity 1=parity
4,3 0,0 -> synchronous mode (all others asynch)
0,1 -> 1 start bit, 1 stop bit
1,1 -> 1 start bit, 2 stop bits
6,5 number of data bits
0,0 -> 8 bits
0,1 -> 7
1,0 -> 6
Port Configuration Page 3
1,1 -> 5
7 transmit and receive frequency
0 -> divide by 1 (synchronous only)
1 -> divide by 16
If you want to use the rsr, tsr, or scr registers, please refer elsewhere for
more documentation on the 68901 chip (ST Internals, for example).
◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆