diff --git a/src/bus.rs b/src/bus.rs index eb9c781..c36bad7 100644 --- a/src/bus.rs +++ b/src/bus.rs @@ -111,7 +111,7 @@ impl UsbBus { } } - fn deconfigure_all(&self, cs: CriticalSection<'_>) { + fn deconfigure_all(&self, cs: CriticalSection<'_>, core_id: u32) { let regs = self.regs.borrow(cs); // disable interrupts @@ -125,7 +125,7 @@ impl UsbBus { for ep in &self.allocator.endpoints_out { if let Some(ep) = ep { - ep.deconfigure(cs); + ep.deconfigure(cs, core_id); } } } @@ -605,7 +605,7 @@ impl usb_device::bus::UsbBus for UsbBus { if reset != 0 { write_reg!(otg_global, regs.global(), GINTSTS, USBRST: 1); - self.deconfigure_all(cs); + self.deconfigure_all(cs, core_id); // Flush RX modify_reg!(otg_global, regs.global(), GRSTCTL, RXFFLSH: 1); diff --git a/src/endpoint.rs b/src/endpoint.rs index c6e3be1..d8380fe 100644 --- a/src/endpoint.rs +++ b/src/endpoint.rs @@ -189,15 +189,18 @@ impl EndpointOut { } } - pub fn deconfigure(&self, _cs: CriticalSection<'_>) { + pub fn deconfigure(&self, _cs: CriticalSection<'_>, core_id: u32) { let regs = self.usb.endpoint_out(self.index() as usize); - // deactivating endpoint - modify_reg!(endpoint_out, regs, DOEPCTL, USBAEP: 0); + // GD32VF103 doesn't support endpoint deactivation after reset, so skip this. + if core_id > 0x0000_1000 { + // deactivating endpoint + modify_reg!(endpoint_out, regs, DOEPCTL, USBAEP: 0); - // disabling endpoint - if read_reg!(endpoint_out, regs, DOEPCTL, EPENA) != 0 && self.index() != 0 { - modify_reg!(endpoint_out, regs, DOEPCTL, EPDIS: 1) + // disabling endpoint + if read_reg!(endpoint_out, regs, DOEPCTL, EPENA) != 0 && self.index() != 0 { + modify_reg!(endpoint_out, regs, DOEPCTL, EPDIS: 1) + } } // clean EP interrupts