diff options
author | robert-hh <robert@hammelrath.com> | 2024-07-17 20:43:51 +0200 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2024-07-20 00:27:58 +1000 |
commit | a734ee9057a760b0316eca110d71db1524142fec (patch) | |
tree | 3214ec0671d24836f9514616114ed8c144221d1b /shared/tinyusb/mp_usbd_cdc.c | |
parent | 847ee20d9b18c36e2160aaadfe71d2f7814648b1 (diff) | |
download | micropython-a734ee9057a760b0316eca110d71db1524142fec.tar.gz micropython-a734ee9057a760b0316eca110d71db1524142fec.zip |
shared/tinyusb/mp_usbd_cdc: Skip writing to an uninitialized USB device.
During execution of `boot.py` the USB device is not yet initialized. Any
attempt to write to the CDC (eg calling `print()`) would lock up the
device. This commit skips writing when the USB device is not initialized.
Any output from `boot.py` is lost, but the device does not lock up.
Also removed unnecessary declaration of `tusb_init()`.
Signed-off-by: robert-hh <robert@hammelrath.com>
Diffstat (limited to 'shared/tinyusb/mp_usbd_cdc.c')
-rw-r--r-- | shared/tinyusb/mp_usbd_cdc.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/shared/tinyusb/mp_usbd_cdc.c b/shared/tinyusb/mp_usbd_cdc.c index 63d015cb46..c6a88e467d 100644 --- a/shared/tinyusb/mp_usbd_cdc.c +++ b/shared/tinyusb/mp_usbd_cdc.c @@ -95,6 +95,9 @@ void tud_cdc_rx_cb(uint8_t itf) { } mp_uint_t mp_usbd_cdc_tx_strn(const char *str, mp_uint_t len) { + if (!tusb_inited()) { + return 0; + } size_t i = 0; while (i < len) { uint32_t n = len - i; |