diff options
-rw-r--r-- | ports/stm32/usb.c | 2 | ||||
-rw-r--r-- | ports/stm32/usbd_cdc_interface.c | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/ports/stm32/usb.c b/ports/stm32/usb.c index 18841fdee..8b7608a15 100644 --- a/ports/stm32/usb.c +++ b/ports/stm32/usb.c @@ -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 diff --git a/ports/stm32/usbd_cdc_interface.c b/ports/stm32/usbd_cdc_interface.c index 586f2d525..4a4a8beb8 100644 --- a/ports/stm32/usbd_cdc_interface.c +++ b/ports/stm32/usbd_cdc_interface.c @@ -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; |