Skip to content

Commit bd3fba4

Browse files
committed
sync tinyusb upstream
1 parent 27ae871 commit bd3fba4

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/class/cdc/cdc_host.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,7 +1377,7 @@ static inline bool ch34x_control_in(cdch_interface_t* p_cdc, uint8_t request, ui
13771377
complete_cb, user_data);
13781378
}
13791379

1380-
static bool ch34x_write_reg(cdch_interface_t* p_cdc, uint16_t reg, uint16_t reg_value, tuh_xfer_cb_t complete_cb, uintptr_t user_data) {
1380+
static inline bool ch34x_write_reg(cdch_interface_t* p_cdc, uint16_t reg, uint16_t reg_value, tuh_xfer_cb_t complete_cb, uintptr_t user_data) {
13811381
return ch34x_control_out(p_cdc, CH34X_REQ_WRITE_REG, reg, reg_value, complete_cb, user_data);
13821382
}
13831383

@@ -1390,7 +1390,7 @@ static bool ch34x_write_reg(cdch_interface_t* p_cdc, uint16_t reg, uint16_t reg_
13901390
static bool ch34x_write_reg_baudrate(cdch_interface_t* p_cdc, uint32_t baudrate,
13911391
tuh_xfer_cb_t complete_cb, uintptr_t user_data) {
13921392
uint16_t const div_ps = ch34x_get_divisor_prescaler(baudrate);
1393-
TU_VERIFY(div_ps != 0);
1393+
TU_VERIFY(div_ps);
13941394
TU_ASSERT(ch34x_write_reg(p_cdc, CH34X_REG16_DIVISOR_PRESCALER, div_ps,
13951395
complete_cb, user_data));
13961396
return true;
@@ -1411,7 +1411,7 @@ static bool ch34x_set_data_format(cdch_interface_t* p_cdc, uint8_t stop_bits, ui
14111411
p_cdc->requested_line_coding.data_bits = data_bits;
14121412

14131413
uint8_t const lcr = ch34x_get_lcr(stop_bits, parity, data_bits);
1414-
TU_VERIFY(lcr != 0);
1414+
TU_VERIFY(lcr);
14151415
TU_ASSERT (ch34x_control_out(p_cdc, CH34X_REQ_WRITE_REG, CH32X_REG16_LCR2_LCR, lcr,
14161416
complete_cb ? ch34x_control_complete : NULL, user_data));
14171417
return true;
@@ -1427,6 +1427,7 @@ static bool ch34x_set_baudrate(cdch_interface_t* p_cdc, uint32_t baudrate,
14271427
}
14281428

14291429
static void ch34x_set_line_coding_stage1_complete(tuh_xfer_t* xfer) {
1430+
// CH34x only has 1 interface and use wIndex as payload and not for bInterfaceNumber
14301431
uint8_t const itf_num = 0;
14311432
uint8_t const idx = tuh_cdc_itf_get_index(xfer->daddr, itf_num);
14321433
cdch_interface_t* p_cdc = get_itf(idx);
@@ -1475,7 +1476,7 @@ static bool ch34x_set_line_coding(cdch_interface_t* p_cdc, cdc_line_coding_t con
14751476

14761477
// update transfer result, user_data is expected to point to xfer_result_t
14771478
if (user_data) {
1478-
user_data = result;
1479+
*((xfer_result_t*) user_data) = result;
14791480
}
14801481
}
14811482

@@ -1545,8 +1546,7 @@ static void ch34x_process_config(tuh_xfer_t* xfer) {
15451546
uintptr_t const state = xfer->user_data;
15461547
uint8_t buffer[2]; // TODO remove
15471548
TU_ASSERT (p_cdc,);
1548-
1549-
// TODO check xfer->result
1549+
TU_ASSERT (xfer->result == XFER_RESULT_SUCCESS,);
15501550

15511551
switch (state) {
15521552
case CONFIG_CH34X_READ_VERSION:
@@ -1563,9 +1563,9 @@ static void ch34x_process_config(tuh_xfer_t* xfer) {
15631563
// init CH34x with line coding
15641564
cdc_line_coding_t const line_coding = CFG_TUH_CDC_LINE_CODING_ON_ENUM_CH34X;
15651565
uint16_t const div_ps = ch34x_get_divisor_prescaler(line_coding.bit_rate);
1566-
TU_ASSERT(div_ps != 0, );
1566+
TU_ASSERT(div_ps, );
15671567
uint8_t const lcr = ch34x_get_lcr(line_coding.stop_bits, line_coding.parity, line_coding.data_bits);
1568-
TU_ASSERT(lcr != 0, );
1568+
TU_ASSERT(lcr, );
15691569
TU_ASSERT (ch34x_control_out(p_cdc, CH34X_REQ_SERIAL_INIT, tu_u16(lcr, 0x9c), div_ps,
15701570
ch34x_process_config, CONFIG_CH34X_SPECIAL_REG_WRITE),);
15711571
break;
@@ -1605,7 +1605,7 @@ static uint16_t ch34x_get_divisor_prescaler(uint32_t baval) {
16051605
uint8_t b;
16061606
uint32_t c;
16071607

1608-
TU_VERIFY(baval != 0, 0);
1608+
TU_VERIFY(baval != 0 && baval <= 2000000, 0);
16091609
switch (baval) {
16101610
case 921600:
16111611
a = 0xf3;
@@ -1659,7 +1659,7 @@ static uint8_t ch34x_get_lcr(uint8_t stop_bits, uint8_t parity, uint8_t data_bit
16591659
break;
16601660

16611661
case CDC_LINE_CODING_PARITY_ODD:
1662-
lcr |= CH34X_LCR_ENABLE_PAR;
1662+
lcr |= CH34X_LCR_ENABLE_PAR;
16631663
break;
16641664

16651665
case CDC_LINE_CODING_PARITY_EVEN:

0 commit comments

Comments
 (0)