4 * Ullrich von Bassewitz, 19.3.1999
6 * This module is based upon the public domain swiftlink module written by
7 * Craig Bruce. Thanks a lot!
18 /*****************************************************************************/
20 /*****************************************************************************/
25 /* Baudrate settings */
26 #define RS_BAUD_50 0x00
27 #define RS_BAUD_110 0x01
28 #define RS_BAUD_134_5 0x02
29 #define RS_BAUD_300 0x03
30 #define RS_BAUD_600 0x04
31 #define RS_BAUD_1200 0x05
32 #define RS_BAUD_2400 0x06
33 #define RS_BAUD_4800 0x07
34 #define RS_BAUD_9600 0x08
35 #define RS_BAUD_19200 0x09
36 #define RS_BAUD_38400 0x0A
37 #define RS_BAUD_57600 0x0B
38 #define RS_BAUD_115200 0x0C
39 #define RS_BAUD_230400 0x0D
41 /* Data bit settings */
42 #define RS_BITS_5 0x60
43 #define RS_BITS_6 0x40
44 #define RS_BITS_7 0x20
45 #define RS_BITS_8 0x00
48 #define RS_PAR_NONE 0x00
49 #define RS_PAR_ODD 0x20
50 #define RS_PAR_EVEN 0x60
51 #define RS_PAR_MARK 0xA0
52 #define RS_PAR_SPACE 0xE0
54 /* Bit masks to mask out things from the status returned by rs232_status */
55 #define RS_STATUS_PE 0x01 /* Parity error */
56 #define RS_STATUS_FE 0x02 /* Framing error */
57 #define RS_STATUS_OVERRUN 0x04 /* Overrun error */
58 #define RS_STATUS_RDRF 0x08 /* Receiver data register full */
59 #define RS_STATUS_THRE 0x10 /* Transmit holding reg. empty */
60 #define RS_STATUS_DCD 0x20 /* NOT data carrier detect */
61 #define RS_STATUS_DSR 0x40 /* NOT data set ready */
62 #define RS_STATUS_IRQ 0x80 /* IRQ condition */
64 #elif defined(__ATARI__)
66 /* Baudrate settings */
67 #define RS_BAUD_300 0x00
68 #define RS_BAUD_45_5 0x01
69 #define RS_BAUD_50 0x02
70 #define RS_BAUD_56_875 0x03
71 #define RS_BAUD_75 0x04
72 #define RS_BAUD_110 0x05
73 #define RS_BAUD_134_5 0x06
74 #define RS_BAUD_150 0x07
75 /*#define RS_BAUD_300 0x08 alternative */
76 #define RS_BAUD_600 0x09
77 #define RS_BAUD_1200 0x0A
78 #define RS_BAUD_1800 0x0B
79 #define RS_BAUD_2400 0x0C
80 #define RS_BAUD_4800 0x0D
81 #define RS_BAUD_9600 0x0E
83 /* Data bit settings */
84 #define RS_BITS_5 0x30
85 #define RS_BITS_6 0x20
86 #define RS_BITS_7 0x10
87 #define RS_BITS_8 0x00
90 #define RS_PAR_NONE 0x00
91 #define RS_PAR_ODD 0x05
92 #define RS_PAR_EVEN 0x0A
93 #define RS_PAR_MARK 0x03
94 #define RS_PAR_SPACE 0x0C
96 /* Bit masks to mask out things from the status returned by rs232_status */
97 #define RS_STATUS_PE 0x20 /* Parity error */
98 #define RS_STATUS_FE 0x80 /* Framing error */
99 #define RS_STATUS_OVERRUN 0x40 /* Overrun error */
100 #define RS_STATUS_RDRF 0x10 /* Receiver data register full */
102 #endif /* __ATARI__ section */
104 /* Stop bit settings */
105 #define RS_STOP_1 0x00
106 #define RS_STOP_2 0x80
108 /* Error codes returned by all functions */
109 #define RS_ERR_OK 0x00 /* Not an error - relax */
110 #define RS_ERR_NOT_INITIALIZED 0x01 /* Module not initialized */
111 #define RS_ERR_BAUD_TOO_FAST 0x02 /* Cannot handle baud rate */
112 #define RS_ERR_BAUD_NOT_AVAIL 0x03 /* Baud rate not available */
113 #define RS_ERR_NO_DATA 0x04 /* Nothing to read */
114 #define RS_ERR_OVERFLOW 0x05 /* No room in send buffer */
118 /*****************************************************************************/
120 /*****************************************************************************/
124 unsigned char __fastcall__ rs232_init (char hacked);
125 /* Initialize the serial port, install the interrupt handler. The parameter
126 * must be true (non zero) for a hacked swiftlink and false (zero) otherwise.
129 unsigned char __fastcall__ rs232_params (unsigned char params, unsigned char parity);
130 /* Set the port parameters. Use a combination of the #defined values above. */
132 unsigned char __fastcall__ rs232_done (void);
133 /* Close the port, deinstall the interrupt hander. You MUST call this function
134 * before terminating the program, otherwise the machine may crash later. If
135 * in doubt, install an exit handler using atexit(). The function will do
136 * nothing, if it was already called.
139 unsigned char __fastcall__ rs232_get (char* b);
140 /* Get a character from the serial port. If no characters are available, the
141 * function will return RS_ERR_NO_DATA, so this is not a fatal error.
144 unsigned char __fastcall__ rs232_put (char b);
145 /* Send a character via the serial port. There is a transmit buffer, but
146 * transmitting is not done via interrupt. The function returns
147 * RS_ERR_OVERFLOW if there is no space left in the transmit buffer.
150 unsigned char __fastcall__ rs232_pause (void);
151 /* Assert flow control and disable interrupts. */
153 unsigned char __fastcall__ rs232_unpause (void);
154 /* Re-enable interrupts and release flow control */
156 unsigned char __fastcall__ rs232_status (unsigned char* status,
157 unsigned char* errors);
158 /* Return the serial port status. */