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 /*****************************************************************************/
24 /* Baudrate settings */
25 #define RS_BAUD_50 0x00
26 #define RS_BAUD_110 0x01
27 #define RS_BAUD_134_5 0x02
28 #define RS_BAUD_300 0x03
29 #define RS_BAUD_600 0x04
30 #define RS_BAUD_1200 0x05
31 #define RS_BAUD_2400 0x06
32 #define RS_BAUD_4800 0x07
33 #define RS_BAUD_9600 0x08
34 #define RS_BAUD_19200 0x09
35 #define RS_BAUD_38400 0x0A
36 #define RS_BAUD_57600 0x0B
37 #define RS_BAUD_115200 0x0C
38 #define RS_BAUD_230400 0x0D
40 /* Stop bit settings */
41 #define RS_STOP_1 0x00
42 #define RS_STOP_2 0x80
44 /* Data bit settings */
45 #define RS_BITS_5 0x60
46 #define RS_BITS_6 0x40
47 #define RS_BITS_7 0x20
48 #define RS_BITS_8 0x00
51 #define RS_PAR_NONE 0x00
52 #define RS_PAR_ODD 0x20
53 #define RS_PAR_EVEN 0x60
54 #define RS_PAR_MARK 0xA0
55 #define RS_PAR_SPACE 0xE0
57 /* Bit masks to mask out things from the status returned by rs232_status */
58 #define RS_STATUS_PE 0x01 /* Parity error */
59 #define RS_STATUS_FE 0x02 /* Framing error */
60 #define RS_STATUS_OVERRUN 0x04 /* Overrun error */
61 #define RS_STATUS_RDRF 0x08 /* Receiver data register full */
62 #define RS_STATUS_THRE 0x10 /* Transmit holding reg. empty */
63 #define RS_STATUS_DCD 0x20 /* NOT data carrier detect */
64 #define RS_STATUS_DSR 0x40 /* NOT data set ready */
65 #define RS_STATUS_IRQ 0x80 /* IRQ condition */
67 /* Error codes returned by all functions */
68 #define RS_ERR_OK 0x00 /* Not an error - relax */
69 #define RS_ERR_NOT_INITIALIZED 0x01 /* Module not initialized */
70 #define RS_ERR_BAUD_TOO_FAST 0x02 /* Cannot handle baud rate */
71 #define RS_ERR_BAUD_NOT_AVAIL 0x03 /* Baud rate not available */
72 #define RS_ERR_NO_DATA 0x04 /* Nothing to read */
73 #define RS_ERR_OVERFLOW 0x05 /* No room in send buffer */
77 /*****************************************************************************/
79 /*****************************************************************************/
83 unsigned char __fastcall__ rs232_init (char hacked);
84 /* Initialize the serial port, install the interrupt handler. The parameter
85 * must be true (non zero) for a hacked swiftlink and false (zero) otherwise.
88 unsigned char __fastcall__ rs232_params (unsigned char params, unsigned char parity);
89 /* Set the port parameters. Use a combination of the #defined values above. */
91 unsigned char __fastcall__ rs232_done (void);
92 /* Close the port, deinstall the interrupt hander. You MUST call this function
93 * before terminating the program, otherwise the machine may crash later. If
94 * in doubt, install an exit handler using atexit(). The function will do
95 * nothing, if it was already called.
98 unsigned char __fastcall__ rs232_get (char* b);
99 /* Get a character from the serial port. If no characters are available, the
100 * function will return RS_ERR_NO_DATA, so this is not a fatal error.
103 unsigned char __fastcall__ rs232_put (char b);
104 /* Send a character via the serial port. There is a transmit buffer, but
105 * transmitting is not done via interrupt. The function returns
106 * RS_ERR_OVERFLOW if there is no space left in the transmit buffer.
109 unsigned char __fastcall__ rs232_pause (void);
110 /* Assert flow control and disable interrupts. */
112 unsigned char __fastcall__ rs232_unpause (void);
113 /* Re-enable interrupts and release flow control */
115 unsigned char __fastcall__ rs232_status (unsigned char* status,
116 unsigned char* errors);
117 /* Return the serial port status. */