Skip to content

Commit 7c7c7b1

Browse files
committed
stm32/usbd_cdc_interface: Don't reset CDC output buf on initialisation.
So that characters can be buffered before the USB device is connected (restoring behviour of the driver before recent state refactoring).
1 parent c59fc14 commit 7c7c7b1

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

ports/stm32/usbd_cdc_interface.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,14 @@
5757
#define CDC_SEND_BREAK 0x23
5858

5959
uint8_t *usbd_cdc_init(usbd_cdc_itf_t *cdc, usbd_cdc_msc_hid_state_t *usbd) {
60+
// Link the parent state
6061
cdc->usbd = usbd;
62+
63+
// Reset all the CDC state
64+
// Note: we don't reset tx_buf_ptr_in in order to allow the output buffer to
65+
// be filled (by usbd_cdc_tx_always) before the USB device is connected.
6166
cdc->rx_buf_put = 0;
6267
cdc->rx_buf_get = 0;
63-
cdc->tx_buf_ptr_in = 0;
6468
cdc->tx_buf_ptr_out = 0;
6569
cdc->tx_buf_ptr_out_shadow = 0;
6670
cdc->tx_buf_ptr_wait_count = 0;

0 commit comments

Comments
 (0)