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