Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: BSD-3-Clause */
0002 /*
0003     usa28msg.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 USA26X
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     Note: these message formats are common to USA18, USA19, and USA28;
0040     (for USA28X, see usa26msg.h)
0041 
0042     Buffer formats for RX/TX data messages are not defined by
0043     a structure, but are described here:
0044 
0045     USB OUT (host -> USA28, transmit) messages contain a 
0046     REQUEST_ACK indicator (set to 0xff to request an ACK at the 
0047     completion of transmit; 0x00 otherwise), followed by data.
0048     If the port is configured for parity, the data will be an 
0049     alternating string of parity and data bytes, so the message
0050     format will be:
0051 
0052         RQSTACK PAR DAT PAR DAT ...
0053 
0054     so the maximum length is 63 bytes (1 + 62, or 31 data bytes);
0055     always an odd number for the total message length.
0056 
0057     If there is no parity, the format is simply:
0058 
0059         RQSTACK DAT DAT DAT ...
0060 
0061     with a total data length of 63.
0062 
0063     USB IN (USA28 -> host, receive) messages contain data and parity
0064     if parity is configred, thusly:
0065     
0066         DAT PAR DAT PAR DAT PAR ...
0067 
0068     for a total of 32 data bytes;
0069     
0070     If parity is not configured, the format is:
0071 
0072         DAT DAT DAT ...
0073 
0074     for a total of 64 data bytes.
0075 
0076     In the TX messages (USB OUT), the 0x01 bit of the PARity byte is 
0077     the parity bit.  In the RX messages (USB IN), the PARity byte is 
0078     the content of the 8051's status register; the parity bit 
0079     (RX_PARITY_BIT) is the 0x04 bit.
0080 
0081     revision history:
0082 
0083     1999may06   add resetDataToggle to control message
0084     2000mar21   add rs232invalid to status response message
0085     2000apr04   add 230.4Kb definition to setBaudRate
0086     2000apr13   add/remove loopbackMode switch
0087     2000apr13   change definition of setBaudRate to cover 115.2Kb, too
0088     2000jun01   add extended BSD-style copyright text
0089 */
0090 
0091 #ifndef __USA28MSG__
0092 #define __USA28MSG__
0093 
0094 
0095 struct keyspan_usa28_portControlMessage
0096 {
0097     /*
0098         there are four types of "commands" sent in the control message:
0099 
0100         1.  configuration changes which must be requested by setting
0101             the corresponding "set" flag (and should only be requested
0102             when necessary, to reduce overhead on the USA28):
0103     */
0104     u8  setBaudRate,    // 0=don't set, 1=baudLo/Hi, 2=115.2K, 3=230.4K
0105         baudLo,         // host does baud divisor calculation
0106         baudHi;         // baudHi is only used for first port (gives lower rates)
0107 
0108     /*
0109         2.  configuration changes which are done every time (because it's
0110             hardly more trouble to do them than to check whether to do them):
0111     */
0112     u8  parity,         // 1=use parity, 0=don't
0113         ctsFlowControl,         // all except 19Q: 1=use CTS flow control, 0=don't
0114                     // 19Q: 0x08:CTSflowControl 0x10:DSRflowControl
0115         xonFlowControl, // 1=use XON/XOFF flow control, 0=don't
0116         rts,            // 1=on, 0=off
0117         dtr;            // 1=on, 0=off
0118 
0119     /*
0120         3.  configuration data which is simply used as is (no overhead,
0121             but must be correct in every host message).
0122     */
0123     u8  forwardingLength,  // forward when this number of chars available
0124         forwardMs,      // forward this many ms after last rx data
0125         breakThreshold, // specified in ms, 1-255 (see note below)
0126         xonChar,        // specified in current character format
0127         xoffChar;       // specified in current character format
0128 
0129     /*
0130         4.  commands which are flags only; these are processed in order
0131             (so that, e.g., if both _txOn and _txOff flags are set, the
0132             port ends in a TX_OFF state); any non-zero value is respected
0133     */
0134     u8  _txOn,          // enable transmitting (and continue if there's data)
0135         _txOff,         // stop transmitting
0136         txFlush,        // toss outbound data
0137         txForceXoff,    // pretend we've received XOFF
0138         txBreak,        // turn on break (leave on until txOn clears it)
0139         rxOn,           // turn on receiver
0140         rxOff,          // turn off receiver
0141         rxFlush,        // toss inbound data
0142         rxForward,      // forward all inbound data, NOW
0143         returnStatus,   // return current status n times (1 or 2)
0144         resetDataToggle;// reset data toggle state to DATA0
0145     
0146 };
0147 
0148 struct keyspan_usa28_portStatusMessage
0149 {
0150     u8  port,           // 0=first, 1=second, 2=global (see below)
0151         cts,
0152         dsr,            // (not used in all products)
0153         dcd,
0154 
0155         ri,             // (not used in all products)
0156         _txOff,         // port has been disabled (by host)
0157         _txXoff,        // port is in XOFF state (either host or RX XOFF)
0158         dataLost,       // count of lost chars; wraps; not guaranteed exact
0159 
0160         rxEnabled,      // as configured by rxOn/rxOff 1=on, 0=off
0161         rxBreak,        // 1=we're in break state
0162         rs232invalid,   // 1=no valid signals on rs-232 inputs
0163         controlResponse;// 1=a control messages has been processed
0164 };
0165 
0166 // bit defines in txState
0167 #define TX_OFF          0x01    // requested by host txOff command
0168 #define TX_XOFF         0x02    // either real, or simulated by host
0169 
0170 struct keyspan_usa28_globalControlMessage
0171 {
0172     u8  sendGlobalStatus,   // 2=request for two status responses
0173         resetStatusToggle,  // 1=reset global status toggle
0174         resetStatusCount;   // a cycling value
0175 };
0176 
0177 struct keyspan_usa28_globalStatusMessage
0178 {
0179     u8  port,               // 3
0180         sendGlobalStatus,   // from request, decremented
0181         resetStatusCount;   // as in request
0182 };
0183 
0184 struct keyspan_usa28_globalDebugMessage
0185 {
0186     u8  port,               // 2
0187         n,                  // typically a count/status byte
0188         b;                  // typically a data byte
0189 };
0190 
0191 // ie: the maximum length of an EZUSB endpoint buffer
0192 #define MAX_DATA_LEN            64
0193 
0194 // the parity bytes have only one significant bit
0195 #define RX_PARITY_BIT           0x04
0196 #define TX_PARITY_BIT           0x01
0197 
0198 // update status approx. 60 times a second (16.6666 ms)
0199 #define STATUS_UPDATE_INTERVAL  16
0200 
0201 #endif
0202