| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604 |
- #ifndef _DEV_UART_H
- #define _DEV_UART_H
- /*
- * Copyright (C) 2001-2004 by egnite Software GmbH. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
- * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * For additional information see http://www.ethernut.de/
- *
- */
- /*
- * $Log: uart.h,v $
- * Revision 1.4 2005/06/26 12:40:59 chaac
- * Added support for raw mode to AHDLC driver.
- *
- * Revision 1.3 2004/11/12 11:14:32 freckle
- * added UART_GETBLOCKREAD & UART_SETBLOCKREAD defines
- *
- * Revision 1.2 2004/05/24 20:19:08 drsung
- * Added function UartAvrSize to return number of chars in input buffer.
- *
- * Revision 1.1 2004/03/16 16:48:28 haraldkipp
- * Added Jan Dubiec's H8/300 port.
- *
- * Revision 1.2 2003/12/15 19:29:18 haraldkipp
- * USART driver support added
- *
- * Revision 1.1.1.1 2003/05/09 14:41:23 haraldkipp
- * Initial using 3.2.1
- *
- * Revision 1.11 2003/05/06 17:58:28 harald
- * Handshakes added
- *
- * Revision 1.10 2003/03/31 14:53:25 harald
- * Prepare release 3.1
- *
- * Revision 1.9 2003/02/04 18:00:54 harald
- * Version 3 released
- *
- * Revision 1.8 2003/01/14 16:35:24 harald
- * Definitions moved
- *
- * Revision 1.7 2002/11/02 15:17:01 harald
- * Library dependencies moved to compiler.h
- *
- * Revision 1.6 2002/06/26 17:29:30 harald
- * First pre-release with 2.4 stack
- *
- */
- #include <sys/device.h>
- /*!
- * \file dev/uart.h
- * \brief UART I/O function prototypes.
- */
- /*!
- * \addtogroup xgUARTIOCTL
- *
- * \brief UART _ioctl() commands.
- *
- * These commands are used to control and retrieve hardware specific
- * configurations. The definitions are kept independent from the
- * underlying hardware, but not all commands may be fully implemented
- * in each UART driver.
- *
- * The _ioctl() function expects three parameters:
- * - A device descriptor.
- * - A command code, any of the UART_... commands listed below.
- * - A pointer to a configuration parameter, in most cases an unsigned long.
- */
- /*@{*/
- /*! \brief UART _ioctl() command code to set the line speed.
- *
- * The configuration parameter specifies the input and output bit rate
- * per second.
- */
- #define UART_SETSPEED 0x0101
- /*! \brief UART _ioctl() command code to query the line speed.
- *
- * The configuration parameter is set to the input and output bit rate
- * per second.
- */
- #define UART_GETSPEED 0x0102
- /*! \brief UART _ioctl() command code to set the number of data bits.
- *
- * The configuration parameter specifies the number of data bits, 5, 6,
- * 7, 8 or 9.
- */
- #define UART_SETDATABITS 0x0103
- /*! \brief UART _ioctl() command code to query the number of data bits.
- *
- * The configuration parameter is set to the number of data bits, 5, 6,
- * 7, 8 or 9.
- */
- #define UART_GETDATABITS 0x0104
- /*! \brief UART _ioctl() command code to set the parity mode.
- *
- * The configuration parameter specifies the type of the parity bit,
- * 0 (none), 1 (odd) or 2 (even).
- */
- #define UART_SETPARITY 0x0105
- /*! \brief UART _ioctl() command code to query the parity mode.
- *
- * The configuration parameter is set to the type of the parity bit,
- * 0 (none), 1 (odd) or 2 (even).
- */
- #define UART_GETPARITY 0x0106
- /*! \brief UART _ioctl() command code to set the number of stop bits.
- *
- * The configuration parameter specifies the number of stop bits, 1 or 2.
- */
- #define UART_SETSTOPBITS 0x0107
- /*! \brief UART _ioctl() command code to query the number of stop bits.
- *
- * The configuration parameter is set to the number of stop bits, 1 or 2.
- */
- #define UART_GETSTOPBITS 0x0108
- /*! \brief UART _ioctl() command code to set the status.
- *
- * The configuration parameter specifies the status to set.
- */
- #define UART_SETSTATUS 0x0109
- /*! \brief UART _ioctl() command code to query the status.
- *
- * The configuration parameter is set to the current status.
- */
- #define UART_GETSTATUS 0x010a
- /*! \brief UART _ioctl() command code to set the read timeout.
- *
- * The configuration parameter specifies the read timeout in
- * milliseconds.
- */
- #define UART_SETREADTIMEOUT 0x010b
- /*! \brief UART _ioctl() command code to query the read timeout.
- *
- * The configuration parameter is set to the read timeout in
- * milliseconds.
- */
- #define UART_GETREADTIMEOUT 0x010c
- /*! \brief UART _ioctl() command code to set the write timeout.
- *
- * The configuration parameter specifies the write timeout in
- * milliseconds.
- */
- #define UART_SETWRITETIMEOUT 0x010d
- /*! \brief UART _ioctl() command code to query the write timeout.
- *
- * The configuration parameter is set to the write timeout in
- * milliseconds.
- */
- #define UART_GETWRITETIMEOUT 0x010e
- /*! \brief UART _ioctl() command code to set the local echo mode.
- *
- * The configuration parameter specifies the local echo mode,
- * 0 (off) or 1 (on).
- */
- #define UART_SETLOCALECHO 0x010f
- /*! \brief UART _ioctl() command code to query the local echo mode.
- *
- * The configuration parameter is set to the local echo mode,
- * 0 (off) or 1 (on).
- */
- #define UART_GETLOCALECHO 0x0110
- /*! \brief UART _ioctl() command code to set the flow control mode.
- *
- * The configuration parameter specifies the flow control mode.
- */
- #define UART_SETFLOWCONTROL 0x0111
- /*! \brief UART _ioctl() command code to query the flow control mode.
- *
- * The configuration parameter is set to the flow control mode.
- */
- #define UART_GETFLOWCONTROL 0x0112
- /*! \brief UART _ioctl() command code to set the cooking mode.
- *
- * The configuration parameter specifies the character cooking mode,
- * 0 (raw) or 1 (EOL translation).
- */
- #define UART_SETCOOKEDMODE 0x0113
- /*! \brief UART _ioctl() command code to query the cooking mode.
- *
- * The configuration parameter is set to the character cooking mode,
- * 0 (raw) or 1 (EOL translation).
- */
- #define UART_GETCOOKEDMODE 0x0114
- /*! \brief UART _ioctl() command code to set the buffering mode.
- *
- * The configuration parameter specifies the buffering mode.
- */
- #define UART_SETBUFFERMODE 0x0115
- /*! \brief UART _ioctl() command code to query the buffering mode.
- *
- * The configuration parameter is set to the buffering mode.
- */
- #define UART_GETBUFFERMODE 0x0116
- /*! \brief UART _ioctl() command code to set the network interface mode.
- *
- * The configuration parameter specifies the network interface mode.
- */
- #define HDLC_SETIFNET 0x0117
- /*! \brief UART _ioctl() command code to query the network interface mode.
- *
- * The configuration parameter is set to the network interface mode.
- */
- #define HDLC_GETIFNET 0x0118
- /*! \brief UART _ioctl() command code to set the clock mode.
- *
- * The configuration parameter specifies the clock mode.
- */
- #define UART_SETCLOCKMODE 0x0119
- /*! \brief UART _ioctl() command code to query the clock mode.
- *
- * The configuration parameter is set to the clock mode.
- */
- #define UART_GETCLOCKMODE 0x011a
- /*! \brief UART _ioctl() command code to set the transmit buffer size.
- *
- * The configuration parameter specifies the number of bytes.
- */
- #define UART_SETTXBUFSIZ 0x011b
- /*! \brief UART _ioctl() command code to query the transmit buffer size.
- *
- * The configuration parameter specifies the number of bytes.
- */
- #define UART_GETTXBUFSIZ 0x011c
- /*! \brief UART _ioctl() command code to set the receive buffer size.
- *
- * The configuration parameter specifies the number of bytes.
- */
- #define UART_SETRXBUFSIZ 0x011d
- /*! \brief UART _ioctl() command code to query the receive buffer size.
- *
- * The configuration parameter specifies the number of bytes.
- */
- #define UART_GETRXBUFSIZ 0x011e
- /*! \brief UART _ioctl() command code to set the transmit buffer low watermark.
- *
- * The configuration parameter specifies the number of bytes.
- */
- #define UART_SETTXBUFLWMARK 0x0120
- /*! \brief UART _ioctl() command code to query the transmit buffer low watermark.
- *
- * The configuration parameter specifies the number of bytes.
- */
- #define UART_GETTXBUFLWMARK 0x0121
- /*! \brief UART _ioctl() command code to set the transmit buffer high watermark.
- *
- * The configuration parameter specifies the number of bytes.
- */
- #define UART_SETTXBUFHWMARK 0x0122
- /*! \brief UART _ioctl() command code to query the transmit buffer high watermark.
- *
- * The configuration parameter specifies the number of bytes.
- */
- #define UART_GETTXBUFHWMARK 0x0123
- /*! \brief UART _ioctl() command code to set the receive buffer low watermark.
- *
- * The configuration parameter specifies the number of bytes.
- */
- #define UART_SETRXBUFLWMARK 0x0124
- /*! \brief UART _ioctl() command code to query the receive buffer low watermark.
- *
- * The configuration parameter specifies the number of bytes.
- */
- #define UART_GETRXBUFLWMARK 0x0125
- /*! \brief UART _ioctl() command code to set the receive buffer high watermark.
- *
- * The configuration parameter specifies the number of bytes.
- */
- #define UART_SETRXBUFHWMARK 0x0126
- /*! \brief UART _ioctl() command code to query the receive buffer high watermark.
- *
- * The configuration parameter specifies the number of bytes.
- */
- #define UART_GETRXBUFHWMARK 0x0127
- /*! \brief UART _ioctl() command code to set the block read mode
- *
- * The configuration parameter specifies the block read mode.
- */
- #define UART_SETBLOCKREAD 0x0128
- /*! \brief UART _ioctl() command code to query the receive buffer high watermark.
- *
- * The configuration parameter specifies the block read mode.
- */
- #define UART_GETBLOCKREAD 0x0129
- /*! \brief UART _ioctl() command code to set physical device to the raw mode.
- *
- * The configuration parameter specifies the raw mode for device. In raw mode
- * data encapsulation is not allowed to be done. This allows other processing to
- * be done on physical device.
- */
- #define UART_SETRAWMODE 0x012a
- /*! \brief UART _ioctl() command code to query the raw mode.
- *
- * The configuration parameter specified the raw mode.
- */
- #define UART_GETRAWMODE 0x012b
- /*!
- * \addtogroup xgUARTStatus
- * \brief UART device status flags,
- *
- * A combination of these status flags is used by the _ioctl() commands
- * \ref UART_SETSTATUS and \ref UART_GETSTATUS.
- */
- /*@{*/
- /*! \brief Framing error.
- *
- * \ref UART_SETSTATUS will clear this error.
- */
- #define UART_FRAMINGERROR 0x00000001UL
- /*! \brief Overrun error.
- *
- * \ref UART_SETSTATUS will clear this error.
- */
- #define UART_OVERRUNERROR 0x00000002UL
- /*! \brief Parity error.
- *
- * \ref UART_SETSTATUS will clear this error.
- */
- #define UART_PARITYERROR 0x00000004UL
- /*! \brief UART errors.
- *
- * \ref UART_SETSTATUS will clear all errors.
- */
- #define UART_ERRORS (UART_FRAMINGERROR | UART_OVERRUNERROR | UART_PARITYERROR)
- /*! \brief Receiver buffer empty.
- */
- #define UART_RXBUFFEREMPTY 0x00000040UL
- /*! \brief Transmitter buffer empty.
- *
- * \ref UART_SETSTATUS will immediately clear the buffer. It will not
- * wait until the remaining characters have been transmitted.
- */
- #define UART_TXBUFFEREMPTY 0x00000080UL
- /*! \brief RTS handshake output enabled.
- */
- #define UART_RTSENABLED 0x00000100UL
- /*! \brief RTS handshake output disabled.
- */
- #define UART_RTSDISABLED 0x00000200UL
- /*! \brief CTS handshake input enabled.
- */
- #define UART_CTSENABLED 0x00000400UL
- /*! \brief CTS handshake input disabled.
- */
- #define UART_CTSDISABLED 0x00000800UL
- /*! \brief DTR handshake output enabled.
- */
- #define UART_DTRENABLED 0x00001000UL
- /*! \brief DTR handshake output disabled.
- */
- #define UART_DTRDISABLED 0x00002000UL
- /*! \brief Receiver enabled.
- */
- #define UART_RXENABLED 0x00010000UL
- /*! \brief Receiver enabled.
- */
- #define UART_RXDISABLED 0x00020000UL
- /*! \brief Transmitter enabled.
- */
- #define UART_TXENABLED 0x00040000UL
- /*! \brief Transmitter enabled.
- */
- #define UART_TXDISABLED 0x00080000UL
- /*! \brief Receive address frames only.
- *
- * Used in multidrop communication. May only work if 9 databits have
- * been configured.
- */
- #define UART_RXADDRFRAME 0x00100000UL
- /*! \brief Receive all frames.
- *
- * Used in multidrop communication.
- */
- #define UART_RXNORMFRAME 0x00200000UL
- /*! \brief Transmit as address frame.
- *
- * Used in multidrop communication. May only work if 9 databits have
- * been configured.
- */
- #define UART_TXADDRFRAME 0x00400000UL
- /*! \brief Transmit as normal frame.
- *
- * Used in multidrop communication.
- */
- #define UART_TXNORMFRAME 0x00800000UL
- /*@}*/
- /*!
- * \addtogroup xgUARTHS
- * \brief UART handshake modes.
- *
- * Any of these values may be used by the _ioctl() commands
- * \ref UART_SETFLOWCONTROL and \ref UART_GETFLOWCONTROL.
- */
- /*@{*/
- /*! \brief RTS / CTS hardware handshake.
- *
- * Nut/OS uses DTE definitions, where RTS is output and CTS is input.
- */
- #define UART_HS_RTSCTS 0x0003
- /*! \brief Full modem hardware handshake.
- *
- * Not supported yet by the standard drivers.
- */
- #define UART_HS_MODEM 0x001F
- /*! \brief XON / XOFF software handshake.
- *
- * It is recommended to set a proper read timeout with software handshake.
- * In this case a timeout may occur, if the communication peer lost our
- * last XON character. The application may then use ioctl() to disable the
- * receiver and do the read again. This will send out another XON.
- */
- #define UART_HS_SOFT 0x0020
- /*@}*/
- /*!
- * \addtogroup xgUARTClock
- * \brief UART device clock modes.
- *
- * Any of these values may be used by the _ioctl() commands
- * \ref UART_SETCLOCKMODE and \ref UART_GETCLOCKMODE. Most drivers
- * require to set the bit rate after modifying the clock mode. In order
- * to avoid unknown clock output frequencies in master mode, set the
- * clock mode to \ref UART_SYNCSLAVE first, than use \ref UART_SETSPEED
- * to select the bit rate and finally switch to \ref UART_SYNCMASTER or
- * \ref UART_NSYNCMASTER.
- */
- /*@{*/
- #define UART_SYNC 0x01
- #define UART_MASTER 0x02
- #define UART_NCLOCK 0x04
- #define UART_HIGHSPEED 0x20
- /*! \brief Normal asynchronous mode.
- */
- #define UART_ASYNC 0x00
- /*! \brief Synchronous slave mode.
- *
- * Transmit data changes on rising edge and receive data is sampled on
- * the falling edge of the clock input.
- */
- #define UART_SYNCSLAVE UART_SYNC
- /*! \brief Synchronous master mode.
- *
- * Transmit data changes on rising edge and receive data is sampled on
- * the falling edge of the clock output.
- */
- #define UART_SYNCMASTER (UART_SYNC | UART_MASTER)
- /*! \brief Synchronous slave mode, clock negated.
- *
- * Similar to \ref UART_SYNCSLAVE, but transmit data changes on falling
- * edge and receive data is sampled on the rising edge of the clock input.
- */
- #define UART_NSYNCSLAVE (UART_SYNC | UART_NCLOCK)
- /*! \brief Synchronous master mode, clock negated
- *
- * Similar to \ref UART_SYNCMASTER, but transmit data changes on falling
- * edge and receive data is sampled on the rising edge of the clock output.
- */
- #define UART_NSYNCMASTER (UART_SYNC | UART_NCLOCK | UART_MASTER)
- /*! \brief Asynchronous high speed mode.
- *
- * More deviation sensitive than normal mode, but supports higher speed.
- */
- #define UART_ASYNC_HS UART_HIGHSPEED
- /*@}*/
- /*@}*/
- __BEGIN_DECLS
- /*
- * The following prototypes are misplaced and should be removed
- * from here.
- *
- * A note by Jan Dubiec: I suggest move them to dev/uart[01].c;
- * more, those files could be even merged.
- *
- */
- extern int UartAvrInit(NUTDEVICE * dev);
- extern int UartAvrIOCtl(NUTDEVICE * dev, int req, void *conf);
- extern int UartAvrInput(NUTDEVICE * dev);
- extern int UartAvrOutput(NUTDEVICE * dev);
- extern int UartAvrFlush(NUTDEVICE * dev);
- extern int UartAvrGetRaw(u_char * cp);
- extern int UartAvrPutRaw(u_char ch);
- extern int UartAvrRead(NUTFILE * fp, void *buffer, int size);
- extern int UartAvrWrite(NUTFILE * fp, CONST void *buffer, int len);
- #ifdef __HARVARD_ARCH__
- extern int UartAvrWrite_P(NUTFILE * fp, PGM_P buffer, int len);
- #endif
- extern NUTFILE *UartAvrOpen(NUTDEVICE * dev, CONST char *name, int mode, int acc);
- extern long UartAvrSize(NUTFILE * fp);
- extern int UartAvrClose(NUTFILE * fp);
- __END_DECLS
- #endif
|