DeskLib 2.90a:Serial.h


Contents


Introduction and Overview

This provides an interface to the serial port SWIs.


Functions


Serial_Activate

os_error * Serial_Activate(void );

This function activates the serial drivers. It is equivalent to OS_Byte 2,2.


Serial_Deactivate

os_error * Serial_Deactivate(void );

This function deactivates the serial drivers. It is equivalent to OS_Byte 2,0.


Serial_GetStatus

int Serial_GetStatus(void );

This function returns the current state of the serial port, as given by OS_SerialOp 0. There are various #defined macros to give meaningful names to the returned flags.


Serial_SetStatus

os_error * Serial_SetStatus(int eor_mask, int and_mask);

This function sets the current status of the serial port using OS_SerialOp 0. There are various #defined macros to give meaningful names to the status flags.

The new state is given by: new_state = (old_state AND and_mask) EOR eor_mask.


Serial_GetFormat

int Serial_GetFormat(void );

This function returns the current data format for transmission/reception of characters on the serial line. There are various #defined macros to give meaningful names to the format flags.


Serial_SetFormat

os_error * Serial_SetFormat(int format);

This function sets the current data format for transmission/reception of characters on the serial line. There are various #defined macros to give meaningful names to the format flags.


Serial_GetTxRate

serial_rate Serial_GetTxRate(void );

This function returns the current speed used for transmission of characters on the serial line.


Serial_GetRxRate

serial_rate Serial_GetRxRate(void );

This function returns the current speed used for reception of characters on the serial line.


Serial_SetTxRate

os_error * Serial_SetTxRate(serial_rate rate);

This function sets the speed to use for transmission of characters on the serial line.


Serial_SetRxRate

os_error * Serial_SetRxRate(serial_rate rate);

This function sets the speed to use for reception of characters on the serial line.


Serial_GetByte

int Serial_GetByte(void );

Reads a byte from the serial input buffer if one is available, otherwise returns -1.


Serial_PutByte

BOOL Serial_PutByte(int c);

Inserts a byte to be transmitted into the serial output buffer if there is room. It returns ERROR if it was unable to send the byte.


Serial_SendBreak

os_error * Serial_SendBreak(int length);

Transmits a break of the specified length in centiseconds.


Serial_NonZeroPollWordOnReceive

void Serial_NonZeroPollWordOnReceive(int pollword_value, void *pollword);

This function installs a piece of code on the InsV vector to monitor the insertion of characters into the serial input buffer. It will modify the supplied pollword to the given value whenever an insertion occurs. Also, an atexit function is registered to remove the vector claimant and the RMA based code.


Macros


serial_USEXONXOFF

#define serial_USEXONXOFF             0x00000001

A bit in a status word


serial_IGNOREDCDBIT

#define serial_IGNOREDCDBIT           0x00000002

A bit in a status word


serial_IGNOREDSRBIT

#define serial_IGNOREDSRBIT           0x00000004

A bit in a status word


serial_DTROFF

#define serial_DTROFF                 0x00000008

A bit in a status word


serial_IGNORECTSBIT

#define serial_IGNORECTSBIT           0x00000010

A bit in a status word


serial_DONTUSERTSFLOWCONTROL

#define serial_DONTUSERTSFLOWCONTROL  0x00000020

A bit in a status word


serial_SUPPRESSINPUT

#define serial_SUPPRESSINPUT          0x00000040

A bit in a status word


serial_RTSHIGH

#define serial_RTSHIGH                0x00000080

A bit in a status word


serial_XOFFRECEIVED

#define serial_XOFFRECEIVED           0x00010000

A bit in a status word


serial_XOFFSENT

#define serial_XOFFSENT               0x00020000

A bit in a status word


serial_DCDHIGH

#define serial_DCDHIGH                0x00040000

A bit in a status word


serial_NOCARRIER

#define serial_NOCARRIER              0x00040000

A bit in a status word


serial_DSRHIGH

#define serial_DSRHIGH                0x00080000

A bit in a status word


serial_RIHIGH

#define serial_RIHIGH                 0x00100000

A bit in a status word


serial_CTSHIGH

#define serial_CTSHIGH                0x00200000

A bit in a status word


serial_XOFFSENTMANUALLY

#define serial_XOFFSENTMANUALLY       0x00400000

A bit in a status word


serial_SPACEINRECEIVEBUFFER

#define serial_SPACEINRECEIVEBUFFER   0x00800000

A bit in a status word


serial_8BITWORD

#define serial_8BITWORD         0x00000000

A "setting" in a serial I/O format word. This denotes that 8 bit words are being used.


serial_7BITWORD

#define serial_7BITWORD         0x00000001

A "setting" in a serial I/O format word. This denotes that 7 bit words are being used.


serial_6BITWORD

#define serial_6BITWORD         0x00000002

A "setting" in a serial I/O format word. This denotes that 6 bit words are being used.


serial_5BITWORD

#define serial_5BITWORD         0x00000003

A "setting" in a serial I/O format word. This denotes that 5 bit words are being used.


serial_1STOPBIT

#define serial_1STOPBIT         0x00000000

A "setting" in a serial I/O format word. This denotes that 1 stop bit is being used.


serial_2STOPBITS

#define serial_2STOPBITS        0x00000004

A "setting" in a serial I/O format word. This denotes that 2 stop bits are being used in most cases, 1 stop bit is being used if 8 bit word with parity is being used, and 1.5 stop bits if a 5 bit word without parity of being used.


serial_NOPARITY

#define serial_NOPARITY         0x00000000

A "setting" in a serial I/O format word. This denotes that parity is disabled.


serial_PARITY

#define serial_PARITY           0x00000008

A "setting" in a serial I/O format word. This denotes that parity is enabled.


serial_ODDPARITY

#define serial_ODDPARITY        0x00000000

A "setting" in a serial I/O format word. This denotes odd parity.


serial_EVENPARITY

#define serial_EVENPARITY       0x00000010

A "setting" in a serial I/O format word. This denotes even parity.


serial_MARKPARITY

#define serial_MARKPARITY       0x00000020

A "setting" in a serial I/O format word. This denotes that parity is always 1 on TX and ignored on RX.


serial_SPACEPARITY

#define serial_SPACEPARITY      0x00000030

A "setting" in a serial I/O format word. This denotes that parity is always 0 on TX and ignored on RX.


Type


serial_rate

typedef enum
{
serial_9600BAUD = 0,
serial_75BAUD,
serial_150BAUD,
serial_300BAUD,
serial_1200BAUD,
serial_2400BAUD,
serial_4800BAUD,
serial_19200BAUD = 8,
serial_50BAUD,
serial_110BAUD,
serial_134_5BAUD,
serial_600BAUD,
serial_1800BAUD,
serial_3600BAUD,
serial_7200BAUD
} serial_rate;

This defines the values to be used when reading or setting baud rates with Serial_GetRxRate, SerialSetTxRate, etc.