keyspan_usa28msg.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /* SPDX-License-Identifier: BSD-3-Clause */
  2. /*
  3. usa28msg.h
  4. Copyright (C) 1998-2000 InnoSys Incorporated. All Rights Reserved
  5. This file is available under a BSD-style copyright
  6. Keyspan USB Async Message Formats for the USA26X
  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-2000 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. Note: these message formats are common to USA18, USA19, and USA28;
  31. (for USA28X, see usa26msg.h)
  32. Buffer formats for RX/TX data messages are not defined by
  33. a structure, but are described here:
  34. USB OUT (host -> USA28, transmit) messages contain a
  35. REQUEST_ACK indicator (set to 0xff to request an ACK at the
  36. completion of transmit; 0x00 otherwise), followed by data.
  37. If the port is configured for parity, the data will be an
  38. alternating string of parity and data bytes, so the message
  39. format will be:
  40. RQSTACK PAR DAT PAR DAT ...
  41. so the maximum length is 63 bytes (1 + 62, or 31 data bytes);
  42. always an odd number for the total message length.
  43. If there is no parity, the format is simply:
  44. RQSTACK DAT DAT DAT ...
  45. with a total data length of 63.
  46. USB IN (USA28 -> host, receive) messages contain data and parity
  47. if parity is configred, thusly:
  48. DAT PAR DAT PAR DAT PAR ...
  49. for a total of 32 data bytes;
  50. If parity is not configured, the format is:
  51. DAT DAT DAT ...
  52. for a total of 64 data bytes.
  53. In the TX messages (USB OUT), the 0x01 bit of the PARity byte is
  54. the parity bit. In the RX messages (USB IN), the PARity byte is
  55. the content of the 8051's status register; the parity bit
  56. (RX_PARITY_BIT) is the 0x04 bit.
  57. revision history:
  58. 1999may06 add resetDataToggle to control message
  59. 2000mar21 add rs232invalid to status response message
  60. 2000apr04 add 230.4Kb definition to setBaudRate
  61. 2000apr13 add/remove loopbackMode switch
  62. 2000apr13 change definition of setBaudRate to cover 115.2Kb, too
  63. 2000jun01 add extended BSD-style copyright text
  64. */
  65. #ifndef __USA28MSG__
  66. #define __USA28MSG__
  67. struct keyspan_usa28_portControlMessage
  68. {
  69. /*
  70. there are four types of "commands" sent in the control message:
  71. 1. configuration changes which must be requested by setting
  72. the corresponding "set" flag (and should only be requested
  73. when necessary, to reduce overhead on the USA28):
  74. */
  75. u8 setBaudRate, // 0=don't set, 1=baudLo/Hi, 2=115.2K, 3=230.4K
  76. baudLo, // host does baud divisor calculation
  77. baudHi; // baudHi is only used for first port (gives lower rates)
  78. /*
  79. 2. configuration changes which are done every time (because it's
  80. hardly more trouble to do them than to check whether to do them):
  81. */
  82. u8 parity, // 1=use parity, 0=don't
  83. ctsFlowControl, // all except 19Q: 1=use CTS flow control, 0=don't
  84. // 19Q: 0x08:CTSflowControl 0x10:DSRflowControl
  85. xonFlowControl, // 1=use XON/XOFF flow control, 0=don't
  86. rts, // 1=on, 0=off
  87. dtr; // 1=on, 0=off
  88. /*
  89. 3. configuration data which is simply used as is (no overhead,
  90. but must be correct in every host message).
  91. */
  92. u8 forwardingLength, // forward when this number of chars available
  93. forwardMs, // forward this many ms after last rx data
  94. breakThreshold, // specified in ms, 1-255 (see note below)
  95. xonChar, // specified in current character format
  96. xoffChar; // specified in current character format
  97. /*
  98. 4. commands which are flags only; these are processed in order
  99. (so that, e.g., if both _txOn and _txOff flags are set, the
  100. port ends in a TX_OFF state); any non-zero value is respected
  101. */
  102. u8 _txOn, // enable transmitting (and continue if there's data)
  103. _txOff, // stop transmitting
  104. txFlush, // toss outbound data
  105. txForceXoff, // pretend we've received XOFF
  106. txBreak, // turn on break (leave on until txOn clears it)
  107. rxOn, // turn on receiver
  108. rxOff, // turn off receiver
  109. rxFlush, // toss inbound data
  110. rxForward, // forward all inbound data, NOW
  111. returnStatus, // return current status n times (1 or 2)
  112. resetDataToggle;// reset data toggle state to DATA0
  113. };
  114. struct keyspan_usa28_portStatusMessage
  115. {
  116. u8 port, // 0=first, 1=second, 2=global (see below)
  117. cts,
  118. dsr, // (not used in all products)
  119. dcd,
  120. ri, // (not used in all products)
  121. _txOff, // port has been disabled (by host)
  122. _txXoff, // port is in XOFF state (either host or RX XOFF)
  123. dataLost, // count of lost chars; wraps; not guaranteed exact
  124. rxEnabled, // as configured by rxOn/rxOff 1=on, 0=off
  125. rxBreak, // 1=we're in break state
  126. rs232invalid, // 1=no valid signals on rs-232 inputs
  127. controlResponse;// 1=a control messages has been processed
  128. };
  129. // bit defines in txState
  130. #define TX_OFF 0x01 // requested by host txOff command
  131. #define TX_XOFF 0x02 // either real, or simulated by host
  132. struct keyspan_usa28_globalControlMessage
  133. {
  134. u8 sendGlobalStatus, // 2=request for two status responses
  135. resetStatusToggle, // 1=reset global status toggle
  136. resetStatusCount; // a cycling value
  137. };
  138. struct keyspan_usa28_globalStatusMessage
  139. {
  140. u8 port, // 3
  141. sendGlobalStatus, // from request, decremented
  142. resetStatusCount; // as in request
  143. };
  144. struct keyspan_usa28_globalDebugMessage
  145. {
  146. u8 port, // 2
  147. n, // typically a count/status byte
  148. b; // typically a data byte
  149. };
  150. // ie: the maximum length of an EZUSB endpoint buffer
  151. #define MAX_DATA_LEN 64
  152. // the parity bytes have only one significant bit
  153. #define RX_PARITY_BIT 0x04
  154. #define TX_PARITY_BIT 0x01
  155. // update status approx. 60 times a second (16.6666 ms)
  156. #define STATUS_UPDATE_INTERVAL 16
  157. #endif