| 1 |
/* SPDX-License-Identifier: BSD-3-Clause */ |
| 2 |
/* |
| 3 |
usa90msg.h |
| 4 |
|
| 5 |
Copyright (c) 1998-2003 InnoSys Incorporated. All Rights Reserved |
| 6 |
This file is available under a BSD-style copyright |
| 7 |
|
| 8 |
Keyspan USB Async Message Formats for the USA19HS |
| 9 |
|
| 10 |
Redistribution and use in source and binary forms, with or without |
| 11 |
modification, are permitted provided that the following conditions are |
| 12 |
met: |
| 13 |
|
| 14 |
1. Redistributions of source code must retain this licence text |
| 15 |
without modification, this list of conditions, and the following |
| 16 |
disclaimer. The following copyright notice must appear immediately at |
| 17 |
the beginning of all source files: |
| 18 |
|
| 19 |
Copyright (c) 1998-2003 InnoSys Incorporated. All Rights Reserved |
| 20 |
|
| 21 |
This file is available under a BSD-style copyright |
| 22 |
|
| 23 |
2. The name of InnoSys Incorporated may not be used to endorse or promote |
| 24 |
products derived from this software without specific prior written |
| 25 |
permission. |
| 26 |
|
| 27 |
THIS SOFTWARE IS PROVIDED BY INNOSYS CORP. ``AS IS'' AND ANY EXPRESS OR |
| 28 |
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 29 |
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN |
| 30 |
NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
| 31 |
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 32 |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 33 |
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 34 |
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 35 |
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 36 |
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 37 |
SUCH DAMAGE. |
| 38 |
|
| 39 |
Revisions: |
| 40 |
|
| 41 |
2003feb14 add setTxMode/txMode and cancelRxXoff to portControl |
| 42 |
2003mar21 change name of PARITY_0/1 to add MARK/SPACE |
| 43 |
*/ |
| 44 |
|
| 45 |
#ifndef __USA90MSG__ |
| 46 |
#define __USA90MSG__ |
| 47 |
|
| 48 |
struct keyspan_usa90_portControlMessage |
| 49 |
{ |
| 50 |
/* |
| 51 |
there are three types of "commands" sent in the control message: |
| 52 |
|
| 53 |
1. configuration changes which must be requested by setting |
| 54 |
the corresponding "set" flag (and should only be requested |
| 55 |
when necessary, to reduce overhead on the device): |
| 56 |
*/ |
| 57 |
|
| 58 |
u8 setClocking, // host requests baud rate be set |
| 59 |
baudLo, // host does baud divisor calculation |
| 60 |
baudHi, // host does baud divisor calculation |
| 61 |
|
| 62 |
setLcr, // host requests lcr be set |
| 63 |
lcr, // use PARITY, STOPBITS, DATABITS below |
| 64 |
|
| 65 |
setRxMode, // set receive mode |
| 66 |
rxMode, // RXMODE_DMA or RXMODE_BYHAND |
| 67 |
|
| 68 |
setTxMode, // set transmit mode |
| 69 |
txMode, // TXMODE_DMA or TXMODE_BYHAND |
| 70 |
|
| 71 |
setTxFlowControl, // host requests tx flow control be set |
| 72 |
txFlowControl , // use TX_FLOW... bits below |
| 73 |
setRxFlowControl, // host requests rx flow control be set |
| 74 |
rxFlowControl, // use RX_FLOW... bits below |
| 75 |
sendXoff, // host requests XOFF transmitted immediately |
| 76 |
sendXon, // host requests XON char transmitted |
| 77 |
xonChar, // specified in current character format |
| 78 |
xoffChar, // specified in current character format |
| 79 |
|
| 80 |
sendChar, // host requests char transmitted immediately |
| 81 |
txChar, // character to send |
| 82 |
|
| 83 |
setRts, // host requests RTS output be set |
| 84 |
rts, // 1=on, 0=off |
| 85 |
setDtr, // host requests DTR output be set |
| 86 |
dtr; // 1=on, 0=off |
| 87 |
|
| 88 |
|
| 89 |
/* |
| 90 |
2. configuration data which is simply used as is |
| 91 |
and must be specified correctly in every host message. |
| 92 |
*/ |
| 93 |
|
| 94 |
u8 rxForwardingLength, // forward when this number of chars available |
| 95 |
rxForwardingTimeout, // (1-31 in ms) |
| 96 |
txAckSetting; // 0=don't ack, 1=normal, 2-255 TBD... |
| 97 |
/* |
| 98 |
3. Firmware states which cause actions if they change |
| 99 |
and must be specified correctly in every host message. |
| 100 |
*/ |
| 101 |
|
| 102 |
u8 portEnabled, // 0=disabled, 1=enabled |
| 103 |
txFlush, // 0=normal, 1=toss outbound data |
| 104 |
txBreak, // 0=break off, 1=break on |
| 105 |
loopbackMode; // 0=no loopback, 1=loopback enabled |
| 106 |
|
| 107 |
/* |
| 108 |
4. commands which are flags only; these are processed in order |
| 109 |
(so that, e.g., if rxFlush and rxForward flags are set, the |
| 110 |
port will have no data to forward); any non-zero value |
| 111 |
is respected |
| 112 |
*/ |
| 113 |
|
| 114 |
u8 rxFlush, // toss inbound data |
| 115 |
rxForward, // forward all inbound data, NOW (as if fwdLen==1) |
| 116 |
cancelRxXoff, // cancel any receive XOFF state (_txXoff) |
| 117 |
returnStatus; // return current status NOW |
| 118 |
}; |
| 119 |
|
| 120 |
// defines for bits in lcr |
| 121 |
#define USA_DATABITS_5 0x00 |
| 122 |
#define USA_DATABITS_6 0x01 |
| 123 |
#define USA_DATABITS_7 0x02 |
| 124 |
#define USA_DATABITS_8 0x03 |
| 125 |
#define STOPBITS_5678_1 0x00 // 1 stop bit for all byte sizes |
| 126 |
#define STOPBITS_5_1p5 0x04 // 1.5 stop bits for 5-bit byte |
| 127 |
#define STOPBITS_678_2 0x04 // 2 stop bits for 6-8 bit byte |
| 128 |
#define USA_PARITY_NONE 0x00 |
| 129 |
#define USA_PARITY_ODD 0x08 |
| 130 |
#define USA_PARITY_EVEN 0x18 |
| 131 |
#define PARITY_MARK_1 0x28 // force parity MARK |
| 132 |
#define PARITY_SPACE_0 0x38 // force parity SPACE |
| 133 |
|
| 134 |
#define TXFLOW_CTS 0x04 |
| 135 |
#define TXFLOW_DSR 0x08 |
| 136 |
#define TXFLOW_XOFF 0x01 |
| 137 |
#define TXFLOW_XOFF_ANY 0x02 |
| 138 |
#define TXFLOW_XOFF_BITS (TXFLOW_XOFF | TXFLOW_XOFF_ANY) |
| 139 |
|
| 140 |
#define RXFLOW_XOFF 0x10 |
| 141 |
#define RXFLOW_RTS 0x20 |
| 142 |
#define RXFLOW_DTR 0x40 |
| 143 |
#define RXFLOW_DSR_SENSITIVITY 0x80 |
| 144 |
|
| 145 |
#define RXMODE_BYHAND 0x00 |
| 146 |
#define RXMODE_DMA 0x02 |
| 147 |
|
| 148 |
#define TXMODE_BYHAND 0x00 |
| 149 |
#define TXMODE_DMA 0x02 |
| 150 |
|
| 151 |
|
| 152 |
// all things called "StatusMessage" are sent on the status endpoint |
| 153 |
|
| 154 |
struct keyspan_usa90_portStatusMessage |
| 155 |
{ |
| 156 |
u8 msr, // reports the actual MSR register |
| 157 |
cts, // reports CTS pin |
| 158 |
dcd, // reports DCD pin |
| 159 |
dsr, // reports DSR pin |
| 160 |
ri, // reports RI pin |
| 161 |
_txXoff, // port is in XOFF state (we received XOFF) |
| 162 |
rxBreak, // reports break state |
| 163 |
rxOverrun, // count of overrun errors (since last reported) |
| 164 |
rxParity, // count of parity errors (since last reported) |
| 165 |
rxFrame, // count of frame errors (since last reported) |
| 166 |
portState, // PORTSTATE_xxx bits (useful for debugging) |
| 167 |
messageAck, // message acknowledgement |
| 168 |
charAck, // character acknowledgement |
| 169 |
controlResponse; // (value = returnStatus) a control message has been processed |
| 170 |
}; |
| 171 |
|
| 172 |
// bits in RX data message when STAT byte is included |
| 173 |
|
| 174 |
#define RXERROR_OVERRUN 0x02 |
| 175 |
#define RXERROR_PARITY 0x04 |
| 176 |
#define RXERROR_FRAMING 0x08 |
| 177 |
#define RXERROR_BREAK 0x10 |
| 178 |
|
| 179 |
#define PORTSTATE_ENABLED 0x80 |
| 180 |
#define PORTSTATE_TXFLUSH 0x01 |
| 181 |
#define PORTSTATE_TXBREAK 0x02 |
| 182 |
#define PORTSTATE_LOOPBACK 0x04 |
| 183 |
|
| 184 |
// MSR bits |
| 185 |
|
| 186 |
#define USA_MSR_dCTS 0x01 // CTS has changed since last report |
| 187 |
#define USA_MSR_dDSR 0x02 |
| 188 |
#define USA_MSR_dRI 0x04 |
| 189 |
#define USA_MSR_dDCD 0x08 |
| 190 |
|
| 191 |
#define USA_MSR_CTS 0x10 // current state of CTS |
| 192 |
#define USA_MSR_DSR 0x20 |
| 193 |
#define USA_USA_MSR_RI 0x40 |
| 194 |
#define MSR_DCD 0x80 |
| 195 |
|
| 196 |
// ie: the maximum length of an endpoint buffer |
| 197 |
#define MAX_DATA_LEN 64 |
| 198 |
|
| 199 |
#endif |