summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIngHK <[email protected]>2024-04-04 14:12:14 +0200
committerIngHK <[email protected]>2024-04-04 14:12:14 +0200
commite07ee4a7b1f7c7d18f385d605dd41e08962ddba4 (patch)
tree7ec833b471b2d40f842a7bc0673803f046f66847 /src
parent5e67b92b8c398d6fee92010ecd63cf50b51f8f9a (diff)
CP210x removed baudrate check, fixed data bits check
Diffstat (limited to 'src')
-rw-r--r--src/class/cdc/cdc_host.c12
-rw-r--r--src/class/cdc/serial/cp210x.h9
2 files changed, 2 insertions, 19 deletions
diff --git a/src/class/cdc/cdc_host.c b/src/class/cdc/cdc_host.c
index 2d900a753..73d800469 100644
--- a/src/class/cdc/cdc_host.c
+++ b/src/class/cdc/cdc_host.c
@@ -1701,22 +1701,14 @@ static inline bool cp210x_ifc_enable(cdch_interface_t * p_cdc, uint16_t enabled,
}
static bool cp210x_set_baudrate_request(cdch_interface_t * p_cdc, tuh_xfer_cb_t complete_cb, uintptr_t user_data) {
- // Check baudrate is supported. It's only a specific list. reference: datasheets and AN205 "CP210x Baud Rate Support"
- uint32_t const supported_baudrates_list[] = CP210X_SUPPORTED_BAUDRATES_LIST;
- uint8_t i;
- for ( i=0; supported_baudrates_list[i]; i++ ){
- if (p_cdc->requested_line_coding.bit_rate == supported_baudrates_list[i]) {
- break;
- }
- }
- TU_VERIFY(supported_baudrates_list[i]);
+ // Not every baud rate is supported. See datasheets and AN205 "CP210x Baud Rate Support"
uint32_t baud_le = tu_htole32(p_cdc->requested_line_coding.bit_rate);
return cp210x_set_request(p_cdc, CP210X_SET_BAUDRATE, 0, (uint8_t *) &baud_le, 4, complete_cb, user_data);
}
static bool cp210x_set_line_ctl(cdch_interface_t * p_cdc, tuh_xfer_cb_t complete_cb, uintptr_t user_data) {
- TU_VERIFY(p_cdc->requested_line_coding.data_bits >= 5 && p_cdc->requested_line_coding.data_bits <= 9, 0);
+ TU_VERIFY(p_cdc->requested_line_coding.data_bits >= 5 && p_cdc->requested_line_coding.data_bits <= 8, 0);
uint16_t lcr = (uint16_t) (
(p_cdc->requested_line_coding.data_bits & 0xfUL) << 8 | // data bit quantity is stored in bits 8-11
(p_cdc->requested_line_coding.parity & 0xfUL) << 4 | // parity is stored in bits 4-7, same coding
diff --git a/src/class/cdc/serial/cp210x.h b/src/class/cdc/serial/cp210x.h
index ac9c27330..a0eff9e40 100644
--- a/src/class/cdc/serial/cp210x.h
+++ b/src/class/cdc/serial/cp210x.h
@@ -111,13 +111,4 @@
#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