Skip to content

Commit fd43355

Browse files
authored
feat: Apply suggestions from code review
1 parent 4ba9517 commit fd43355

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

cores/esp32/HWCDC.cpp

+9-5
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,6 @@ bool HWCDC::isCDC_Connected()
166166
usb_serial_jtag_ll_ena_intr_mask(USB_SERIAL_JTAG_INTR_SERIAL_IN_EMPTY);
167167
}
168168
// this will feed CDC TX FIFO to trigger IN_EMPTY
169-
//uint8_t c = '\0';
170-
//usb_serial_jtag_ll_write_txfifo(&c, sizeof(c));
171169
usb_serial_jtag_ll_txfifo_flush();
172170
running = true;
173171
return false;
@@ -460,15 +458,21 @@ void HWCDC::flush(void)
460458
if(uxItemsWaiting){
461459
// Now trigger the ISR to read data from the ring buffer.
462460
usb_serial_jtag_ll_txfifo_flush();
463-
if(connected) usb_serial_jtag_ll_ena_intr_mask(USB_SERIAL_JTAG_INTR_SERIAL_IN_EMPTY);
461+
if(connected) {
462+
usb_serial_jtag_ll_ena_intr_mask(USB_SERIAL_JTAG_INTR_SERIAL_IN_EMPTY);
463+
}
464464
}
465465
uint32_t tries = tx_timeout_ms; // waits 1ms per ISR sending data attempt, in case CDC is unplugged
466466
while(connected && tries && uxItemsWaiting){
467467
delay(1);
468468
UBaseType_t lastUxItemsWaiting = uxItemsWaiting;
469469
vRingbufferGetInfo(tx_ring_buf, NULL, NULL, NULL, NULL, &uxItemsWaiting);
470-
if (lastUxItemsWaiting == uxItemsWaiting) tries--;
471-
if(connected) usb_serial_jtag_ll_ena_intr_mask(USB_SERIAL_JTAG_INTR_SERIAL_IN_EMPTY);
470+
if (lastUxItemsWaiting == uxItemsWaiting) {
471+
tries--;
472+
}
473+
if(connected) {
474+
usb_serial_jtag_ll_ena_intr_mask(USB_SERIAL_JTAG_INTR_SERIAL_IN_EMPTY);
475+
}
472476
}
473477
if (tries == 0) { // CDC isn't connected anymore...
474478
connected = false;

0 commit comments

Comments
 (0)