ns16552Sio.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:7k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* ns16552.h - National Semiconductor 16552 DUART header file */
  2. /* Copyright 1984-2000 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 01d,12apr00,dra  Add include of sioLib.h
  7. 01c,08may97,db  added elements options and mcr to NS16550_CHAN structure to
  8.  implement hardware options & modem control(SPRs #7570, #7082).
  9. 01b,01nov95,myz  removed #if CPU=I960XX ... in NS16550_CHAN structure
  10. 01a,24oct95,myz  written from ns16552.h.
  11. */
  12. #ifndef __INCns16552Sioh 
  13. #define __INCns16552Sioh 
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. /*********************************************************************
  18.  *  Copyright (c) 1990,1991 Intel Corporation
  19.  *
  20.  * Intel hereby grants you permission to copy, modify, and
  21.  * distribute this software and its documentation.  Intel grants
  22.  * this permission provided that the above copyright notice
  23.  * appears in all copies and that both the copyright notice and
  24.  * this permission notice appear in supporting documentation.  In
  25.  * addition, Intel grants this permission provided that you
  26.  * prominently mark as not part of the original any modifications
  27.  * made to this software or documentation, and that the name of
  28.  * Intel Corporation not be used in advertising or publicity
  29.  * pertaining to distribution of the software or the documentation
  30.  * without specific, written prior permission.
  31.  *
  32.  * Intel Corporation does not warrant, guarantee or make any
  33.  * representations regarding the use of, or the results of the use
  34.  * of, the software and documentation in terms of correctness,
  35.  * accuracy, reliability, currentness, or otherwise; and you rely
  36.  * on the software, documentation and results solely at your own risk.
  37.  *********************************************************************/
  38. /******************************************************************************
  39.  *
  40.  * REGISTER DESCRIPTION OF NATIONAL 16552 DUART
  41.  *
  42.  * $Id: ns16552.h,v 2.1 1993/06/07 15:07:59 wise active $
  43.  ******************************************************************************/
  44. #ifndef _ASMLANGUAGE
  45. #include "sioLib.h"
  46. /* Register offsets from base address */
  47. #define RBR 0x00 /* receiver buffer register */
  48. #define THR 0x00 /* transmit holding register */
  49. #define DLL 0x00 /* divisor latch */
  50. #define IER 0x01 /* interrupt enable register */
  51. #define DLM 0x01 /* divisor latch(MS) */
  52. #define IIR 0x02 /* interrupt identification register */
  53. #define FCR 0x02 /* FIFO control register */
  54. #define LCR 0x03 /* line control register */
  55. #define MCR 0x04  /* modem control register */
  56. #define LSR 0x05 /* line status register */
  57. #define MSR 0x06 /* modem status register */
  58. #define SCR 0x07 /* scratch register */
  59. #define BAUD_LO(baud)  ((XTAL/(16*baud)) & 0xff)
  60. #define BAUD_HI(baud)  (((XTAL/(16*baud)) & 0xff00) >> 8)
  61. /* Line Control Register */
  62. #define CHAR_LEN_5 0x00 /* 5bits data size */
  63. #define CHAR_LEN_6 0x01 /* 6bits data size */
  64. #define CHAR_LEN_7 0x02 /* 7bits data size */
  65. #define CHAR_LEN_8 0x03 /* 8bits data size */
  66. #define LCR_STB 0x04 /* 2 stop bits */
  67. #define ONE_STOP 0x00 /* one stop bit */
  68. #define LCR_PEN 0x08 /* parity enable */
  69. #define PARITY_NONE 0x00 /* parity disable */
  70. #define LCR_EPS 0x10 /* even parity select */
  71. #define LCR_SP 0x20 /* stick parity select */
  72. #define LCR_SBRK 0x40 /* break control bit */
  73. #define LCR_DLAB 0x80 /* divisor latch access enable */
  74. #define DLAB LCR_DLAB
  75. /* Line Status Register */
  76. #define LSR_DR 0x01 /* data ready */
  77. #define RxCHAR_AVAIL LSR_DR /* data ready */
  78. #define LSR_OE 0x02 /* overrun error */
  79. #define LSR_PE 0x04 /* parity error */
  80. #define LSR_FE 0x08 /* framing error */
  81. #define LSR_BI 0x10 /* break interrupt */
  82. #define LSR_THRE 0x20 /* transmit holding register empty */
  83. #define LSR_TEMT 0x40 /* transmitter empty */
  84. #define LSR_FERR 0x80 /* in fifo mode, set when PE,FE or BI error */
  85. /* Interrupt Identification Register */
  86. #define IIR_IP 0x01
  87. #define IIR_ID 0x0e
  88. #define IIR_RLS 0x06 /* received line status */
  89. #define Rx_INT IIR_RLS /* received line status */
  90. #define IIR_RDA 0x04 /* received data available */
  91. #define RxFIFO_INT IIR_RDA /* received data available */
  92. #define IIR_THRE 0x02 /* transmit holding register empty */
  93. #define TxFIFO_INT IIR_THRE 
  94. #define IIR_MSTAT 0x00 /* modem status */
  95. #define IIR_TIMEOUT 0x0c /* char receiv tiemout */
  96. /* Interrupt Enable Register */
  97. #define IER_ERDAI 0x01 /* received data avail. & timeout int */
  98. #define RxFIFO_BIT IER_ERDAI
  99. #define IER_ETHREI 0x02 /* transmitter holding register empty int */
  100. #define TxFIFO_BIT IER_ETHREI
  101. #define IER_ELSI 0x04 /* receiver line status int enable */
  102. #define Rx_BIT IER_ELSI
  103. #define IER_EMSI 0x08 /* modem status int enable */
  104. /* Modem Control Register */
  105. #define MCR_DTR 0x01 /* dtr output */
  106. #define DTR MCR_DTR
  107. #define MCR_RTS 0x02 /* rts output */
  108. #define MCR_OUT1 0x04 /* output #1 */
  109. #define MCR_OUT2 0x08 /* output #2 */
  110. #define MCR_LOOP 0x10 /* loopback enable */
  111. /* Modem Status Register */
  112. #define MSR_DCTS 0x01 /* cts change */
  113. #define MSR_DDSR 0x02 /* dsr change */
  114. #define MSR_TERI 0x04 /* ring indicator change */
  115. #define MSR_DDCD 0x08 /* data carrier indicator change */
  116. #define MSR_CTS 0x10 /* complement of cts */
  117. #define MSR_DSR 0x20 /* complement of dsr */
  118. #define MSR_RI 0x40 /* complement of ring signal */
  119. #define MSR_DCD 0x80 /* complement of dcd */ 
  120. /* FIFO Control Register */
  121. #define FCR_EN 0x01 /* enable xmit and rcvr */
  122. #define FIFO_ENABLE FCR_EN
  123. #define FCR_RXCLR 0x02 /* clears rcvr fifo */
  124. #define RxCLEAR FCR_RXCLR
  125. #define FCR_TXCLR 0x04 /* clears xmit fifo */
  126. #define TxCLEAR FCR_TXCLR
  127. #define FCR_DMA 0x08 /* dma */
  128. #define FCR_RXTRIG_L 0x40 /* rcvr fifo trigger lvl low */
  129. #define FCR_RXTRIG_H 0x80 /* rcvr fifo trigger lvl high */
  130. typedef  struct  /* NS16550_CHAN * */
  131.     {
  132.     /* always goes first */
  133.     SIO_DRV_FUNCS *     pDrvFuncs;      /* driver functions */
  134.     /* callbacks */
  135.     STATUS      (*getTxChar) (); /* pointer to xmitr function */
  136.     STATUS      (*putRcvChar) (); /* pointer to rcvr function */
  137.     void *      getTxArg;
  138.     void *      putRcvArg;
  139.     UINT8  *regs; /* NS16552 registers */
  140.     UINT8  level; /* 8259a interrupt level for this device */
  141.     UINT8  ier; /* copy of ier */
  142.     UINT8  lcr; /* copy of lcr, not used by ns16552 driver */
  143.     UINT8  mcr; /* copy of modem control register */
  144.     UINT8  pad1;
  145.     UINT16      channelMode; /* such as INT, POLL modes */
  146.     UINT16      regDelta; /* register address spacing */
  147.     int         baudRate;
  148.     UINT32      xtal; /* UART clock frequency     */     
  149.     UINT32 options; /* hardware setup options */
  150.     } NS16550_CHAN;
  151. /* function declarations */
  152. #if defined(__STDC__) || defined(__cplusplus)
  153. extern void ns16550Int (NS16550_CHAN *);
  154. extern void ns16550DevInit (NS16550_CHAN *);
  155. #else
  156. extern void ns16550Int ();
  157. extern void ns16550DevInit ();
  158. #endif  /* __STDC__ */
  159. #endif /* _ASMLANGUAGE */
  160. #ifdef __cplusplus
  161. }
  162. #endif
  163.  
  164. #endif /* __INCns16552Sioh */