stm32/usbd_cdc_interface: Don't retransmit chars if USB is reconnected.
Before this change, if the USB was reconnected it was possible that some characters in the TX buffer were retransmitted because tx_buf_ptr_out and tx_buf_ptr_out_shadow were reset while tx_buf_ptr_in wasn't. That behaviour is fixed here by retaining the TX buffer state across reconnects. Fixes issue #4761.
This commit is contained in:
parent
97753a1bbc
commit
b8c74014e4
@ -69,7 +69,7 @@ typedef struct _usb_device_t {
|
||||
usbd_hid_itf_t usbd_hid_itf;
|
||||
} usb_device_t;
|
||||
|
||||
usb_device_t usb_device;
|
||||
usb_device_t usb_device = {0};
|
||||
pyb_usb_storage_medium_t pyb_usb_storage_medium = PYB_USB_STORAGE_MEDIUM_NONE;
|
||||
|
||||
// predefined hid mouse data
|
||||
|
@ -64,14 +64,14 @@ static uint8_t usbd_cdc_connect_tx_timer;
|
||||
uint8_t *usbd_cdc_init(usbd_cdc_state_t *cdc_in) {
|
||||
usbd_cdc_itf_t *cdc = (usbd_cdc_itf_t*)cdc_in;
|
||||
|
||||
// Reset all the CDC state
|
||||
// Note: we don't reset tx_buf_ptr_in in order to allow the output buffer to
|
||||
// be filled (by usbd_cdc_tx_always) before the USB device is connected.
|
||||
// Reset the CDC state due to a new USB host connection
|
||||
// Note: we don't reset tx_buf_ptr_* in order to allow the output buffer to
|
||||
// be filled (by usbd_cdc_tx_always) before the USB device is connected, and
|
||||
// to retain transmit buffer state across multiple USB connections (they will
|
||||
// be 0 at MCU reset since the variables live in the BSS).
|
||||
cdc->rx_buf_put = 0;
|
||||
cdc->rx_buf_get = 0;
|
||||
cdc->rx_buf_full = false;
|
||||
cdc->tx_buf_ptr_out = 0;
|
||||
cdc->tx_buf_ptr_out_shadow = 0;
|
||||
cdc->tx_need_empty_packet = 0;
|
||||
cdc->connect_state = USBD_CDC_CONNECT_STATE_DISCONNECTED;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user