Skip to content

Commit 0ebd518

Browse files
committed
Re-enable endpoint after reading GRXSTSP
1 parent 8cbeb70 commit 0ebd518

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/bus.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,12 +689,17 @@ impl<USB: UsbPeripheral> usb_device::bus::UsbBus for UsbBus<USB> {
689689
}
690690
0x03 | 0x04 => {
691691
// OUT completed | SETUP completed
692+
693+
// It's important to read this register before re-enabling the relevant
694+
// endpoint on GD32VF103, otherwise DOEPCTL.EPENA resets back to 0 after
695+
// reading GRXSTSP.
696+
read_reg!(otg_global, regs.global(), GRXSTSP); // pop GRXSTSP
697+
692698
// Re-enable the endpoint, F429-like chips only
693699
if core_id == 0x0000_1200 || core_id == 0x0000_1100 {
694700
let ep = regs.endpoint_out(epnum as usize);
695701
modify_reg!(endpoint_out, ep, DOEPCTL, CNAK: 1, EPENA: 1);
696702
}
697-
read_reg!(otg_global, regs.global(), GRXSTSP); // pop GRXSTSP
698703
}
699704
_ => {
700705
read_reg!(otg_global, regs.global(), GRXSTSP); // pop GRXSTSP

0 commit comments

Comments
 (0)