/* * The MIT License (MIT) * * Copyright (c) 2023 Heiko Kuester * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * This file is part of the TinyUSB stack. *//* ... */#ifndef_CH34X_H_#define_CH34X_H_// There is no official documentation for the CH34x (CH340, CH341) chips. Reference can be found// - https://github.com/WCHSoftGroup/ch341ser_linux// - https://github.com/torvalds/linux/blob/master/drivers/usb/serial/ch341.c// - https://github.com/freebsd/freebsd-src/blob/main/sys/dev/usb/serial/uchcom.c// set line_coding @ enumeration#ifdefCFG_TUH_CDC_LINE_CODING_ON_ENUM#defineCFG_TUH_CDC_LINE_CODING_ON_ENUM_CH34XCFG_TUH_CDC_LINE_CODING_ON_ENUM#else// this default is necessary to work properly#defineCFG_TUH_CDC_LINE_CODING_ON_ENUM_CH34X{9600,CDC_LINE_CONDING_STOP_BITS_1,CDC_LINE_CODING_PARITY_NONE,8}#endif// USB requests#defineCH34X_REQ_READ_VERSION0x5F// dec 95#defineCH34X_REQ_WRITE_REG0x9A// dec 154#defineCH34X_REQ_READ_REG0x95// dec 149#defineCH34X_REQ_SERIAL_INIT0xA1// dec 161#defineCH34X_REQ_MODEM_CTRL0xA4// dev 164// registers#defineCH34X_REG_BREAK0x05#defineCH34X_REG_PRESCALER0x12#defineCH34X_REG_DIVISOR0x13#defineCH34X_REG_LCR0x18#defineCH34X_REG_LCR20x25#defineCH34X_REG_MCR_MSR0x06#defineCH34X_REG_MCR_MSR20x07#defineCH34X_NBREAK_BITS0x01#defineCH341_REG_0x0F0x0F// undocumented register#defineCH341_REG_0x2C0x2C// undocumented register#defineCH341_REG_0x270x27// hardware flow control (cts/rts)#defineCH34X_REG16_DIVISOR_PRESCALERTU_U16(CH34X_REG_DIVISOR,CH34X_REG_PRESCALER)#defineCH32X_REG16_LCR2_LCRTU_U16(CH34X_REG_LCR2,CH34X_REG_LCR)// modem control bits#defineCH34X_BIT_RTS(1<<6)#defineCH34X_BIT_DTR(1<<5)// line control bits#defineCH34X_LCR_ENABLE_RX0x80#defineCH34X_LCR_ENABLE_TX0x40#defineCH34X_LCR_MARK_SPACE0x20#defineCH34X_LCR_PAR_EVEN0x10#defineCH34X_LCR_ENABLE_PAR0x08#defineCH34X_LCR_PAR_MASK0x38// all parity bits#defineCH34X_LCR_STOP_BITS_20x04#defineCH34X_LCR_CS80x03#defineCH34X_LCR_CS70x02#defineCH34X_LCR_CS60x01#defineCH34X_LCR_CS50x00#defineCH34X_LCR_CS_MASK0x03// all CSx bits32 defines/* ... */#endif/* _CH34X_H_ */
Details
Show: from
Types: Columns:
All items filtered out
All items filtered out
This file uses the notable symbols shown below. Click anywhere in the file to view more details.