circuitpython/ports
Damien George 7be1f77902 stm32/usbd_cdc_interface: Don't wait in usbd_cdc_tx_always if suspended.
MCUs with device-only USB peripherals (eg L0, WB) do not implement (at
least not in the ST HAL) the HAL_PCD_DisconnectCallback event.  So if a USB
cable is disconnected the USB driver does not deinitialise itself
(usbd_cdc_deinit is not called) and the CDC driver can stay in the
USBD_CDC_CONNECT_STATE_CONNECTED state.  Then if the USB was attached to
the REPL, output can become very slow waiting in usbd_cdc_tx_always for
500ms for each character.

The disconnect event is not implemented on these MCUs but the suspend event
is.  And in the situation where the USB cable is disconnected the suspend
event is raised because SOF packets are no longer received.

The issue of very slow output on these MCUs is fixed in this commit (really
worked around) by adding a check in usbd_cdc_tx_always to see if the USB
device state is suspended, and, if so, breaking out of the 500ms wait loop.
This should also help all MCUs for a real USB suspend.

A proper fix for MCUs with device-only USB would be to implement or somehow
synthesise the HAL_PCD_DisconnectCallback event.

See issue #6672.

Signed-off-by: Damien George <damien@micropython.org>
2021-02-02 12:09:33 +11:00
..
bare-arm ports: Disable MICROPY_PY_ASSIGN_EXPR in bare-arm and minimal ports. 2020-06-16 22:06:21 +10:00
cc3200 cc3200: Fix debug build. 2021-01-23 17:44:27 +11:00
esp32 esp32/modnetwork: Synchronize WiFi AUTH_xxx constants with IDF values. 2021-01-23 16:49:16 +11:00
esp8266 esp8266/modules/neopixel.py: Add timing param to NeoPixel constructor. 2021-01-30 14:35:54 +11:00
javascript all: Format code to add space after C++-style comment start. 2020-04-23 11:24:25 +10:00
mimxrt ports: Use correct in/out endpoint size in TUD_CDC_DESCRIPTOR. 2020-10-17 15:49:16 +11:00
minimal ports: Disable MICROPY_PY_ASSIGN_EXPR in bare-arm and minimal ports. 2020-06-16 22:06:21 +10:00
nrf nrf/README: Add use of "make submodules" in alternative build paragraph. 2021-01-30 14:32:55 +11:00
pic16bit all: Format code to add space after C++-style comment start. 2020-04-23 11:24:25 +10:00
powerpc powerpc/uart: Choose which UART to use at build time, not runtime. 2020-05-29 22:54:55 +10:00
qemu-arm qemu-arm/Makefile: Add CFLAGS_EXTRA to CFLAGS. 2020-06-22 13:42:24 +10:00
rp2 rp2/rp2_pio: Add JMP PIN support for PIO. 2021-02-02 11:32:48 +11:00
samd ports: Use correct in/out endpoint size in TUD_CDC_DESCRIPTOR. 2020-10-17 15:49:16 +11:00
stm32 stm32/usbd_cdc_interface: Don't wait in usbd_cdc_tx_always if suspended. 2021-02-02 12:09:33 +11:00
teensy teensy: Fix build errors and warnings and enable -Werror. 2020-12-18 13:48:57 +11:00
unix py/qstr.h: Remove QSTR_FROM_STR_STATIC macro. 2021-01-30 13:40:48 +11:00
windows unix: Make mp_hal_delay_ms run MICROPY_EVENT_POLL_HOOK. 2020-11-13 17:19:05 +11:00
zephyr zephyr/machine_uart: Fix arg of machine_uart_ioctl to make it uintptr_t. 2021-02-01 22:30:50 +11:00