CP210x removed baudrate check, fixed data bits check
This commit is contained in:
@@ -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) {
|
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"
|
// Not every baud rate is supported. See 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]);
|
|
||||||
uint32_t baud_le = tu_htole32(p_cdc->requested_line_coding.bit_rate);
|
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);
|
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) {
|
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) (
|
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.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
|
(p_cdc->requested_line_coding.parity & 0xfUL) << 4 | // parity is stored in bits 4-7, same coding
|
||||||
|
|||||||
@@ -111,13 +111,4 @@
|
|||||||
#define CP210X_LSR_PARITY_ERROR 0x0010
|
#define CP210X_LSR_PARITY_ERROR 0x0010
|
||||||
#define CP210X_LSR_ALL 0x001F
|
#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
|
#endif //TUSB_CP210X_H
|
||||||
|
|||||||
Reference in New Issue
Block a user