serial.h

Go to the documentation of this file.
00001 /*-
00002  * Copyright (c) 2004 Poul-Henning Kamp
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  *
00014  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
00015  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00016  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00017  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
00018  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00019  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00020  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00021  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00022  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00023  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00024  * SUCH DAMAGE.
00025  *
00026  * This file contains definitions which pertain to serial ports as such,
00027  * (both async and sync), but which do not necessarily have anything to
00028  * do with tty processing.
00029  *
00030  * $FreeBSD: src/sys/sys/serial.h,v 1.2 2004/06/25 10:56:43 phk Exp $
00031  */
00032 
00033 #ifndef _SYS_SERIAL_H_
00034 #define _SYS_SERIAL_H_
00035 
00036 #if (defined(__SYMBIAN32__) && !defined(SYMBIAN))
00037 #define SYMBIAN
00038 #endif
00039 
00040 #ifndef __SYMBIAN32__
00041 
00042 /*
00043  * Indentification of modem control signals.  These definitions match
00044  * the TIOCMGET definitions in <sys/ttycom.h> shifted a bit down, and
00045  * that identity is enforced with CTASSERT at the bottom of kern/tty.c
00046  * Both the modem bits and delta bits must fit in 16 bit.
00047  */
00048 #define         SER_DTR 0x0001          /* data terminal ready */
00049 #define         SER_RTS 0x0002          /* request to send */
00050 #define         SER_STX 0x0004          /* secondary transmit */
00051 #define         SER_SRX 0x0008          /* secondary receive */
00052 #define         SER_CTS 0x0010          /* clear to send */
00053 #define         SER_DCD 0x0020          /* data carrier detect */
00054 #define         SER_RI  0x0040          /* ring indicate */
00055 #define         SER_DSR 0x0080          /* data set ready */
00056 
00057 /* Delta bits, used to indicate which signals should/was affected */
00058 #define         SER_DELTA(x)    ((x) << 8)
00059 
00060 #define         SER_DDTR SER_DELTA(SER_DTR)
00061 #define         SER_DRTS SER_DELTA(SER_RTS)
00062 #define         SER_DSTX SER_DELTA(SER_STX)
00063 #define         SER_DSRX SER_DELTA(SER_SRX)
00064 #define         SER_DCTS SER_DELTA(SER_CTS)
00065 #define         SER_DDCD SER_DELTA(SER_DCD)
00066 #define         SER_DRI  SER_DELTA(SER_RI)
00067 #define         SER_DDSR SER_DELTA(SER_DSR)
00068 
00069 #else
00070 
00073 #define KNotifyBreakInt                         0x01
00074 #define KNotifyCD                                       0x02
00075 #define KNotifyCTS                                      0x04
00076 #define KNotifyDataAvailable            0x08
00077 #define KNotifyDSR                                      0x10
00078 #define KNotifyFramingError                     0x20
00079 #define KNotifyOutputEmpty                      0x40
00080 #define KNotifyOverrunError                     0x80
00081 #define KNotifyParityError                      0x100
00082 #define KNotifyRI                                       0x200
00083 
00087 enum DataBits {DBits5,DBits6,DBits7,DBits8};
00088 
00089 enum StopBits {Stop1,Stop2};
00090 
00091 enum Parity {ParityNone,ParityEven,ParityOdd,ParityMark,ParitySpace};
00092 
00093 enum Bps
00094         {
00095         Bps50,Bps75,Bps110,Bps134,Bps150,Bps300,Bps600,Bps1200,
00096         Bps1800,Bps2000,Bps2400,Bps3600,Bps4800,Bps7200,Bps9600,
00097         Bps19200,Bps38400,Bps57600,Bps115200,Bps230400,Bps460800,
00098         Bps576000,Bps1152000,Bps4000000,
00099         BpsSpecial=0x80000000
00100         };
00101 
00102 enum Fifo {FifoEnable,FifoDisable};
00103 
00104 enum Sir {SIREnable,SIRDisable};
00105 //
00106 #define ConfigMaxTerminators 4
00107 //
00108 #define ConfigObeyXoff 0x01
00109 #define ConfigSendXoff 0x02
00110 #define ConfigObeyCTS 0x04
00111 #define ConfigFailCTS 0x08
00112 #define ConfigObeyDSR 0x10
00113 #define ConfigFailDSR 0x20
00114 #define ConfigObeyDCD 0x40
00115 #define ConfigFailDCD 0x80
00116 #define ConfigFreeRTS 0x100
00117 #define ConfigFreeDTR 0x200
00118 #define ConfigWriteBufferedComplete 0x80000000
00119 //
00120 #define ConfigParityErrorFail 0
00121 #define ConfigParityErrorIgnore 0x01
00122 #define ConfigParityErrorReplaceChar 0x02
00123 #define ConfigXonXoffDebug 0x80000000
00124 //
00125 #define SignalCTS 0x01
00126 #define SignalDSR 0x02
00127 #define SignalDCD 0x04
00128 #define SignalRNG 0x08
00129 #define SignalRTS 0x10
00130 #define SignalDTR 0x20
00131 
00132 #define ConfigSIRPulseWidthMaximum 0x01
00133 #define ConfigSIRPulseWidthMinimum 0x02
00134 //
00135 
00136 typedef struct
00137         {
00138         enum Bps iRate;
00139         enum DataBits iDataBits;
00140         enum StopBits iStopBits;
00141         enum Parity iParity;
00142         unsigned int iHandshake;
00143         unsigned int iParityError;
00144         unsigned int iFifo;
00145         int iSpecialRate;
00146         int iTerminatorCount;
00147         char iTerminator[ConfigMaxTerminators];
00148         char iXonChar;
00149         char iXoffChar;
00150         char iParityErrorChar;
00151         enum Sir iSIREnable;
00152         unsigned int iSIRSettings;
00153         } SerialConfig;
00154 
00155 //__SYMBIAN32__
00156 #endif
00157 
00158 #endif /* !_SYS_SERIAL_H_ */

Copyright © Nokia Corporation 2001-2008
Back to top