keyspan_usa90msg.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. /* SPDX-License-Identifier: BSD-3-Clause */
  2. /*
  3. usa90msg.h
  4. Copyright (c) 1998-2003 InnoSys Incorporated. All Rights Reserved
  5. This file is available under a BSD-style copyright
  6. Keyspan USB Async Message Formats for the USA19HS
  7. Redistribution and use in source and binary forms, with or without
  8. modification, are permitted provided that the following conditions are
  9. met:
  10. 1. Redistributions of source code must retain this licence text
  11. without modification, this list of conditions, and the following
  12. disclaimer. The following copyright notice must appear immediately at
  13. the beginning of all source files:
  14. Copyright (c) 1998-2003 InnoSys Incorporated. All Rights Reserved
  15. This file is available under a BSD-style copyright
  16. 2. The name of InnoSys Incorporated may not be used to endorse or promote
  17. products derived from this software without specific prior written
  18. permission.
  19. THIS SOFTWARE IS PROVIDED BY INNOSYS CORP. ``AS IS'' AND ANY EXPRESS OR
  20. IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  21. OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  22. NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  23. INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  25. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  26. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  27. LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  28. OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  29. SUCH DAMAGE.
  30. Revisions:
  31. 2003feb14 add setTxMode/txMode and cancelRxXoff to portControl
  32. 2003mar21 change name of PARITY_0/1 to add MARK/SPACE
  33. */
  34. #ifndef __USA90MSG__
  35. #define __USA90MSG__
  36. struct keyspan_usa90_portControlMessage
  37. {
  38. /*
  39. there are three types of "commands" sent in the control message:
  40. 1. configuration changes which must be requested by setting
  41. the corresponding "set" flag (and should only be requested
  42. when necessary, to reduce overhead on the device):
  43. */
  44. u8 setClocking, // host requests baud rate be set
  45. baudLo, // host does baud divisor calculation
  46. baudHi, // host does baud divisor calculation
  47. setLcr, // host requests lcr be set
  48. lcr, // use PARITY, STOPBITS, DATABITS below
  49. setRxMode, // set receive mode
  50. rxMode, // RXMODE_DMA or RXMODE_BYHAND
  51. setTxMode, // set transmit mode
  52. txMode, // TXMODE_DMA or TXMODE_BYHAND
  53. setTxFlowControl, // host requests tx flow control be set
  54. txFlowControl , // use TX_FLOW... bits below
  55. setRxFlowControl, // host requests rx flow control be set
  56. rxFlowControl, // use RX_FLOW... bits below
  57. sendXoff, // host requests XOFF transmitted immediately
  58. sendXon, // host requests XON char transmitted
  59. xonChar, // specified in current character format
  60. xoffChar, // specified in current character format
  61. sendChar, // host requests char transmitted immediately
  62. txChar, // character to send
  63. setRts, // host requests RTS output be set
  64. rts, // 1=on, 0=off
  65. setDtr, // host requests DTR output be set
  66. dtr; // 1=on, 0=off
  67. /*
  68. 2. configuration data which is simply used as is
  69. and must be specified correctly in every host message.
  70. */
  71. u8 rxForwardingLength, // forward when this number of chars available
  72. rxForwardingTimeout, // (1-31 in ms)
  73. txAckSetting; // 0=don't ack, 1=normal, 2-255 TBD...
  74. /*
  75. 3. Firmware states which cause actions if they change
  76. and must be specified correctly in every host message.
  77. */
  78. u8 portEnabled, // 0=disabled, 1=enabled
  79. txFlush, // 0=normal, 1=toss outbound data
  80. txBreak, // 0=break off, 1=break on
  81. loopbackMode; // 0=no loopback, 1=loopback enabled
  82. /*
  83. 4. commands which are flags only; these are processed in order
  84. (so that, e.g., if rxFlush and rxForward flags are set, the
  85. port will have no data to forward); any non-zero value
  86. is respected
  87. */
  88. u8 rxFlush, // toss inbound data
  89. rxForward, // forward all inbound data, NOW (as if fwdLen==1)
  90. cancelRxXoff, // cancel any receive XOFF state (_txXoff)
  91. returnStatus; // return current status NOW
  92. };
  93. // defines for bits in lcr
  94. #define USA_DATABITS_5 0x00
  95. #define USA_DATABITS_6 0x01
  96. #define USA_DATABITS_7 0x02
  97. #define USA_DATABITS_8 0x03
  98. #define STOPBITS_5678_1 0x00 // 1 stop bit for all byte sizes
  99. #define STOPBITS_5_1p5 0x04 // 1.5 stop bits for 5-bit byte
  100. #define STOPBITS_678_2 0x04 // 2 stop bits for 6-8 bit byte
  101. #define USA_PARITY_NONE 0x00
  102. #define USA_PARITY_ODD 0x08
  103. #define USA_PARITY_EVEN 0x18
  104. #define PARITY_MARK_1 0x28 // force parity MARK
  105. #define PARITY_SPACE_0 0x38 // force parity SPACE
  106. #define TXFLOW_CTS 0x04
  107. #define TXFLOW_DSR 0x08
  108. #define TXFLOW_XOFF 0x01
  109. #define TXFLOW_XOFF_ANY 0x02
  110. #define TXFLOW_XOFF_BITS (TXFLOW_XOFF | TXFLOW_XOFF_ANY)
  111. #define RXFLOW_XOFF 0x10
  112. #define RXFLOW_RTS 0x20
  113. #define RXFLOW_DTR 0x40
  114. #define RXFLOW_DSR_SENSITIVITY 0x80
  115. #define RXMODE_BYHAND 0x00
  116. #define RXMODE_DMA 0x02
  117. #define TXMODE_BYHAND 0x00
  118. #define TXMODE_DMA 0x02
  119. // all things called "StatusMessage" are sent on the status endpoint
  120. struct keyspan_usa90_portStatusMessage
  121. {
  122. u8 msr, // reports the actual MSR register
  123. cts, // reports CTS pin
  124. dcd, // reports DCD pin
  125. dsr, // reports DSR pin
  126. ri, // reports RI pin
  127. _txXoff, // port is in XOFF state (we received XOFF)
  128. rxBreak, // reports break state
  129. rxOverrun, // count of overrun errors (since last reported)
  130. rxParity, // count of parity errors (since last reported)
  131. rxFrame, // count of frame errors (since last reported)
  132. portState, // PORTSTATE_xxx bits (useful for debugging)
  133. messageAck, // message acknowledgement
  134. charAck, // character acknowledgement
  135. controlResponse; // (value = returnStatus) a control message has been processed
  136. };
  137. // bits in RX data message when STAT byte is included
  138. #define RXERROR_OVERRUN 0x02
  139. #define RXERROR_PARITY 0x04
  140. #define RXERROR_FRAMING 0x08
  141. #define RXERROR_BREAK 0x10
  142. #define PORTSTATE_ENABLED 0x80
  143. #define PORTSTATE_TXFLUSH 0x01
  144. #define PORTSTATE_TXBREAK 0x02
  145. #define PORTSTATE_LOOPBACK 0x04
  146. // MSR bits
  147. #define USA_MSR_dCTS 0x01 // CTS has changed since last report
  148. #define USA_MSR_dDSR 0x02
  149. #define USA_MSR_dRI 0x04
  150. #define USA_MSR_dDCD 0x08
  151. #define USA_MSR_CTS 0x10 // current state of CTS
  152. #define USA_MSR_DSR 0x20
  153. #define USA_USA_MSR_RI 0x40
  154. #define MSR_DCD 0x80
  155. // ie: the maximum length of an endpoint buffer
  156. #define MAX_DATA_LEN 64
  157. #endif