keyspan_usa26msg.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. /* SPDX-License-Identifier: BSD-3-Clause */
  2. /*
  3. usa26msg.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 USA28X
  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. Third revision: USA28X version (aka USA26)
  31. Buffer formats for RX/TX data messages are not defined by
  32. a structure, but are described here:
  33. USB OUT (host -> USAxx, 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. RQSTACK DAT DAT DAT ...
  37. with a total data length of 63.
  38. USB IN (USAxx -> host, receive) messages begin with a status
  39. byte in which the 0x80 bit is either:
  40. (a) 0x80 bit clear
  41. indicates that the bytes following it are all data
  42. bytes:
  43. STAT DATA DATA DATA DATA DATA ...
  44. for a total of up to 63 DATA bytes,
  45. or:
  46. (b) 0x80 bit set
  47. indicates that the bytes following alternate data and
  48. status bytes:
  49. STAT DATA STAT DATA STAT DATA STAT DATA ...
  50. for a total of up to 32 DATA bytes.
  51. The valid bits in the STAT bytes are:
  52. OVERRUN 0x02
  53. PARITY 0x04
  54. FRAMING 0x08
  55. BREAK 0x10
  56. Notes:
  57. (1) The OVERRUN bit can appear in either (a) or (b) format
  58. messages, but the but the PARITY/FRAMING/BREAK bits
  59. only appear in (b) format messages.
  60. (2) For the host to determine the exact point at which the
  61. overrun occurred (to identify the point in the data
  62. stream at which the data was lost), it needs to count
  63. 128 characters, starting at the first character of the
  64. message in which OVERRUN was reported; the lost character(s)
  65. would have been received between the 128th and 129th
  66. characters.
  67. (3) An RX data message in which the first byte has 0x80 clear
  68. serves as a "break off" indicator.
  69. revision history:
  70. 1999feb10 add reportHskiaChanges to allow us to ignore them
  71. 1999feb10 add txAckThreshold for fast+loose throughput enhancement
  72. 1999mar30 beef up support for RX error reporting
  73. 1999apr14 add resetDataToggle to control message
  74. 2000jan04 merge with usa17msg.h
  75. 2000jun01 add extended BSD-style copyright text
  76. 2001jul05 change message format to improve OVERRUN case
  77. Note on shared names:
  78. In the case of fields which have been merged between the USA17
  79. and USA26 definitions, the USA26 definition is the first part
  80. of the name and the USA17 definition is the second part of the
  81. name; both meanings are described below.
  82. */
  83. #ifndef __USA26MSG__
  84. #define __USA26MSG__
  85. struct keyspan_usa26_portControlMessage
  86. {
  87. /*
  88. there are three types of "commands" sent in the control message:
  89. 1. configuration changes which must be requested by setting
  90. the corresponding "set" flag (and should only be requested
  91. when necessary, to reduce overhead on the USA26):
  92. */
  93. u8 setClocking, // BOTH: host requests baud rate be set
  94. baudLo, // BOTH: host does baud divisor calculation
  95. baudHi, // BOTH: baudHi is only used for first port (gives lower rates)
  96. externalClock_txClocking,
  97. // USA26: 0=internal, other=external
  98. // USA17: 0=internal, other=external/RI
  99. rxClocking, // USA17: 0=internal, 1=external/RI, other=external/DSR
  100. setLcr, // BOTH: host requests lcr be set
  101. lcr, // BOTH: use PARITY, STOPBITS, DATABITS below
  102. setFlowControl, // BOTH: host requests flow control be set
  103. ctsFlowControl, // BOTH: 1=use CTS flow control, 0=don't
  104. xonFlowControl, // BOTH: 1=use XON/XOFF flow control, 0=don't
  105. xonChar, // BOTH: specified in current character format
  106. xoffChar, // BOTH: specified in current character format
  107. setTxTriState_setRts,
  108. // USA26: host requests TX tri-state be set
  109. // USA17: host requests RTS output be set
  110. txTriState_rts, // BOTH: 1=active (normal), 0=tristate (off)
  111. setHskoa_setDtr,
  112. // USA26: host requests HSKOA output be set
  113. // USA17: host requests DTR output be set
  114. hskoa_dtr, // BOTH: 1=on, 0=off
  115. setPrescaler, // USA26: host requests prescalar be set (default: 13)
  116. prescaler; // BOTH: specified as N/8; values 8-ff are valid
  117. // must be set any time internal baud rate is set;
  118. // must not be set when external clocking is used
  119. // note: in USA17, prescaler is applied whenever
  120. // setClocking is requested
  121. /*
  122. 3. configuration data which is simply used as is (no overhead,
  123. but must be specified correctly in every host message).
  124. */
  125. u8 forwardingLength, // BOTH: forward when this number of chars available
  126. reportHskiaChanges_dsrFlowControl,
  127. // USA26: 1=normal; 0=ignore external clock
  128. // USA17: 1=use DSR flow control, 0=don't
  129. txAckThreshold, // BOTH: 0=not allowed, 1=normal, 2-255 deliver ACK faster
  130. loopbackMode; // BOTH: 0=no loopback, 1=loopback enabled
  131. /*
  132. 4. commands which are flags only; these are processed in order
  133. (so that, e.g., if both _txOn and _txOff flags are set, the
  134. port ends in a TX_OFF state); any non-zero value is respected
  135. */
  136. u8 _txOn, // BOTH: enable transmitting (and continue if there's data)
  137. _txOff, // BOTH: stop transmitting
  138. txFlush, // BOTH: toss outbound data
  139. txBreak, // BOTH: turn on break (cleared by _txOn)
  140. rxOn, // BOTH: turn on receiver
  141. rxOff, // BOTH: turn off receiver
  142. rxFlush, // BOTH: toss inbound data
  143. rxForward, // BOTH: forward all inbound data, NOW (as if fwdLen==1)
  144. returnStatus, // BOTH: return current status (even if it hasn't changed)
  145. resetDataToggle;// BOTH: reset data toggle state to DATA0
  146. };
  147. // defines for bits in lcr
  148. #define USA_DATABITS_5 0x00
  149. #define USA_DATABITS_6 0x01
  150. #define USA_DATABITS_7 0x02
  151. #define USA_DATABITS_8 0x03
  152. #define STOPBITS_5678_1 0x00 // 1 stop bit for all byte sizes
  153. #define STOPBITS_5_1p5 0x04 // 1.5 stop bits for 5-bit byte
  154. #define STOPBITS_678_2 0x04 // 2 stop bits for 6/7/8-bit byte
  155. #define USA_PARITY_NONE 0x00
  156. #define USA_PARITY_ODD 0x08
  157. #define USA_PARITY_EVEN 0x18
  158. #define PARITY_1 0x28
  159. #define PARITY_0 0x38
  160. // all things called "StatusMessage" are sent on the status endpoint
  161. struct keyspan_usa26_portStatusMessage // one for each port
  162. {
  163. u8 port, // BOTH: 0=first, 1=second, other=see below
  164. hskia_cts, // USA26: reports HSKIA pin
  165. // USA17: reports CTS pin
  166. gpia_dcd, // USA26: reports GPIA pin
  167. // USA17: reports DCD pin
  168. dsr, // USA17: reports DSR pin
  169. ri, // USA17: reports RI pin
  170. _txOff, // port has been disabled (by host)
  171. _txXoff, // port is in XOFF state (either host or RX XOFF)
  172. rxEnabled, // as configured by rxOn/rxOff 1=on, 0=off
  173. controlResponse;// 1=a control message has been processed
  174. };
  175. // bits in RX data message when STAT byte is included
  176. #define RXERROR_OVERRUN 0x02
  177. #define RXERROR_PARITY 0x04
  178. #define RXERROR_FRAMING 0x08
  179. #define RXERROR_BREAK 0x10
  180. struct keyspan_usa26_globalControlMessage
  181. {
  182. u8 sendGlobalStatus, // 2=request for two status responses
  183. resetStatusToggle, // 1=reset global status toggle
  184. resetStatusCount; // a cycling value
  185. };
  186. struct keyspan_usa26_globalStatusMessage
  187. {
  188. u8 port, // 3
  189. sendGlobalStatus, // from request, decremented
  190. resetStatusCount; // as in request
  191. };
  192. struct keyspan_usa26_globalDebugMessage
  193. {
  194. u8 port, // 2
  195. a,
  196. b,
  197. c,
  198. d;
  199. };
  200. // ie: the maximum length of an EZUSB endpoint buffer
  201. #define MAX_DATA_LEN 64
  202. // update status approx. 60 times a second (16.6666 ms)
  203. #define STATUS_UPDATE_INTERVAL 16
  204. // status rationing tuning value (each port gets checked each n ms)
  205. #define STATUS_RATION 10
  206. #endif