Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: BSD-3-Clause */
0002 /*
0003     usa49msg.h
0004 
0005     Copyright (C) 1998-2000 InnoSys Incorporated.  All Rights Reserved
0006     This file is available under a BSD-style copyright
0007 
0008     Keyspan USB Async Message Formats for the USA49W
0009 
0010     Redistribution and use in source and binary forms, with or without
0011     modification, are permitted provided that the following conditions are
0012     met:
0013 
0014     1. Redistributions of source code must retain this licence text
0015     without modification, this list of conditions, and the following
0016     disclaimer.  The following copyright notice must appear immediately at
0017     the beginning of all source files:
0018 
0019             Copyright (C) 1998-2000 InnoSys Incorporated.  All Rights Reserved
0020 
0021             This file is available under a BSD-style copyright
0022 
0023     2. The name of InnoSys Incorporated may not be used to endorse or promote
0024     products derived from this software without specific prior written
0025     permission.
0026 
0027     THIS SOFTWARE IS PROVIDED BY INNOSYS CORP. ``AS IS'' AND ANY EXPRESS OR
0028     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
0029     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
0030     NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
0031     INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
0032     (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
0033     SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
0034     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
0035     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
0036     OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
0037     SUCH DAMAGE.    
0038 
0039     4th revision: USA49W version
0040 
0041     Buffer formats for RX/TX data messages are not defined by
0042     a structure, but are described here:
0043 
0044     USB OUT (host -> USAxx, transmit) messages contain a 
0045     REQUEST_ACK indicator (set to 0xff to request an ACK at the 
0046     completion of transmit; 0x00 otherwise), followed by data:
0047 
0048         RQSTACK DAT DAT DAT ...
0049 
0050     with a total data length of 63.
0051 
0052     USB IN (USAxx -> host, receive) messages begin with a status
0053     byte in which the 0x80 bit is either:
0054                     
0055         (a) 0x80 bit clear
0056             indicates that the bytes following it are all data
0057             bytes:
0058 
0059                 STAT DATA DATA DATA DATA DATA ...
0060 
0061             for a total of up to 63 DATA bytes,
0062 
0063     or:
0064 
0065         (b) 0x80 bit set
0066             indiates that the bytes following alternate data and
0067             status bytes:
0068 
0069                 STAT DATA STAT DATA STAT DATA STAT DATA ...
0070 
0071             for a total of up to 32 DATA bytes.
0072 
0073     The valid bits in the STAT bytes are:
0074 
0075         OVERRUN 0x02
0076         PARITY  0x04
0077         FRAMING 0x08
0078         BREAK   0x10
0079 
0080     Notes:
0081     
0082     (1) The OVERRUN bit can appear in either (a) or (b) format
0083         messages, but the but the PARITY/FRAMING/BREAK bits
0084         only appear in (b) format messages.
0085     (2) For the host to determine the exact point at which the
0086         overrun occurred (to identify the point in the data
0087         stream at which the data was lost), it needs to count
0088         128 characters, starting at the first character of the
0089         message in which OVERRUN was reported; the lost character(s)
0090         would have been received between the 128th and 129th
0091         characters.
0092     (3) An RX data message in which the first byte has 0x80 clear
0093         serves as a "break off" indicator.
0094     (4) a control message specifying disablePort will be answered
0095         with a status message, but no further status will be sent
0096         until a control messages with enablePort is sent
0097 
0098     revision history:
0099 
0100     1999feb10   add reportHskiaChanges to allow us to ignore them
0101     1999feb10   add txAckThreshold for fast+loose throughput enhancement
0102     1999mar30   beef up support for RX error reporting
0103     1999apr14   add resetDataToggle to control message
0104     2000jan04   merge with usa17msg.h
0105     2000mar08   clone from usa26msg.h -> usa49msg.h
0106     2000mar09   change to support 4 ports
0107     2000may03   change external clocking to match USA-49W hardware
0108     2000jun01   add extended BSD-style copyright text
0109     2001jul05   change message format to improve OVERRUN case
0110 */
0111 
0112 #ifndef __USA49MSG__
0113 #define __USA49MSG__
0114 
0115 
0116 /*
0117     Host->device messages sent on the global control endpoint:
0118 
0119     portNumber  message
0120     ----------  --------------------
0121     0,1,2,3     portControlMessage
0122     0x80        globalControlMessage
0123 */
0124 
0125 struct keyspan_usa49_portControlMessage
0126 {
0127     /*
0128         0.  0/1/2/3     port control message follows
0129             0x80 set    non-port control message follows
0130     */
0131     u8  portNumber,
0132 
0133     /*
0134         there are three types of "commands" sent in the control message:
0135 
0136         1.  configuration changes which must be requested by setting
0137             the corresponding "set" flag (and should only be requested
0138             when necessary, to reduce overhead on the USA26):
0139     */
0140         setClocking,    // host requests baud rate be set
0141         baudLo,         // host does baud divisor calculation
0142         baudHi,         // baudHi is only used for first port (gives lower rates)
0143         prescaler,      // specified as N/8; values 8-ff are valid
0144                         // must be set any time internal baud rate is set;
0145         txClocking,     // 0=internal, 1=external/DSR
0146         rxClocking,     // 0=internal, 1=external/DSR
0147 
0148         setLcr,         // host requests lcr be set
0149         lcr,            // use PARITY, STOPBITS, DATABITS below
0150 
0151         setFlowControl, // host requests flow control be set
0152         ctsFlowControl, // 1=use CTS flow control, 0=don't
0153         xonFlowControl, // 1=use XON/XOFF flow control, 0=don't
0154         xonChar,        // specified in current character format
0155         xoffChar,       // specified in current character format
0156 
0157         setRts,         // host requests RTS output be set
0158         rts,            // 1=active, 0=inactive
0159 
0160         setDtr,         // host requests DTR output be set
0161         dtr;            // 1=on, 0=off
0162 
0163 
0164     /*
0165         3.  configuration data which is simply used as is (no overhead,
0166             but must be specified correctly in every host message).
0167     */
0168     u8  forwardingLength,  // forward when this number of chars available
0169         dsrFlowControl, // 1=use DSR flow control, 0=don't
0170         txAckThreshold, // 0=not allowed, 1=normal, 2-255 deliver ACK faster
0171         loopbackMode;   // 0=no loopback, 1=loopback enabled
0172 
0173     /*
0174         4.  commands which are flags only; these are processed in order
0175             (so that, e.g., if both _txOn and _txOff flags are set, the
0176             port ends in a TX_OFF state); any non-zero value is respected
0177     */
0178     u8  _txOn,          // enable transmitting (and continue if there's data)
0179         _txOff,         // stop transmitting
0180         txFlush,        // toss outbound data
0181         txBreak,        // turn on break (cleared by _txOn)
0182         rxOn,           // turn on receiver
0183         rxOff,          // turn off receiver
0184         rxFlush,        // toss inbound data
0185         rxForward,      // forward all inbound data, NOW (as if fwdLen==1)
0186         returnStatus,   // return current status (even if it hasn't changed)
0187         resetDataToggle,// reset data toggle state to DATA0
0188         enablePort,     // start servicing port (move data, check status)
0189         disablePort;    // stop servicing port (does implicit tx/rx flush/off)
0190     
0191 };
0192 
0193 // defines for bits in lcr
0194 #define USA_DATABITS_5      0x00
0195 #define USA_DATABITS_6      0x01
0196 #define USA_DATABITS_7      0x02
0197 #define USA_DATABITS_8      0x03
0198 #define STOPBITS_5678_1     0x00    // 1 stop bit for all byte sizes
0199 #define STOPBITS_5_1p5      0x04    // 1.5 stop bits for 5-bit byte
0200 #define STOPBITS_678_2      0x04    // 2 stop bits for 6/7/8-bit byte
0201 #define USA_PARITY_NONE     0x00
0202 #define USA_PARITY_ODD      0x08
0203 #define USA_PARITY_EVEN     0x18
0204 #define PARITY_1            0x28
0205 #define PARITY_0            0x38
0206 
0207 /*
0208     during normal operation, status messages are returned 
0209     to the host whenever the board detects changes.  In some
0210     circumstances (e.g. Windows), status messages from the
0211     device cause problems; to shut them off, the host issues
0212     a control message with the disableStatusMessages flags
0213     set (to any non-zero value).  The device will respond to
0214     this message, and then suppress further status messages;
0215     it will resume sending status messages any time the host
0216     sends any control message (either global or port-specific).
0217 */
0218 
0219 struct keyspan_usa49_globalControlMessage
0220 {
0221     u8  portNumber,         // 0x80
0222         sendGlobalStatus,   // 1/2=number of status responses requested
0223         resetStatusToggle,  // 1=reset global status toggle
0224         resetStatusCount,   // a cycling value
0225         remoteWakeupEnable,     // 0x10=P1, 0x20=P2, 0x40=P3, 0x80=P4
0226         disableStatusMessages;  // 1=send no status until host talks
0227 };
0228 
0229 /*
0230     Device->host messages send on the global status endpoint
0231 
0232     portNumber          message
0233     ----------          --------------------
0234     0x00,0x01,0x02,0x03 portStatusMessage
0235     0x80                globalStatusMessage
0236     0x81                globalDebugMessage
0237 */
0238 
0239 struct keyspan_usa49_portStatusMessage  // one for each port
0240 {
0241     u8  portNumber,     // 0,1,2,3
0242         cts,            // reports CTS pin
0243         dcd,            // reports DCD pin
0244         dsr,            // reports DSR pin
0245         ri,             // reports RI pin
0246         _txOff,         // transmit has been disabled (by host)
0247         _txXoff,        // transmit is in XOFF state (either host or RX XOFF)
0248         rxEnabled,      // as configured by rxOn/rxOff 1=on, 0=off
0249         controlResponse,// 1=a control message has been processed
0250         txAck,          // ACK (data TX complete)
0251         rs232valid;     // RS-232 signal valid
0252 };
0253 
0254 // bits in RX data message when STAT byte is included
0255 #define RXERROR_OVERRUN 0x02
0256 #define RXERROR_PARITY  0x04
0257 #define RXERROR_FRAMING 0x08
0258 #define RXERROR_BREAK   0x10
0259 
0260 struct keyspan_usa49_globalStatusMessage
0261 {
0262     u8  portNumber,         // 0x80=globalStatusMessage
0263         sendGlobalStatus,   // from request, decremented
0264         resetStatusCount;   // as in request
0265 };
0266 
0267 struct keyspan_usa49_globalDebugMessage
0268 {
0269     u8  portNumber,         // 0x81=globalDebugMessage
0270         n,                  // typically a count/status byte
0271         b;                  // typically a data byte
0272 };
0273 
0274 // ie: the maximum length of an EZUSB endpoint buffer
0275 #define MAX_DATA_LEN            64
0276 
0277 // update status approx. 60 times a second (16.6666 ms)
0278 #define STATUS_UPDATE_INTERVAL  16
0279 
0280 // status rationing tuning value (each port gets checked each n ms)
0281 #define STATUS_RATION   10
0282 
0283 #endif