summaryrefslogtreecommitdiff
path: root/src/class/cdc/serial
diff options
context:
space:
mode:
authorIngHK <[email protected]>2024-02-22 15:42:33 +0100
committerIngHK <[email protected]>2024-02-24 12:58:59 +0100
commit4547737833de0368354cb4823d908c6b250f92df (patch)
treee3af98f6f5f0fe82a3f1dbd203d43aa221176762 /src/class/cdc/serial
parent7fef5943eff0d7f1b7122e878cf2caa78bea06aa (diff)
improved CP210x support
Diffstat (limited to 'src/class/cdc/serial')
-rw-r--r--src/class/cdc/serial/cp210x.h63
1 files changed, 62 insertions, 1 deletions
diff --git a/src/class/cdc/serial/cp210x.h b/src/class/cdc/serial/cp210x.h
index 2c749f522..e18da7d51 100644
--- a/src/class/cdc/serial/cp210x.h
+++ b/src/class/cdc/serial/cp210x.h
@@ -28,7 +28,8 @@
// Protocol details can be found at AN571: CP210x Virtual COM Port Interface
// https://www.silabs.com/documents/public/application-notes/AN571.pdf
-#define TU_CP210X_VID 0x10C4
+// parts are overtaken from vendors driver
+// https://www.silabs.com/documents/public/software/cp210x-3.1.0.tar.gz
/* Config request codes */
#define CP210X_IFC_ENABLE 0x00
@@ -59,4 +60,64 @@
#define CP210X_SET_BAUDRATE 0x1E
#define CP210X_VENDOR_SPECIFIC 0xFF // GPIO, Recipient must be Device
+/* SILABSER_IFC_ENABLE_REQUEST_CODE */
+#define CP210X_UART_ENABLE 0x0001
+#define CP210X_UART_DISABLE 0x0000
+
+/* SILABSER_SET_BAUDDIV_REQUEST_CODE */
+#define CP210X_BAUD_RATE_GEN_FREQ 0x384000
+
+/*SILABSER_SET_LINE_CTL_REQUEST_CODE */
+#define CP210X_BITS_DATA_MASK 0x0f00
+#define CP210X_BITS_DATA_5 0x0500
+#define CP210X_BITS_DATA_6 0x0600
+#define CP210X_BITS_DATA_7 0x0700
+#define CP210X_BITS_DATA_8 0x0800
+#define CP210X_BITS_DATA_9 0x0900
+
+#define CP210X_BITS_PARITY_MASK 0x00f0
+#define CP210X_BITS_PARITY_NONE 0x0000
+#define CP210X_BITS_PARITY_ODD 0x0010
+#define CP210X_BITS_PARITY_EVEN 0x0020
+#define CP210X_BITS_PARITY_MARK 0x0030
+#define CP210X_BITS_PARITY_SPACE 0x0040
+
+#define CP210X_BITS_STOP_MASK 0x000f
+#define CP210X_BITS_STOP_1 0x0000
+#define CP210X_BITS_STOP_1_5 0x0001
+#define CP210X_BITS_STOP_2 0x0002
+
+/* SILABSER_SET_BREAK_REQUEST_CODE */
+#define CP210X_BREAK_ON 0x0001
+#define CP210X_BREAK_OFF 0x0000
+
+/* SILABSER_SET_MHS_REQUEST_CODE */
+#define CP210X_MCR_DTR 0x0001
+#define CP210X_MCR_RTS 0x0002
+#define CP210X_MCR_ALL 0x0003
+#define CP210X_MSR_CTS 0x0010
+#define CP210X_MSR_DSR 0x0020
+#define CP210X_MSR_RING 0x0040
+#define CP210X_MSR_DCD 0x0080
+#define CP210X_MSR_ALL 0x00F0
+
+#define CP210X_CONTROL_WRITE_DTR 0x0100
+#define CP210X_CONTROL_WRITE_RTS 0x0200
+
+#define CP210X_LSR_BREAK 0x0001
+#define CP210X_LSR_FRAMING_ERROR 0x0002
+#define CP210X_LSR_HW_OVERRUN 0x0004
+#define CP210X_LSR_QUEUE_OVERRUN 0x0008
+#define CP210X_LSR_PARITY_ERROR 0x0010
+#define CP210X_LSR_ALL 0x001F
+
+// supported baudrates
+// reference: datasheets and AN205 "CP210x Baud Rate Support"
+#define CP210X_SUPPORTED_BAUDRATES_LIST { \
+ 300, 600, \
+ 1200, 1800, 2400, 4000, 4800, 7200, 9600, \
+ 14400, 16000, 19200, 28800, 38400, 51200, 56000, 57600, 64000, 76800, \
+ 115200, 128000, 153600, 230400, 250000, 256000, 460800, 500000, 576000, 921600, \
+ 0 }
+
#endif //TUSB_CP210X_H