summaryrefslogtreecommitdiff
path: root/src/class/cdc/serial
diff options
context:
space:
mode:
authorIngHK <[email protected]>2024-01-16 07:57:06 +0100
committerIngHK <[email protected]>2024-01-16 07:57:06 +0100
commit43e655b896fab0d3dd8f2c2d1d987713d87036f6 (patch)
treeda171d665631d8ab601d39dd797a7dfb6045fcac /src/class/cdc/serial
parentc2bbcc9f60a2b7293fad4e24468d3f045fde28ee (diff)
parent4b3b401ce37e12eaf4c85a5184d94327c28c70a5 (diff)
Merge remote-tracking branch 'remotes/hathach/master' into cdc_ch34x_support
Diffstat (limited to 'src/class/cdc/serial')
-rw-r--r--src/class/cdc/serial/ch34x.h.bak60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/class/cdc/serial/ch34x.h.bak b/src/class/cdc/serial/ch34x.h.bak
new file mode 100644
index 000000000..f77434b31
--- /dev/null
+++ b/src/class/cdc/serial/ch34x.h.bak
@@ -0,0 +1,60 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2023 Heiko Kuester (tinyusb.org)
+ *
+ * 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_
+
+// set line_coding
+#ifdef CFG_TUH_CDC_LINE_CODING_ON_ENUM
+#define CFG_TUH_CDC_LINE_CODING_ON_ENUM_CH341 CFG_TUH_CDC_LINE_CODING_ON_ENUM
+#else // this default is necessary to work properly
+#define CFG_TUH_CDC_LINE_CODING_ON_ENUM_CH341 { 9600, CDC_LINE_CONDING_STOP_BITS_1, CDC_LINE_CODING_PARITY_NONE, 8 }
+#endif
+
+// USB requests
+#define CH341_REQ_READ_VERSION 0x5F // dec 95
+#define CH341_REQ_WRITE_REG 0x9A // dec 154
+#define CH341_REQ_READ_REG 0x95 // dec 149
+#define CH341_REQ_SERIAL_INIT 0xA1 // dec 161
+#define CH341_REQ_MODEM_CTRL 0xA4 // dev 164
+
+// modem control bits
+#define CH341_BIT_RTS ( 1 << 6 )
+#define CH341_BIT_DTR ( 1 << 5 )
+
+// line control bits
+#define CH341_LCR_ENABLE_RX 0x80
+#define CH341_LCR_ENABLE_TX 0x40
+#define CH341_LCR_MARK_SPACE 0x20
+#define CH341_LCR_PAR_EVEN 0x10
+#define CH341_LCR_ENABLE_PAR 0x08
+#define CH341_LCR_STOP_BITS_2 0x04
+#define CH341_LCR_CS8 0x03
+#define CH341_LCR_CS7 0x02
+#define CH341_LCR_CS6 0x01
+#define CH341_LCR_CS5 0x00
+
+#endif /* _CH34X_H_ */