Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: BSD-3-Clause */
0002 /*
0003     usa67msg.h
0004 
0005     Copyright (c) 1998-2007 InnoSys Incorporated.  All Rights Reserved
0006     This file is available under a BSD-style copyright
0007 
0008     Keyspan USB Async Firmware to run on Anchor FX1
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-2007 InnoSys Incorporated.  All Rights Reserved
0020 
0021             This file is available under a BSD-style copyright
0022 
0023     2. Redistributions in binary form must reproduce the above copyright
0024     notice, this list of conditions and the following disclaimer in the
0025     documentation and/or other materials provided with the distribution.
0026 
0027     3. The name of InnoSys Incorprated may not be used to endorse or promote
0028     products derived from this software without specific prior written
0029     permission.
0030 
0031     THIS SOFTWARE IS PROVIDED BY INNOSYS CORP. ``AS IS'' AND ANY EXPRESS OR
0032     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
0033     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
0034     NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
0035     INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
0036     (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
0037     SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
0038     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
0039     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
0040     OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
0041     SUCH DAMAGE.
0042 
0043     Fourth revision: This message format supports the USA28XG
0044 
0045     Buffer formats for RX/TX data messages are not defined by
0046     a structure, but are described here:
0047 
0048     USB OUT (host -> USAxx, transmit) messages contain a
0049     REQUEST_ACK indicator (set to 0xff to request an ACK at the
0050     completion of transmit; 0x00 otherwise), followed by data:
0051 
0052         RQSTACK DAT DAT DAT ...
0053 
0054     with a total data length of up to 63.
0055 
0056     USB IN (USAxx -> host, receive) messages begin with a status
0057     byte in which the 0x80 bit is either:
0058 
0059         (a) 0x80 bit clear
0060             indicates that the bytes following it are all data
0061             bytes:
0062 
0063                 STAT DATA DATA DATA DATA DATA ...
0064 
0065             for a total of up to 63 DATA bytes,
0066 
0067     or:
0068 
0069         (b) 0x80 bit set
0070             indiates that the bytes following alternate data and
0071             status bytes:
0072 
0073                 STAT DATA STAT DATA STAT DATA STAT DATA ...
0074 
0075             for a total of up to 32 DATA bytes.
0076 
0077     The valid bits in the STAT bytes are:
0078 
0079         OVERRUN 0x02
0080         PARITY  0x04
0081         FRAMING 0x08
0082         BREAK   0x10
0083 
0084     Notes:
0085 
0086     (1) The OVERRUN bit can appear in either (a) or (b) format
0087         messages, but the but the PARITY/FRAMING/BREAK bits
0088         only appear in (b) format messages.
0089     (2) For the host to determine the exact point at which the
0090         overrun occurred (to identify the point in the data
0091         stream at which the data was lost), it needs to count
0092         128 characters, starting at the first character of the
0093         message in which OVERRUN was reported; the lost character(s)
0094         would have been received between the 128th and 129th
0095         characters.
0096     (3) An RX data message in which the first byte has 0x80 clear
0097         serves as a "break off" indicator.
0098 
0099     revision history:
0100 
0101     1999feb10   add reportHskiaChanges to allow us to ignore them
0102     1999feb10   add txAckThreshold for fast+loose throughput enhancement
0103     1999mar30   beef up support for RX error reporting
0104     1999apr14   add resetDataToggle to control message
0105     2000jan04   merge with usa17msg.h
0106     2000jun01   add extended BSD-style copyright text
0107     2001jul05   change message format to improve OVERRUN case
0108     2002jun05   update copyright date, improve comments
0109     2006feb06   modify for FX1 chip
0110 
0111 */
0112 
0113 #ifndef __USA67MSG__
0114 #define __USA67MSG__
0115 
0116 
0117 // all things called "ControlMessage" are sent on the 'control' endpoint
0118 
0119 typedef struct keyspan_usa67_portControlMessage
0120 {
0121     u8  port;       // 0 or 1 (selects port)
0122     /*
0123         there are three types of "commands" sent in the control message:
0124 
0125         1.  configuration changes which must be requested by setting
0126             the corresponding "set" flag (and should only be requested
0127             when necessary, to reduce overhead on the device):
0128     */
0129     u8  setClocking,    // host requests baud rate be set
0130         baudLo,         // host does baud divisor calculation
0131         baudHi,         // baudHi is only used for first port (gives lower rates)
0132         externalClock_txClocking,
0133                         // 0=internal, other=external
0134 
0135         setLcr,         // host requests lcr be set
0136         lcr,            // use PARITY, STOPBITS, DATABITS below
0137 
0138         setFlowControl, // host requests flow control be set
0139         ctsFlowControl, // 1=use CTS flow control, 0=don't
0140         xonFlowControl, // 1=use XON/XOFF flow control, 0=don't
0141         xonChar,        // specified in current character format
0142         xoffChar,       // specified in current character format
0143 
0144         setTxTriState_setRts,
0145                         // host requests TX tri-state be set
0146         txTriState_rts, // 1=active (normal), 0=tristate (off)
0147 
0148         setHskoa_setDtr,
0149                         // host requests HSKOA output be set
0150         hskoa_dtr,      // 1=on, 0=off
0151 
0152         setPrescaler,   // host requests prescalar be set (default: 13)
0153         prescaler;      // specified as N/8; values 8-ff are valid
0154                         // must be set any time internal baud rate is set;
0155                         // must not be set when external clocking is used
0156 
0157     /*
0158         3.  configuration data which is simply used as is (no overhead,
0159             but must be specified correctly in every host message).
0160     */
0161     u8  forwardingLength,  // forward when this number of chars available
0162         reportHskiaChanges_dsrFlowControl,
0163                         // 1=normal; 0=ignore external clock
0164                         // 1=use DSR flow control, 0=don't
0165         txAckThreshold, // 0=not allowed, 1=normal, 2-255 deliver ACK faster
0166         loopbackMode;   // 0=no loopback, 1=loopback enabled
0167 
0168     /*
0169         4.  commands which are flags only; these are processed in order
0170             (so that, e.g., if both _txOn and _txOff flags are set, the
0171             port ends in a TX_OFF state); any non-zero value is respected
0172     */
0173     u8  _txOn,          // enable transmitting (and continue if there's data)
0174         _txOff,         // stop transmitting
0175         txFlush,        // toss outbound data
0176         txBreak,        // turn on break (cleared by _txOn)
0177         rxOn,           // turn on receiver
0178         rxOff,          // turn off receiver
0179         rxFlush,        // toss inbound data
0180         rxForward,      // forward all inbound data, NOW (as if fwdLen==1)
0181         returnStatus,   // return current status (even if it hasn't changed)
0182         resetDataToggle;// reset data toggle state to DATA0
0183 
0184 } keyspan_usa67_portControlMessage;
0185 
0186 // defines for bits in lcr
0187 #define USA_DATABITS_5      0x00
0188 #define USA_DATABITS_6      0x01
0189 #define USA_DATABITS_7      0x02
0190 #define USA_DATABITS_8      0x03
0191 #define STOPBITS_5678_1     0x00    // 1 stop bit for all byte sizes
0192 #define STOPBITS_5_1p5      0x04    // 1.5 stop bits for 5-bit byte
0193 #define STOPBITS_678_2      0x04    // 2 stop bits for 6/7/8-bit byte
0194 #define USA_PARITY_NONE     0x00
0195 #define USA_PARITY_ODD      0x08
0196 #define USA_PARITY_EVEN     0x18
0197 #define PARITY_1            0x28
0198 #define PARITY_0            0x38
0199 
0200 // all things called "StatusMessage" are sent on the status endpoint
0201 
0202 typedef struct keyspan_usa67_portStatusMessage  // one for each port
0203 {
0204     u8  port,           // 0=first, 1=second, other=see below
0205         hskia_cts,      // reports HSKIA pin
0206         gpia_dcd,       // reports GPIA pin
0207         _txOff,         // port has been disabled (by host)
0208         _txXoff,        // port is in XOFF state (either host or RX XOFF)
0209         txAck,          // indicates a TX message acknowledgement
0210         rxEnabled,      // as configured by rxOn/rxOff 1=on, 0=off
0211         controlResponse;// 1=a control message has been processed
0212 } keyspan_usa67_portStatusMessage;
0213 
0214 // bits in RX data message when STAT byte is included
0215 #define RXERROR_OVERRUN 0x02
0216 #define RXERROR_PARITY  0x04
0217 #define RXERROR_FRAMING 0x08
0218 #define RXERROR_BREAK   0x10
0219 
0220 typedef struct keyspan_usa67_globalControlMessage
0221 {
0222     u8  port,               // 3
0223         sendGlobalStatus,   // 2=request for two status responses
0224         resetStatusToggle,  // 1=reset global status toggle
0225         resetStatusCount;   // a cycling value
0226 } keyspan_usa67_globalControlMessage;
0227 
0228 typedef struct keyspan_usa67_globalStatusMessage
0229 {
0230     u8  port,               // 3
0231         sendGlobalStatus,   // from request, decremented
0232         resetStatusCount;   // as in request
0233 } keyspan_usa67_globalStatusMessage;
0234 
0235 typedef struct keyspan_usa67_globalDebugMessage
0236 {
0237     u8  port,               // 2
0238         a,
0239         b,
0240         c,
0241         d;
0242 } keyspan_usa67_globalDebugMessage;
0243 
0244 // ie: the maximum length of an FX1 endpoint buffer
0245 #define MAX_DATA_LEN            64
0246 
0247 // update status approx. 60 times a second (16.6666 ms)
0248 #define STATUS_UPDATE_INTERVAL  16
0249 
0250 // status rationing tuning value (each port gets checked each n ms)
0251 #define STATUS_RATION   10
0252 
0253 #endif
0254 
0255