keyspan_usa90msg.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /*
  2. usa90msg.h
  3. Copyright (c) 1998-2003 InnoSys Incorporated. All Rights Reserved
  4. This file is available under a BSD-style copyright
  5. Keyspan USB Async Message Formats for the USA19HS
  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-2003 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. Revisions:
  30. 2003feb14 add setTxMode/txMode and cancelRxXoff to portControl
  31. 2003mar21 change name of PARITY_0/1 to add MARK/SPACE
  32. */
  33. #ifndef __USA90MSG__
  34. #define __USA90MSG__
  35. struct keyspan_usa90_portControlMessage
  36. {
  37. /*
  38. there are three types of "commands" sent in the control message:
  39. 1. configuration changes which must be requested by setting
  40. the corresponding "set" flag (and should only be requested
  41. when necessary, to reduce overhead on the device):
  42. */
  43. u8 setClocking, // host requests baud rate be set
  44. baudLo, // host does baud divisor calculation
  45. baudHi, // host does baud divisor calculation
  46. setLcr, // host requests lcr be set
  47. lcr, // use PARITY, STOPBITS, DATABITS below
  48. setRxMode, // set receive mode
  49. rxMode, // RXMODE_DMA or RXMODE_BYHAND
  50. setTxMode, // set transmit mode
  51. txMode, // TXMODE_DMA or TXMODE_BYHAND
  52. setTxFlowControl, // host requests tx flow control be set
  53. txFlowControl , // use TX_FLOW... bits below
  54. setRxFlowControl, // host requests rx flow control be set
  55. rxFlowControl, // use RX_FLOW... bits below
  56. sendXoff, // host requests XOFF transmitted immediately
  57. sendXon, // host requests XON char transmitted
  58. xonChar, // specified in current character format
  59. xoffChar, // specified in current character format
  60. sendChar, // host requests char transmitted immediately
  61. txChar, // character to send
  62. setRts, // host requests RTS output be set
  63. rts, // 1=on, 0=off
  64. setDtr, // host requests DTR output be set
  65. dtr; // 1=on, 0=off
  66. /*
  67. 2. configuration data which is simply used as is
  68. and must be specified correctly in every host message.
  69. */
  70. u8 rxForwardingLength, // forward when this number of chars available
  71. rxForwardingTimeout, // (1-31 in ms)
  72. txAckSetting; // 0=don't ack, 1=normal, 2-255 TBD...
  73. /*
  74. 3. Firmware states which cause actions if they change
  75. and must be specified correctly in every host message.
  76. */
  77. u8 portEnabled, // 0=disabled, 1=enabled
  78. txFlush, // 0=normal, 1=toss outbound data
  79. txBreak, // 0=break off, 1=break on
  80. loopbackMode; // 0=no loopback, 1=loopback enabled
  81. /*
  82. 4. commands which are flags only; these are processed in order
  83. (so that, e.g., if rxFlush and rxForward flags are set, the
  84. port will have no data to forward); any non-zero value
  85. is respected
  86. */
  87. u8 rxFlush, // toss inbound data
  88. rxForward, // forward all inbound data, NOW (as if fwdLen==1)
  89. cancelRxXoff, // cancel any receive XOFF state (_txXoff)
  90. returnStatus; // return current status NOW
  91. };
  92. // defines for bits in lcr
  93. #define USA_DATABITS_5 0x00
  94. #define USA_DATABITS_6 0x01
  95. #define USA_DATABITS_7 0x02
  96. #define USA_DATABITS_8 0x03
  97. #define STOPBITS_5678_1 0x00 // 1 stop bit for all byte sizes
  98. #define STOPBITS_5_1p5 0x04 // 1.5 stop bits for 5-bit byte
  99. #define STOPBITS_678_2 0x04 // 2 stop bits for 6-8 bit byte
  100. #define USA_PARITY_NONE 0x00
  101. #define USA_PARITY_ODD 0x08
  102. #define USA_PARITY_EVEN 0x18
  103. #define PARITY_MARK_1 0x28 // force parity MARK
  104. #define PARITY_SPACE_0 0x38 // force parity SPACE
  105. #define TXFLOW_CTS 0x04
  106. #define TXFLOW_DSR 0x08
  107. #define TXFLOW_XOFF 0x01
  108. #define TXFLOW_XOFF_ANY 0x02
  109. #define TXFLOW_XOFF_BITS (TXFLOW_XOFF | TXFLOW_XOFF_ANY)
  110. #define RXFLOW_XOFF 0x10
  111. #define RXFLOW_RTS 0x20
  112. #define RXFLOW_DTR 0x40
  113. #define RXFLOW_DSR_SENSITIVITY 0x80
  114. #define RXMODE_BYHAND 0x00
  115. #define RXMODE_DMA 0x02
  116. #define TXMODE_BYHAND 0x00
  117. #define TXMODE_DMA 0x02
  118. // all things called "StatusMessage" are sent on the status endpoint
  119. struct keyspan_usa90_portStatusMessage
  120. {
  121. u8 msr, // reports the actual MSR register
  122. cts, // reports CTS pin
  123. dcd, // reports DCD pin
  124. dsr, // reports DSR pin
  125. ri, // reports RI pin
  126. _txXoff, // port is in XOFF state (we received XOFF)
  127. rxBreak, // reports break state
  128. rxOverrun, // count of overrun errors (since last reported)
  129. rxParity, // count of parity errors (since last reported)
  130. rxFrame, // count of frame errors (since last reported)
  131. portState, // PORTSTATE_xxx bits (useful for debugging)
  132. messageAck, // message acknowledgement
  133. charAck, // character acknowledgement
  134. controlResponse; // (value = returnStatus) a control message has been processed
  135. };
  136. // bits in RX data message when STAT byte is included
  137. #define RXERROR_OVERRUN 0x02
  138. #define RXERROR_PARITY 0x04
  139. #define RXERROR_FRAMING 0x08
  140. #define RXERROR_BREAK 0x10
  141. #define PORTSTATE_ENABLED 0x80
  142. #define PORTSTATE_TXFLUSH 0x01
  143. #define PORTSTATE_TXBREAK 0x02
  144. #define PORTSTATE_LOOPBACK 0x04
  145. // MSR bits
  146. #define USA_MSR_dCTS 0x01 // CTS has changed since last report
  147. #define USA_MSR_dDSR 0x02
  148. #define USA_MSR_dRI 0x04
  149. #define USA_MSR_dDCD 0x08
  150. #define USA_MSR_CTS 0x10 // current state of CTS
  151. #define USA_MSR_DSR 0x20
  152. #define USA_USA_MSR_RI 0x40
  153. #define MSR_DCD 0x80
  154. // ie: the maximum length of an endpoint buffer
  155. #define MAX_DATA_LEN 64
  156. #endif