uart.h

Go to the documentation of this file.
00001 #ifndef _DEV_UART_H
00002 #define _DEV_UART_H
00003 
00004 /*
00005  * Copyright (C) 2001-2004 by egnite Software GmbH. All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted provided that the following conditions
00009  * are met:
00010  *
00011  * 1. Redistributions of source code must retain the above copyright
00012  *    notice, this list of conditions and the following disclaimer.
00013  * 2. Redistributions in binary form must reproduce the above copyright
00014  *    notice, this list of conditions and the following disclaimer in the
00015  *    documentation and/or other materials provided with the distribution.
00016  * 3. Neither the name of the copyright holders nor the names of
00017  *    contributors may be used to endorse or promote products derived
00018  *    from this software without specific prior written permission.
00019  *
00020  * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
00021  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00022  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00023  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
00024  * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00025  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00026  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00027  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00028  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00029  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00030  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00031  * SUCH DAMAGE.
00032  *
00033  * For additional information see http://www.ethernut.de/
00034  *
00035  */
00036 
00037 /*
00038  * $Log: uart.h,v $
00039  * Revision 1.4  2005/06/26 12:40:59  chaac
00040  * Added support for raw mode to AHDLC driver.
00041  *
00042  * Revision 1.3  2004/11/12 11:14:32  freckle
00043  * added UART_GETBLOCKREAD & UART_SETBLOCKREAD defines
00044  *
00045  * Revision 1.2  2004/05/24 20:19:08  drsung
00046  * Added function UartAvrSize to return number of chars in input buffer.
00047  *
00048  * Revision 1.1  2004/03/16 16:48:28  haraldkipp
00049  * Added Jan Dubiec's H8/300 port.
00050  *
00051  * Revision 1.2  2003/12/15 19:29:18  haraldkipp
00052  * USART driver support added
00053  *
00054  * Revision 1.1.1.1  2003/05/09 14:41:23  haraldkipp
00055  * Initial using 3.2.1
00056  *
00057  * Revision 1.11  2003/05/06 17:58:28  harald
00058  * Handshakes added
00059  *
00060  * Revision 1.10  2003/03/31 14:53:25  harald
00061  * Prepare release 3.1
00062  *
00063  * Revision 1.9  2003/02/04 18:00:54  harald
00064  * Version 3 released
00065  *
00066  * Revision 1.8  2003/01/14 16:35:24  harald
00067  * Definitions moved
00068  *
00069  * Revision 1.7  2002/11/02 15:17:01  harald
00070  * Library dependencies moved to compiler.h
00071  *
00072  * Revision 1.6  2002/06/26 17:29:30  harald
00073  * First pre-release with 2.4 stack
00074  *
00075  */
00076 
00077 #include <sys/device.h>
00078 
00100 
00106 #define UART_SETSPEED           0x0101
00107 
00113 #define UART_GETSPEED           0x0102
00114 
00120 #define UART_SETDATABITS        0x0103
00121 
00127 #define UART_GETDATABITS        0x0104
00128 
00134 #define UART_SETPARITY          0x0105
00135 
00141 #define UART_GETPARITY          0x0106
00142 
00147 #define UART_SETSTOPBITS        0x0107
00148 
00153 #define UART_GETSTOPBITS        0x0108
00154 
00159 #define UART_SETSTATUS          0x0109
00160 
00165 #define UART_GETSTATUS          0x010a
00166 
00172 #define UART_SETREADTIMEOUT     0x010b
00173 
00179 #define UART_GETREADTIMEOUT     0x010c
00180 
00186 #define UART_SETWRITETIMEOUT    0x010d
00187 
00193 #define UART_GETWRITETIMEOUT    0x010e
00194 
00200 #define UART_SETLOCALECHO       0x010f
00201 
00207 #define UART_GETLOCALECHO       0x0110
00208 
00213 #define UART_SETFLOWCONTROL     0x0111
00214 
00219 #define UART_GETFLOWCONTROL     0x0112
00220 
00226 #define UART_SETCOOKEDMODE      0x0113
00227 
00233 #define UART_GETCOOKEDMODE      0x0114
00234 
00239 #define UART_SETBUFFERMODE      0x0115
00240 
00245 #define UART_GETBUFFERMODE      0x0116
00246 
00251 #define HDLC_SETIFNET           0x0117
00252 
00257 #define HDLC_GETIFNET           0x0118
00258 
00263 #define UART_SETCLOCKMODE       0x0119
00264 
00269 #define UART_GETCLOCKMODE       0x011a
00270 
00275 #define UART_SETTXBUFSIZ        0x011b
00276 
00281 #define UART_GETTXBUFSIZ        0x011c
00282 
00287 #define UART_SETRXBUFSIZ        0x011d
00288 
00293 #define UART_GETRXBUFSIZ        0x011e
00294 
00299 #define UART_SETTXBUFLWMARK     0x0120
00300 
00305 #define UART_GETTXBUFLWMARK     0x0121
00306 
00311 #define UART_SETTXBUFHWMARK     0x0122
00312 
00317 #define UART_GETTXBUFHWMARK     0x0123
00318 
00323 #define UART_SETRXBUFLWMARK     0x0124
00324 
00329 #define UART_GETRXBUFLWMARK     0x0125
00330 
00335 #define UART_SETRXBUFHWMARK     0x0126
00336 
00341 #define UART_GETRXBUFHWMARK     0x0127
00342 
00347 #define UART_SETBLOCKREAD       0x0128
00348 
00353 #define UART_GETBLOCKREAD       0x0129
00354 
00361 #define UART_SETRAWMODE         0x012a
00362 
00367 #define UART_GETRAWMODE         0x012b
00368 
00377 
00382 #define UART_FRAMINGERROR   0x00000001UL
00383 
00388 #define UART_OVERRUNERROR   0x00000002UL
00389 
00394 #define UART_PARITYERROR    0x00000004UL
00395 
00400 #define UART_ERRORS         (UART_FRAMINGERROR | UART_OVERRUNERROR | UART_PARITYERROR)
00401 
00404 #define UART_RXBUFFEREMPTY  0x00000040UL
00405 
00411 #define UART_TXBUFFEREMPTY  0x00000080UL
00412 
00415 #define UART_RTSENABLED     0x00000100UL
00416 
00419 #define UART_RTSDISABLED    0x00000200UL
00420 
00423 #define UART_CTSENABLED     0x00000400UL
00424 
00427 #define UART_CTSDISABLED    0x00000800UL
00428 
00431 #define UART_DTRENABLED     0x00001000UL
00432 
00435 #define UART_DTRDISABLED    0x00002000UL
00436 
00439 #define UART_RXENABLED      0x00010000UL
00440 
00443 #define UART_RXDISABLED     0x00020000UL
00444 
00447 #define UART_TXENABLED      0x00040000UL
00448 
00451 #define UART_TXDISABLED     0x00080000UL
00452 
00458 #define UART_RXADDRFRAME    0x00100000UL
00459 
00464 #define UART_RXNORMFRAME    0x00200000UL
00465 
00471 #define UART_TXADDRFRAME    0x00400000UL
00472 
00477 #define UART_TXNORMFRAME    0x00800000UL
00478 
00479 
00490 
00495 #define UART_HS_RTSCTS      0x0003
00496 
00501 #define UART_HS_MODEM       0x001F
00502 
00510 #define UART_HS_SOFT        0x0020
00511 
00528 
00529 #define UART_SYNC           0x01
00530 #define UART_MASTER         0x02
00531 #define UART_NCLOCK         0x04
00532 #define UART_HIGHSPEED      0x20
00533 
00536 #define UART_ASYNC          0x00
00537 
00543 #define UART_SYNCSLAVE     UART_SYNC
00544 
00550 #define UART_SYNCMASTER    (UART_SYNC | UART_MASTER)
00551 
00557 #define UART_NSYNCSLAVE    (UART_SYNC | UART_NCLOCK)
00558 
00564 #define UART_NSYNCMASTER   (UART_SYNC | UART_NCLOCK | UART_MASTER)
00565 
00570 #define UART_ASYNC_HS      UART_HIGHSPEED
00571 
00575 
00576 __BEGIN_DECLS
00577 /*
00578  * The following prototypes are misplaced and should be removed
00579  * from here.
00580  *
00581  * A note by Jan Dubiec: I suggest move them to dev/uart[01].c;
00582  * more, those files could be even merged.
00583  *
00584  */
00585 extern int UartAvrInit(NUTDEVICE * dev);
00586 extern int UartAvrIOCtl(NUTDEVICE * dev, int req, void *conf);
00587 extern int UartAvrInput(NUTDEVICE * dev);
00588 extern int UartAvrOutput(NUTDEVICE * dev);
00589 extern int UartAvrFlush(NUTDEVICE * dev);
00590 
00591 extern int UartAvrGetRaw(u_char * cp);
00592 extern int UartAvrPutRaw(u_char ch);
00593 
00594 extern int UartAvrRead(NUTFILE * fp, void *buffer, int size);
00595 extern int UartAvrWrite(NUTFILE * fp, CONST void *buffer, int len);
00596 #ifdef __HARVARD_ARCH__
00597 extern int UartAvrWrite_P(NUTFILE * fp, PGM_P buffer, int len);
00598 #endif
00599 extern NUTFILE *UartAvrOpen(NUTDEVICE * dev, CONST char *name, int mode, int acc);
00600 extern long UartAvrSize(NUTFILE * fp);
00601 extern int UartAvrClose(NUTFILE * fp);
00602 
00603 __END_DECLS
00604 #endif

© 2000-2007 by egnite Software GmbH - visit http://www.ethernut.de/