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>
This commit is contained in:
@@ -125,7 +125,6 @@ inline static bool mp_usb_device_builtin_enabled(const mp_obj_usb_device_t *usbd
|
||||
|
||||
static inline void mp_usbd_init(void) {
|
||||
// Without runtime USB support, this can be a thin wrapper wrapper around tusb_init()
|
||||
extern bool tusb_init(void);
|
||||
tusb_init();
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user