kopia lustrzana https://github.com/micropython/micropython
shared/tinyusb: Don't disconnect on soft reset unless USB was active.
Previously, constructing the singleton USBDevice object was enough to trigger a USB disconnect on soft reset. Now it also has to be active. The only case where this changes the behaviour is if the USBDevice object has been constructed but never set to active (no more disconnect in this case). Otherwise, behaviour is the same. This change was requested by hippy on the raspberrypi forums. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>pull/14194/head
rodzic
79edaddf50
commit
935f5391b5
|
@ -431,11 +431,12 @@ void mp_usbd_init(void) {
|
||||||
// Top-level USB device deinit.
|
// Top-level USB device deinit.
|
||||||
//
|
//
|
||||||
// This variant is called from soft reset, NULLs out the USB device
|
// This variant is called from soft reset, NULLs out the USB device
|
||||||
// singleton instance from MP_STATE_VM, and disconnects the port.
|
// singleton instance from MP_STATE_VM, and disconnects the port if a
|
||||||
|
// runtime device was active.
|
||||||
void mp_usbd_deinit(void) {
|
void mp_usbd_deinit(void) {
|
||||||
mp_obj_usb_device_t *usbd = MP_OBJ_TO_PTR(MP_STATE_VM(usbd));
|
mp_obj_usb_device_t *usbd = MP_OBJ_TO_PTR(MP_STATE_VM(usbd));
|
||||||
MP_STATE_VM(usbd) = MP_OBJ_NULL;
|
MP_STATE_VM(usbd) = MP_OBJ_NULL;
|
||||||
if (usbd) {
|
if (usbd && usbd->active) {
|
||||||
// Disconnect if a runtime USB device was active
|
// Disconnect if a runtime USB device was active
|
||||||
mp_usbd_disconnect(usbd);
|
mp_usbd_disconnect(usbd);
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue