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

VxWorks

开发平台:

C/C++

  1. /* st16552Sio.h - Startech (Exar) 16552 DUART header file */
  2. /* Copyright 1984-2000 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 01c,12apr00,jpd  added include of sioLib.h to work with project builds.
  7. 01d,01dec97,jpd  updated to latest standards.
  8. 01c,04apr97,jpd  added ST16552_MUX struct for mutltiplexing interrupts.
  9. 01b,01apr97,jpd  changed UINT16s to UINT32s for efficiency on ARM.
  10. 01a,18jul96,jpd  written from ns16552Sio.h, version 01a.
  11. */
  12. #ifndef __INCst16552Sioh
  13. #define __INCst16552Sioh
  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. /* REGISTER DESCRIPTION OF STARTECH 16552 DUART */
  39. #ifndef _ASMLANGUAGE
  40. #include "vxWorks.h"
  41. #include "sioLib.h"
  42. /* Register offsets from base address */
  43. #define RBR 0x00 /* Receive Holding Register (R/O) */
  44. #define THR 0x00 /* Transmit Holding Register (W/O)*/
  45. #define DLL 0x00 /* Divisor Latch Low */
  46. #define IER 0x01 /* Interrupt Enable Register */
  47. #define DLM 0x01 /* Divisor Latch Middle */
  48. #define IIR 0x02 /* Interupt identification Register (R/O) */
  49. #define FCR 0x02 /* FIFO Control register (W/O) */
  50. #define LCR 0x03 /* Line Control Register */
  51. #define MCR 0x04 /* Modem Control Register */
  52. #define LSR 0x05 /* Line Status register */
  53. #define MSR 0x06 /* Modem Status Register */
  54. #define SCR 0x07 /* Scratchpad Register */
  55. #define BAUD_LO(baud)  ((XTAL/(16*baud)) & 0xFF)
  56. #define BAUD_HI(baud)  (((XTAL/(16*baud)) & 0xFF00) >> 8)
  57. /* Line Control Register values */
  58. #define CHAR_LEN_5 0x00
  59. #define CHAR_LEN_6 0x01
  60. #define CHAR_LEN_7 0x02
  61. #define CHAR_LEN_8 0x03
  62. #define LCR_STB 0x04 /* Stop bit control */
  63. #define ONE_STOP 0x00 /* One stop bit! */
  64. #define LCR_PEN 0x08 /* Parity Enable */
  65. #define PARITY_NONE 0x00
  66. #define LCR_EPS 0x10 /* Even Parity Select */
  67. #define LCR_SP 0x20 /* Force Parity */
  68. #define LCR_SBRK 0x40 /* Start Break */
  69. #define LCR_DLAB 0x80 /* Divisor Latch Access Bit */
  70. #define DLAB LCR_DLAB
  71. /* Line Status Register */
  72. #define LSR_DR 0x01 /* Data Ready */
  73. #define RxCHAR_AVAIL LSR_DR
  74. #define LSR_OE 0x02 /* Overrun Error */
  75. #define LSR_PE 0x04 /* Parity Error */
  76. #define LSR_FE 0x08 /* Framing Error */
  77. #define LSR_BI 0x10 /* Received Break Signal */
  78. #define LSR_THRE 0x20 /* Transmit Holding Register Empty */
  79. #define LSR_TEMT 0x40 /* THR and FIFO empty */
  80. #define LSR_FERR 0x80 /* Parity, Framing error or break in FIFO */
  81. /* Interrupt Identification Register */
  82. #define IIR_IP 0x01 /* Interrupt Pending */
  83. #define IIR_ID 0x0E /* Interrupt source mask */
  84. #define IIR_RLS 0x06 /* Rx Line Status Int */
  85. #define Rx_INT IIR_RLS
  86. #define IIR_RDA 0x04 /* Rx Data Available */
  87. #define RxFIFO_INT IIR_RDA
  88. #define IIR_THRE 0x02 /* THR Empty */
  89. #define TxFIFO_INT IIR_THRE
  90. #define IIR_MSTAT 0x00 /* Modem Status Register Int */
  91. #define IIR_TIMEOUT 0x0C /* Rx Data Timeout */
  92. /* Interrupt Enable Register */
  93. #define IER_ERDAI 0x01 /* Enable Rx Data Available Int */
  94. #define RxFIFO_BIT IER_ERDAI
  95. #define IER_ETHREI 0x02 /* Enable THR Empty Int */
  96. #define TxFIFO_BIT IER_ETHREI
  97. #define IER_ELSI 0x04 /* Enable Line Status Int */
  98. #define Rx_BIT IER_ELSI
  99. #define IER_EMSI 0x08 /* Enable Modem Status Int */
  100. /* Modem Control Register */
  101. #define MCR_DTR 0x01 /* state of DTR output */
  102. #define DTR MCR_DTR
  103. #define MCR_RTS 0x02 /* state of RTS output */
  104. #define MCR_OUT1 0x04 /* UNUSED in ST16552 */
  105. #define MCR_INT 0x08 /* Int Mode */
  106. #define MCR_LOOP 0x10 /* Enable Loopback mode */
  107. /* Modem Status Register */
  108. #define MSR_DCTS 0x01 /* change in CTS */
  109. #define MSR_DDSR 0x02 /* change in DSR */
  110. #define MSR_TERI 0x04 /* change in RI */
  111. #define MSR_DDCD 0x08 /* change in DCD */
  112. #define MSR_CTS 0x10 /* state of CTS input */
  113. #define MSR_DSR 0x20 /* state of DSR input */
  114. #define MSR_RI 0x40 /* state of RI input */
  115. #define MSR_DCD 0x80 /* state of DCD input */
  116. /* FIFO Control Register */
  117. #define FCR_EN 0x01 /* FIFO Enable */
  118. #define FIFO_ENABLE FCR_EN
  119. #define FCR_RXCLR 0x02 /* Rx FIFO Clear */
  120. #define RxCLEAR FCR_RXCLR
  121. #define FCR_TXCLR 0x04 /* Tx FIFO Clear */
  122. #define TxCLEAR FCR_TXCLR
  123. #define FCR_DMA 0x08 /* FIFO Mode Control */
  124. #define FCR_RXTRIG_L 0x40 /* FIFO Trigger level Low */
  125. #define FCR_RXTRIG_H 0x80 /* FIFO Trigger level High */
  126. typedef struct st16552_chan /* ST16552_CHAN */
  127.     {
  128.     /* must be first */
  129.     SIO_CHAN sio; /* standard SIO_CHAN element */
  130.     /* callbacks */
  131.     STATUS (*getTxChar) (); /* installed Tx callback routine */
  132.     STATUS (*putRcvChar) (); /* installed Rx callback routine */
  133.     void * getTxArg; /* argument to Tx callback routine */
  134.     void * putRcvArg; /* argument to Rx callback routine */
  135.     UINT8 * regs; /* ST16552 registers */
  136.     UINT8 level; /* Interrupt level for this device */
  137.     UINT8 ier; /* copy of IER */
  138.     UINT8 lcr; /* copy of LCR */
  139.     UINT32 channelMode; /* such as INT, POLL modes */
  140.     UINT32 regDelta; /* register address spacing */
  141.     int baudRate; /* the current baud rate */
  142.     UINT32 xtal; /* UART clock frequency */
  143.     } ST16552_CHAN;
  144. /* structure used as parameter to multiplexed interrupt handler */
  145. typedef struct st16552_mux /* ST16552_MUX */
  146.     {
  147.     int nextChan; /* next channel to examine on int */
  148.     ST16552_CHAN * pChan; /* array of ST16552_CHAN structs */
  149.     } ST16552_MUX;
  150. /* function declarations */
  151. extern void st16552Int (ST16552_CHAN *);
  152. extern void st16552MuxInt(ST16552_MUX *);
  153. extern void st16552DevInit (ST16552_CHAN *);
  154. #endif /* _ASMLANGUAGE */
  155. #ifdef __cplusplus
  156. }
  157. #endif
  158. #endif /* __INCst16552Sioh */