tlc16c550.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. #ifndef _DEV_TLC16C550_H_
  2. #define _DEV_TLC16C550_H_
  3. /*
  4. * Copyright (C) 2001-2003 by Cyber Integration, LLC. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the copyright holders nor the names of
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY CYBER INTEGRATION, LLC AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CYBER
  23. * INTEGRATION, LLC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. */
  33. /*
  34. * $Log$
  35. * Revision 1.5 2009/01/17 11:26:47 haraldkipp
  36. * Getting rid of two remaining BSD types in favor of stdint.
  37. * Replaced 'u_int' by 'unsinged int' and 'uptr_t' by 'uintptr_t'.
  38. *
  39. * Revision 1.4 2008/08/11 06:59:59 haraldkipp
  40. * BSD types replaced by stdint types (feature request #1282721).
  41. *
  42. * Revision 1.3 2007/05/24 07:29:10 haraldkipp
  43. * Update provided by Przemyslaw Rudy.
  44. *
  45. * Revision 1.2 2006/05/25 09:09:57 haraldkipp
  46. * API documentation updated and corrected.
  47. *
  48. * Revision 1.1 2005/11/24 11:24:06 haraldkipp
  49. * Initial check-in.
  50. * Many thanks to William Basser for this code and also to Przemyslaw Rudy
  51. * for several enhancements.
  52. *
  53. */
  54. /*
  55. Chip connections:
  56. Ax - to avr address lines
  57. CSx - to avr/PGA (chip select)
  58. Dn - to avr data lines
  59. INTN - to vcc (for 16c554 forces activation of interrupt lines)
  60. INTx - to avr interrupt lines (can be OR-ed and share common avr interrupt line)
  61. OIR - to avr /rd
  62. OIW - to avr /wr
  63. RESET - high is active
  64. */
  65. #include <sys/device.h>
  66. #include <dev/ace.h>
  67. /*!
  68. * \file dev/tlc16c550.h
  69. * \brief ACE ACE definitions.
  70. */
  71. /*!
  72. * \addtogroup xgAceDriver
  73. */
  74. /*@{*/
  75. #define ACE_MF_RTSSENSE 0x00000001UL /*!< DCE input, low on port bit is +12V, which means ON. */
  76. #define ACE_MF_CTSCONTROL 0x00000002UL /*!< DCE output. */
  77. #define ACE_MF_DTRSENSE 0x00000004UL /*!< DCE input. */
  78. #define ACE_MF_DSRCONTROL 0x00000008UL /*!< DCE output. */
  79. #define ACE_MF_DCDCONTROL 0x00000010UL /*!< DCE output. */
  80. #define ACE_MF_RTSCONTROL 0x00000020UL /*!< DTE output. */
  81. #define ACE_MF_CTSSENSE 0x00000040UL /*!< DTE input. */
  82. #define ACE_MF_DTRCONTROL 0x00000080UL /*!< DTE output. */
  83. #define ACE_MF_DSRSENSE 0x00000100UL /*!< DTE input. */
  84. #define ACE_MF_DCDSENSE 0x00000200UL /*!< DTE input. */
  85. #define ACE_MF_SENSEMASK 0x0345 /*!< Handshake sense mask. */
  86. #define ACE_MF_CONTROLMASK 0x00BC /*!< Handshake control mask. */
  87. #define ACE_MF_XONXOFF 0x00000400UL /*!< Software handshake. */
  88. #define ACE_MF_HALFDUPLEX 0x00000800UL /*!< Half duplex bit control */
  89. #define ACE_MF_LOCALECHO 0x00010000UL /*!< Should be used in stream, not device. */
  90. #define ACE_MF_COOKEDMODE 0x00020000UL /*!< Should be used in stream, not device. */
  91. #define ACE_MF_NOBUFFER 0x00100000UL /*!< No buffering. */
  92. #define ACE_MF_LINEBUFFER 0x00200000UL /*!< Line buffered. */
  93. #define ACE_MF_BUFFERMASK 0x00300000UL /*!< Masks buffering mode flags. */
  94. #define ACE_SF_RTSOFF 0x00000001UL /*!< Set RTS line is off. */
  95. #define ACE_SF_CTSOFF 0x00000002UL /*!< Set CTS line is off. */
  96. #define ACE_SF_DTROFF 0x00000004UL /*!< Set DTR line is off. */
  97. #define ACE_SF_DSROFF 0x00000008UL /*!< Set DSR line is off. */
  98. #define ACE_SF_DCDOFF 0x00000010UL /*!< Set DCD line is off. */
  99. #define ACE_SF_TXDISABLED 0x00000040UL /*!< Transmitter disabled. */
  100. #define ACE_SF_RXDISABLED 0x00000080UL /*!< Receiver disabled. */
  101. #define ACE_HS_DCERTSCTS 0x00000003UL /*!< RTS/CTS DCE handshake. */
  102. #define ACE_HS_DCEFULL 0x0000001FUL /*!< Full DCE handshake. */
  103. #define ACE_HS_DTERTSCTS 0x00000060UL /*!< RTS/CTS DTE handshake. */
  104. #define ACE_HS_DTEFULL 0x000003E0UL /*!< Full DTE handshake. */
  105. #define ACE_HS_XONXOFF 0x00000400UL /*!< Software handshake. */
  106. #ifndef ACE_CLOCK
  107. #define ACE_CLOCK 14745600UL /* in Hz - common for all devices (should be ok) */
  108. #endif
  109. #define ACE_FIFO_SIZE 16 /* hardware fifo size */
  110. /* define ACE_HDX_LINE to DTR or RTS to use HDX functionality */
  111. #ifdef ACE_HDX_LINE
  112. #undef ACE_HDX_LINE
  113. #endif
  114. #ifdef ACE_HDX_USE_RTS
  115. #define ACE_HDX_LINE MCR_RTS_MSK
  116. #endif
  117. #ifdef ACE_HDX_USE_DTR
  118. #define ACE_HDX_LINE MCR_DTR_MSK
  119. #endif
  120. #ifdef ACE_HDX_LINE
  121. #ifdef ACE_HDX_LINE_FLIP
  122. #define ACE_HDX_RECEIVE(base) *(uint8_t *) ((base) + ACE_MCR_OFS) &= ~ACE_HDX_LINE
  123. #define ACE_HDX_TRANSMIT(base) *(uint8_t *) ((base) + ACE_MCR_OFS) |= ACE_HDX_LINE
  124. #define ACE_HDX_IS_TRANSMIT(base) (*(uint8_t *) ((base) + ACE_MCR_OFS) & ACE_HDX_LINE)
  125. #else
  126. #define ACE_HDX_RECEIVE(base) *(uint8_t *) ((base) + ACE_MCR_OFS) |= ACE_HDX_LINE
  127. #define ACE_HDX_TRANSMIT(base) *(uint8_t *) ((base) + ACE_MCR_OFS) &= ~ACE_HDX_LINE
  128. #define ACE_HDX_IS_TRANSMIT(base) (!(*(uint8_t *) ((base) + ACE_MCR_OFS) & ACE_HDX_LINE))
  129. #endif
  130. #endif
  131. /*!
  132. * ACE device control block type.
  133. */
  134. typedef struct _ACEDCB ACEDCB;
  135. /*!
  136. * \struct _ACEDCB tlc16c550.h dev/tlc16c550.h
  137. * \brief ACE device control block structure.
  138. */
  139. struct _ACEDCB {
  140. /*! \brief pointer to the next device, used if more devices share the same interrupt */
  141. NUTDEVICE *dev_next;
  142. /*! \brief Read timeout.
  143. */
  144. uint32_t dcb_rtimeout;
  145. /*! \brief Write timeout.
  146. */
  147. uint32_t dcb_wtimeout;
  148. /*! \brief Queue of threads waiting for output buffer empty.
  149. *
  150. * Threads are added to this queue when calling ACEAvrFlush().
  151. */
  152. HANDLE dcb_tx_rdy;
  153. /*! \brief Queue of threads waiting for a character in the input buffer.
  154. *
  155. * Threads are added to this queue when calling ACEAvrInput().
  156. */
  157. HANDLE dcb_rx_rdy;
  158. /*! \brief Mode flags.
  159. */
  160. uint32_t dcb_modeflags;
  161. /*! \brief Level of the fifo trigger, 0 if no fifo.
  162. */
  163. uint8_t dcb_rfifo;
  164. /*! \brief Free space in the output fifo since the last write operation.
  165. */
  166. uint8_t dcb_wfifo;
  167. #ifdef ACE_HDX_LINE
  168. /*! \brief One byte time delay after which HDX pin will be off, in OCR register format.
  169. */
  170. unsigned int hdxByteTime;
  171. /*! \brief OCR register value at which HDX pin will be off, 0 if not used.
  172. */
  173. unsigned int hdxOcrTime;
  174. #endif
  175. };
  176. /*@}*/
  177. #endif