os/ossrv/genericopenlibs/openenvcore/include/sys/serial.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/*-
sl@0
     2
 * Copyright (c) 2004 Poul-Henning Kamp
sl@0
     3
 * All rights reserved.
sl@0
     4
 *
sl@0
     5
 * Redistribution and use in source and binary forms, with or without
sl@0
     6
 * modification, are permitted provided that the following conditions
sl@0
     7
 * are met:
sl@0
     8
 * 1. Redistributions of source code must retain the above copyright
sl@0
     9
 *    notice, this list of conditions and the following disclaimer.
sl@0
    10
 * 2. Redistributions in binary form must reproduce the above copyright
sl@0
    11
 *    notice, this list of conditions and the following disclaimer in the
sl@0
    12
 *    documentation and/or other materials provided with the distribution.
sl@0
    13
 *
sl@0
    14
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
sl@0
    15
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
sl@0
    16
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
sl@0
    17
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
sl@0
    18
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
sl@0
    19
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
sl@0
    20
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
sl@0
    21
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
sl@0
    22
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
sl@0
    23
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
sl@0
    24
 * SUCH DAMAGE.
sl@0
    25
 *
sl@0
    26
 * This file contains definitions which pertain to serial ports as such,
sl@0
    27
 * (both async and sync), but which do not necessarily have anything to
sl@0
    28
 * do with tty processing.
sl@0
    29
 *
sl@0
    30
 * $FreeBSD: src/sys/sys/serial.h,v 1.2 2004/06/25 10:56:43 phk Exp $
sl@0
    31
 */
sl@0
    32
sl@0
    33
#ifndef _SYS_SERIAL_H_
sl@0
    34
#define	_SYS_SERIAL_H_
sl@0
    35
sl@0
    36
#ifndef __SYMBIAN32__
sl@0
    37
sl@0
    38
/*
sl@0
    39
 * Indentification of modem control signals.  These definitions match
sl@0
    40
 * the TIOCMGET definitions in <sys/ttycom.h> shifted a bit down, and
sl@0
    41
 * that identity is enforced with CTASSERT at the bottom of kern/tty.c
sl@0
    42
 * Both the modem bits and delta bits must fit in 16 bit.
sl@0
    43
 */
sl@0
    44
#define		SER_DTR	0x0001		/* data terminal ready */
sl@0
    45
#define		SER_RTS	0x0002		/* request to send */
sl@0
    46
#define		SER_STX	0x0004		/* secondary transmit */
sl@0
    47
#define		SER_SRX	0x0008		/* secondary receive */
sl@0
    48
#define		SER_CTS	0x0010		/* clear to send */
sl@0
    49
#define		SER_DCD	0x0020		/* data carrier detect */
sl@0
    50
#define		SER_RI 	0x0040		/* ring indicate */
sl@0
    51
#define		SER_DSR	0x0080		/* data set ready */
sl@0
    52
sl@0
    53
/* Delta bits, used to indicate which signals should/was affected */
sl@0
    54
#define		SER_DELTA(x)	((x) << 8)
sl@0
    55
sl@0
    56
#define		SER_DDTR SER_DELTA(SER_DTR)
sl@0
    57
#define		SER_DRTS SER_DELTA(SER_RTS)
sl@0
    58
#define		SER_DSTX SER_DELTA(SER_STX)
sl@0
    59
#define		SER_DSRX SER_DELTA(SER_SRX)
sl@0
    60
#define		SER_DCTS SER_DELTA(SER_CTS)
sl@0
    61
#define		SER_DDCD SER_DELTA(SER_DCD)
sl@0
    62
#define		SER_DRI  SER_DELTA(SER_RI)
sl@0
    63
#define		SER_DDSR SER_DELTA(SER_DSR)
sl@0
    64
sl@0
    65
#else
sl@0
    66
/**
sl@0
    67
notifications
sl@0
    68
*/
sl@0
    69
#define	KNotifyBreakInt				0x01
sl@0
    70
#define	KNotifyCD					0x02
sl@0
    71
#define	KNotifyCTS					0x04
sl@0
    72
#define	KNotifyDataAvailable		0x08
sl@0
    73
#define	KNotifyDSR					0x10
sl@0
    74
#define	KNotifyFramingError			0x20
sl@0
    75
#define	KNotifyOutputEmpty			0x40
sl@0
    76
#define	KNotifyOverrunError			0x80
sl@0
    77
#define	KNotifyParityError			0x100
sl@0
    78
#define	KNotifyRI					0x200
sl@0
    79
sl@0
    80
/**
sl@0
    81
enums, #defines and struct for serial port settings
sl@0
    82
*/
sl@0
    83
enum DataBits {DBits5,DBits6,DBits7,DBits8};
sl@0
    84
sl@0
    85
enum StopBits {Stop1,Stop2};
sl@0
    86
sl@0
    87
enum Parity {ParityNone,ParityEven,ParityOdd,ParityMark,ParitySpace};
sl@0
    88
sl@0
    89
enum Bps
sl@0
    90
	{
sl@0
    91
	Bps50,Bps75,Bps110,Bps134,Bps150,Bps300,Bps600,Bps1200,
sl@0
    92
	Bps1800,Bps2000,Bps2400,Bps3600,Bps4800,Bps7200,Bps9600,
sl@0
    93
	Bps19200,Bps38400,Bps57600,Bps115200,Bps230400,Bps460800,
sl@0
    94
	Bps576000,Bps1152000,Bps4000000,
sl@0
    95
	BpsSpecial=0x80000000
sl@0
    96
	};
sl@0
    97
sl@0
    98
enum Fifo {FifoEnable,FifoDisable};
sl@0
    99
sl@0
   100
enum Sir {SIREnable,SIRDisable};
sl@0
   101
//
sl@0
   102
#define ConfigMaxTerminators 4
sl@0
   103
//
sl@0
   104
#define ConfigObeyXoff 0x01
sl@0
   105
#define ConfigSendXoff 0x02
sl@0
   106
#define ConfigObeyCTS 0x04
sl@0
   107
#define ConfigFailCTS 0x08
sl@0
   108
#define ConfigObeyDSR 0x10
sl@0
   109
#define ConfigFailDSR 0x20
sl@0
   110
#define ConfigObeyDCD 0x40
sl@0
   111
#define ConfigFailDCD 0x80
sl@0
   112
#define ConfigFreeRTS 0x100
sl@0
   113
#define ConfigFreeDTR 0x200
sl@0
   114
#define ConfigWriteBufferedComplete 0x80000000
sl@0
   115
//
sl@0
   116
#define ConfigParityErrorFail 0
sl@0
   117
#define ConfigParityErrorIgnore 0x01
sl@0
   118
#define ConfigParityErrorReplaceChar 0x02
sl@0
   119
#define ConfigXonXoffDebug 0x80000000
sl@0
   120
//
sl@0
   121
#define SignalCTS 0x01
sl@0
   122
#define SignalDSR 0x02
sl@0
   123
#define SignalDCD 0x04
sl@0
   124
#define SignalRNG 0x08
sl@0
   125
#define SignalRTS 0x10
sl@0
   126
#define SignalDTR 0x20
sl@0
   127
sl@0
   128
#define ConfigSIRPulseWidthMaximum 0x01
sl@0
   129
#define ConfigSIRPulseWidthMinimum 0x02
sl@0
   130
//
sl@0
   131
sl@0
   132
typedef struct
sl@0
   133
	{
sl@0
   134
	enum Bps iRate;
sl@0
   135
	enum DataBits iDataBits;
sl@0
   136
	enum StopBits iStopBits;
sl@0
   137
	enum Parity iParity;
sl@0
   138
	unsigned int iHandshake;
sl@0
   139
	unsigned int iParityError;
sl@0
   140
	unsigned int iFifo;
sl@0
   141
	int iSpecialRate;
sl@0
   142
	int iTerminatorCount;
sl@0
   143
	char iTerminator[ConfigMaxTerminators];
sl@0
   144
	char iXonChar;
sl@0
   145
	char iXoffChar;
sl@0
   146
	char iParityErrorChar;
sl@0
   147
	enum Sir iSIREnable;
sl@0
   148
	unsigned int iSIRSettings;
sl@0
   149
	} SerialConfig;
sl@0
   150
sl@0
   151
#endif //__SYMBIAN32__
sl@0
   152
sl@0
   153
#endif /* !_SYS_SERIAL_H_ */