18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: BSD-3-Clause */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci usa90msg.h 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci Copyright (c) 1998-2003 InnoSys Incorporated. All Rights Reserved 68c2ecf20Sopenharmony_ci This file is available under a BSD-style copyright 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci Keyspan USB Async Message Formats for the USA19HS 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci Redistribution and use in source and binary forms, with or without 118c2ecf20Sopenharmony_ci modification, are permitted provided that the following conditions are 128c2ecf20Sopenharmony_ci met: 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci 1. Redistributions of source code must retain this licence text 158c2ecf20Sopenharmony_ci without modification, this list of conditions, and the following 168c2ecf20Sopenharmony_ci disclaimer. The following copyright notice must appear immediately at 178c2ecf20Sopenharmony_ci the beginning of all source files: 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci Copyright (c) 1998-2003 InnoSys Incorporated. All Rights Reserved 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci This file is available under a BSD-style copyright 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci 2. The name of InnoSys Incorporated may not be used to endorse or promote 248c2ecf20Sopenharmony_ci products derived from this software without specific prior written 258c2ecf20Sopenharmony_ci permission. 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci THIS SOFTWARE IS PROVIDED BY INNOSYS CORP. ``AS IS'' AND ANY EXPRESS OR 288c2ecf20Sopenharmony_ci IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 298c2ecf20Sopenharmony_ci OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 308c2ecf20Sopenharmony_ci NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 318c2ecf20Sopenharmony_ci INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 328c2ecf20Sopenharmony_ci (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 338c2ecf20Sopenharmony_ci SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 348c2ecf20Sopenharmony_ci CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 358c2ecf20Sopenharmony_ci LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 368c2ecf20Sopenharmony_ci OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 378c2ecf20Sopenharmony_ci SUCH DAMAGE. 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci Revisions: 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci 2003feb14 add setTxMode/txMode and cancelRxXoff to portControl 428c2ecf20Sopenharmony_ci 2003mar21 change name of PARITY_0/1 to add MARK/SPACE 438c2ecf20Sopenharmony_ci*/ 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci#ifndef __USA90MSG__ 468c2ecf20Sopenharmony_ci#define __USA90MSG__ 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_cistruct keyspan_usa90_portControlMessage 498c2ecf20Sopenharmony_ci{ 508c2ecf20Sopenharmony_ci /* 518c2ecf20Sopenharmony_ci there are three types of "commands" sent in the control message: 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci 1. configuration changes which must be requested by setting 548c2ecf20Sopenharmony_ci the corresponding "set" flag (and should only be requested 558c2ecf20Sopenharmony_ci when necessary, to reduce overhead on the device): 568c2ecf20Sopenharmony_ci */ 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci u8 setClocking, // host requests baud rate be set 598c2ecf20Sopenharmony_ci baudLo, // host does baud divisor calculation 608c2ecf20Sopenharmony_ci baudHi, // host does baud divisor calculation 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci setLcr, // host requests lcr be set 638c2ecf20Sopenharmony_ci lcr, // use PARITY, STOPBITS, DATABITS below 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci setRxMode, // set receive mode 668c2ecf20Sopenharmony_ci rxMode, // RXMODE_DMA or RXMODE_BYHAND 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci setTxMode, // set transmit mode 698c2ecf20Sopenharmony_ci txMode, // TXMODE_DMA or TXMODE_BYHAND 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci setTxFlowControl, // host requests tx flow control be set 728c2ecf20Sopenharmony_ci txFlowControl , // use TX_FLOW... bits below 738c2ecf20Sopenharmony_ci setRxFlowControl, // host requests rx flow control be set 748c2ecf20Sopenharmony_ci rxFlowControl, // use RX_FLOW... bits below 758c2ecf20Sopenharmony_ci sendXoff, // host requests XOFF transmitted immediately 768c2ecf20Sopenharmony_ci sendXon, // host requests XON char transmitted 778c2ecf20Sopenharmony_ci xonChar, // specified in current character format 788c2ecf20Sopenharmony_ci xoffChar, // specified in current character format 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci sendChar, // host requests char transmitted immediately 818c2ecf20Sopenharmony_ci txChar, // character to send 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci setRts, // host requests RTS output be set 848c2ecf20Sopenharmony_ci rts, // 1=on, 0=off 858c2ecf20Sopenharmony_ci setDtr, // host requests DTR output be set 868c2ecf20Sopenharmony_ci dtr; // 1=on, 0=off 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci /* 908c2ecf20Sopenharmony_ci 2. configuration data which is simply used as is 918c2ecf20Sopenharmony_ci and must be specified correctly in every host message. 928c2ecf20Sopenharmony_ci */ 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci u8 rxForwardingLength, // forward when this number of chars available 958c2ecf20Sopenharmony_ci rxForwardingTimeout, // (1-31 in ms) 968c2ecf20Sopenharmony_ci txAckSetting; // 0=don't ack, 1=normal, 2-255 TBD... 978c2ecf20Sopenharmony_ci /* 988c2ecf20Sopenharmony_ci 3. Firmware states which cause actions if they change 998c2ecf20Sopenharmony_ci and must be specified correctly in every host message. 1008c2ecf20Sopenharmony_ci */ 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci u8 portEnabled, // 0=disabled, 1=enabled 1038c2ecf20Sopenharmony_ci txFlush, // 0=normal, 1=toss outbound data 1048c2ecf20Sopenharmony_ci txBreak, // 0=break off, 1=break on 1058c2ecf20Sopenharmony_ci loopbackMode; // 0=no loopback, 1=loopback enabled 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci /* 1088c2ecf20Sopenharmony_ci 4. commands which are flags only; these are processed in order 1098c2ecf20Sopenharmony_ci (so that, e.g., if rxFlush and rxForward flags are set, the 1108c2ecf20Sopenharmony_ci port will have no data to forward); any non-zero value 1118c2ecf20Sopenharmony_ci is respected 1128c2ecf20Sopenharmony_ci */ 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ci u8 rxFlush, // toss inbound data 1158c2ecf20Sopenharmony_ci rxForward, // forward all inbound data, NOW (as if fwdLen==1) 1168c2ecf20Sopenharmony_ci cancelRxXoff, // cancel any receive XOFF state (_txXoff) 1178c2ecf20Sopenharmony_ci returnStatus; // return current status NOW 1188c2ecf20Sopenharmony_ci}; 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ci// defines for bits in lcr 1218c2ecf20Sopenharmony_ci#define USA_DATABITS_5 0x00 1228c2ecf20Sopenharmony_ci#define USA_DATABITS_6 0x01 1238c2ecf20Sopenharmony_ci#define USA_DATABITS_7 0x02 1248c2ecf20Sopenharmony_ci#define USA_DATABITS_8 0x03 1258c2ecf20Sopenharmony_ci#define STOPBITS_5678_1 0x00 // 1 stop bit for all byte sizes 1268c2ecf20Sopenharmony_ci#define STOPBITS_5_1p5 0x04 // 1.5 stop bits for 5-bit byte 1278c2ecf20Sopenharmony_ci#define STOPBITS_678_2 0x04 // 2 stop bits for 6-8 bit byte 1288c2ecf20Sopenharmony_ci#define USA_PARITY_NONE 0x00 1298c2ecf20Sopenharmony_ci#define USA_PARITY_ODD 0x08 1308c2ecf20Sopenharmony_ci#define USA_PARITY_EVEN 0x18 1318c2ecf20Sopenharmony_ci#define PARITY_MARK_1 0x28 // force parity MARK 1328c2ecf20Sopenharmony_ci#define PARITY_SPACE_0 0x38 // force parity SPACE 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci#define TXFLOW_CTS 0x04 1358c2ecf20Sopenharmony_ci#define TXFLOW_DSR 0x08 1368c2ecf20Sopenharmony_ci#define TXFLOW_XOFF 0x01 1378c2ecf20Sopenharmony_ci#define TXFLOW_XOFF_ANY 0x02 1388c2ecf20Sopenharmony_ci#define TXFLOW_XOFF_BITS (TXFLOW_XOFF | TXFLOW_XOFF_ANY) 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci#define RXFLOW_XOFF 0x10 1418c2ecf20Sopenharmony_ci#define RXFLOW_RTS 0x20 1428c2ecf20Sopenharmony_ci#define RXFLOW_DTR 0x40 1438c2ecf20Sopenharmony_ci#define RXFLOW_DSR_SENSITIVITY 0x80 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_ci#define RXMODE_BYHAND 0x00 1468c2ecf20Sopenharmony_ci#define RXMODE_DMA 0x02 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ci#define TXMODE_BYHAND 0x00 1498c2ecf20Sopenharmony_ci#define TXMODE_DMA 0x02 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_ci// all things called "StatusMessage" are sent on the status endpoint 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_cistruct keyspan_usa90_portStatusMessage 1558c2ecf20Sopenharmony_ci{ 1568c2ecf20Sopenharmony_ci u8 msr, // reports the actual MSR register 1578c2ecf20Sopenharmony_ci cts, // reports CTS pin 1588c2ecf20Sopenharmony_ci dcd, // reports DCD pin 1598c2ecf20Sopenharmony_ci dsr, // reports DSR pin 1608c2ecf20Sopenharmony_ci ri, // reports RI pin 1618c2ecf20Sopenharmony_ci _txXoff, // port is in XOFF state (we received XOFF) 1628c2ecf20Sopenharmony_ci rxBreak, // reports break state 1638c2ecf20Sopenharmony_ci rxOverrun, // count of overrun errors (since last reported) 1648c2ecf20Sopenharmony_ci rxParity, // count of parity errors (since last reported) 1658c2ecf20Sopenharmony_ci rxFrame, // count of frame errors (since last reported) 1668c2ecf20Sopenharmony_ci portState, // PORTSTATE_xxx bits (useful for debugging) 1678c2ecf20Sopenharmony_ci messageAck, // message acknowledgement 1688c2ecf20Sopenharmony_ci charAck, // character acknowledgement 1698c2ecf20Sopenharmony_ci controlResponse; // (value = returnStatus) a control message has been processed 1708c2ecf20Sopenharmony_ci}; 1718c2ecf20Sopenharmony_ci 1728c2ecf20Sopenharmony_ci// bits in RX data message when STAT byte is included 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_ci#define RXERROR_OVERRUN 0x02 1758c2ecf20Sopenharmony_ci#define RXERROR_PARITY 0x04 1768c2ecf20Sopenharmony_ci#define RXERROR_FRAMING 0x08 1778c2ecf20Sopenharmony_ci#define RXERROR_BREAK 0x10 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ci#define PORTSTATE_ENABLED 0x80 1808c2ecf20Sopenharmony_ci#define PORTSTATE_TXFLUSH 0x01 1818c2ecf20Sopenharmony_ci#define PORTSTATE_TXBREAK 0x02 1828c2ecf20Sopenharmony_ci#define PORTSTATE_LOOPBACK 0x04 1838c2ecf20Sopenharmony_ci 1848c2ecf20Sopenharmony_ci// MSR bits 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_ci#define USA_MSR_dCTS 0x01 // CTS has changed since last report 1878c2ecf20Sopenharmony_ci#define USA_MSR_dDSR 0x02 1888c2ecf20Sopenharmony_ci#define USA_MSR_dRI 0x04 1898c2ecf20Sopenharmony_ci#define USA_MSR_dDCD 0x08 1908c2ecf20Sopenharmony_ci 1918c2ecf20Sopenharmony_ci#define USA_MSR_CTS 0x10 // current state of CTS 1928c2ecf20Sopenharmony_ci#define USA_MSR_DSR 0x20 1938c2ecf20Sopenharmony_ci#define USA_USA_MSR_RI 0x40 1948c2ecf20Sopenharmony_ci#define MSR_DCD 0x80 1958c2ecf20Sopenharmony_ci 1968c2ecf20Sopenharmony_ci// ie: the maximum length of an endpoint buffer 1978c2ecf20Sopenharmony_ci#define MAX_DATA_LEN 64 1988c2ecf20Sopenharmony_ci 1998c2ecf20Sopenharmony_ci#endif 200