keyspan_usa28msg.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /*
  2. usa28msg.h
  3. Copyright (C) 1998-2000 InnoSys Incorporated. All Rights Reserved
  4. This file is available under a BSD-style copyright
  5. Keyspan USB Async Message Formats for the USA26X
  6. Redistribution and use in source and binary forms, with or without
  7. modification, are permitted provided that the following conditions are
  8. met:
  9. 1. Redistributions of source code must retain this licence text
  10. without modification, this list of conditions, and the following
  11. disclaimer. The following copyright notice must appear immediately at
  12. the beginning of all source files:
  13. Copyright (C) 1998-2000 InnoSys Incorporated. All Rights Reserved
  14. This file is available under a BSD-style copyright
  15. 2. The name of InnoSys Incorporated may not be used to endorse or promote
  16. products derived from this software without specific prior written
  17. permission.
  18. THIS SOFTWARE IS PROVIDED BY INNOSYS CORP. ``AS IS'' AND ANY EXPRESS OR
  19. IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  20. OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  21. NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  22. INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  24. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  25. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  26. LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  27. OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  28. SUCH DAMAGE.
  29. Note: these message formats are common to USA18, USA19, and USA28;
  30. (for USA28X, see usa26msg.h)
  31. Buffer formats for RX/TX data messages are not defined by
  32. a structure, but are described here:
  33. USB OUT (host -> USA28, transmit) messages contain a
  34. REQUEST_ACK indicator (set to 0xff to request an ACK at the
  35. completion of transmit; 0x00 otherwise), followed by data.
  36. If the port is configured for parity, the data will be an
  37. alternating string of parity and data bytes, so the message
  38. format will be:
  39. RQSTACK PAR DAT PAR DAT ...
  40. so the maximum length is 63 bytes (1 + 62, or 31 data bytes);
  41. always an odd number for the total message length.
  42. If there is no parity, the format is simply:
  43. RQSTACK DAT DAT DAT ...
  44. with a total data length of 63.
  45. USB IN (USA28 -> host, receive) messages contain data and parity
  46. if parity is configred, thusly:
  47. DAT PAR DAT PAR DAT PAR ...
  48. for a total of 32 data bytes;
  49. If parity is not configured, the format is:
  50. DAT DAT DAT ...
  51. for a total of 64 data bytes.
  52. In the TX messages (USB OUT), the 0x01 bit of the PARity byte is
  53. the parity bit. In the RX messages (USB IN), the PARity byte is
  54. the content of the 8051's status register; the parity bit
  55. (RX_PARITY_BIT) is the 0x04 bit.
  56. revision history:
  57. 1999may06 add resetDataToggle to control message
  58. 2000mar21 add rs232invalid to status response message
  59. 2000apr04 add 230.4Kb definition to setBaudRate
  60. 2000apr13 add/remove loopbackMode switch
  61. 2000apr13 change definition of setBaudRate to cover 115.2Kb, too
  62. 2000jun01 add extended BSD-style copyright text
  63. */
  64. #ifndef __USA28MSG__
  65. #define __USA28MSG__
  66. struct keyspan_usa28_portControlMessage
  67. {
  68. /*
  69. there are four types of "commands" sent in the control message:
  70. 1. configuration changes which must be requested by setting
  71. the corresponding "set" flag (and should only be requested
  72. when necessary, to reduce overhead on the USA28):
  73. */
  74. u8 setBaudRate, // 0=don't set, 1=baudLo/Hi, 2=115.2K, 3=230.4K
  75. baudLo, // host does baud divisor calculation
  76. baudHi; // baudHi is only used for first port (gives lower rates)
  77. /*
  78. 2. configuration changes which are done every time (because it's
  79. hardly more trouble to do them than to check whether to do them):
  80. */
  81. u8 parity, // 1=use parity, 0=don't
  82. ctsFlowControl, // all except 19Q: 1=use CTS flow control, 0=don't
  83. // 19Q: 0x08:CTSflowControl 0x10:DSRflowControl
  84. xonFlowControl, // 1=use XON/XOFF flow control, 0=don't
  85. rts, // 1=on, 0=off
  86. dtr; // 1=on, 0=off
  87. /*
  88. 3. configuration data which is simply used as is (no overhead,
  89. but must be correct in every host message).
  90. */
  91. u8 forwardingLength, // forward when this number of chars available
  92. forwardMs, // forward this many ms after last rx data
  93. breakThreshold, // specified in ms, 1-255 (see note below)
  94. xonChar, // specified in current character format
  95. xoffChar; // specified in current character format
  96. /*
  97. 4. commands which are flags only; these are processed in order
  98. (so that, e.g., if both _txOn and _txOff flags are set, the
  99. port ends in a TX_OFF state); any non-zero value is respected
  100. */
  101. u8 _txOn, // enable transmitting (and continue if there's data)
  102. _txOff, // stop transmitting
  103. txFlush, // toss outbound data
  104. txForceXoff, // pretend we've received XOFF
  105. txBreak, // turn on break (leave on until txOn clears it)
  106. rxOn, // turn on receiver
  107. rxOff, // turn off receiver
  108. rxFlush, // toss inbound data
  109. rxForward, // forward all inbound data, NOW
  110. returnStatus, // return current status n times (1 or 2)
  111. resetDataToggle;// reset data toggle state to DATA0
  112. };
  113. struct keyspan_usa28_portStatusMessage
  114. {
  115. u8 port, // 0=first, 1=second, 2=global (see below)
  116. cts,
  117. dsr, // (not used in all products)
  118. dcd,
  119. ri, // (not used in all products)
  120. _txOff, // port has been disabled (by host)
  121. _txXoff, // port is in XOFF state (either host or RX XOFF)
  122. dataLost, // count of lost chars; wraps; not guaranteed exact
  123. rxEnabled, // as configured by rxOn/rxOff 1=on, 0=off
  124. rxBreak, // 1=we're in break state
  125. rs232invalid, // 1=no valid signals on rs-232 inputs
  126. controlResponse;// 1=a control messages has been processed
  127. };
  128. // bit defines in txState
  129. #define TX_OFF 0x01 // requested by host txOff command
  130. #define TX_XOFF 0x02 // either real, or simulated by host
  131. struct keyspan_usa28_globalControlMessage
  132. {
  133. u8 sendGlobalStatus, // 2=request for two status responses
  134. resetStatusToggle, // 1=reset global status toggle
  135. resetStatusCount; // a cycling value
  136. };
  137. struct keyspan_usa28_globalStatusMessage
  138. {
  139. u8 port, // 3
  140. sendGlobalStatus, // from request, decremented
  141. resetStatusCount; // as in request
  142. };
  143. struct keyspan_usa28_globalDebugMessage
  144. {
  145. u8 port, // 2
  146. n, // typically a count/status byte
  147. b; // typically a data byte
  148. };
  149. // ie: the maximum length of an EZUSB endpoint buffer
  150. #define MAX_DATA_LEN 64
  151. // the parity bytes have only one significant bit
  152. #define RX_PARITY_BIT 0x04
  153. #define TX_PARITY_BIT 0x01
  154. // update status approx. 60 times a second (16.6666 ms)
  155. #define STATUS_UPDATE_INTERVAL 16
  156. #endif