Skip to content

Commit a0b2471

Browse files
committed
fix(usb): proper reset timing
USB reset should take ~10 ms
1 parent e6bbca5 commit a0b2471

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/peripherals/usb.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ export class RPUSBController extends BasePeripheral {
113113

114114
private readonly endpointReadAlarms: USBEndpointAlarm[];
115115
private readonly endpointWriteAlarms: USBEndpointAlarm[];
116+
private readonly resetAlarm;
116117

117118
onUSBEnabled?: () => void;
118119
onResetReceived?: () => void;
@@ -153,6 +154,10 @@ export class RPUSBController extends BasePeripheral {
153154
),
154155
);
155156
}
157+
this.resetAlarm = clock.createAlarm(() => {
158+
this.sieStatus |= SIE_BUS_RESET;
159+
this.sieStatusUpdated();
160+
});
156161
}
157162

158163
readUint32(offset: number) {
@@ -313,8 +318,7 @@ export class RPUSBController extends BasePeripheral {
313318
}
314319

315320
resetDevice() {
316-
this.sieStatus |= SIE_BUS_RESET;
317-
this.sieStatusUpdated();
321+
this.resetAlarm.schedule(10_000_000); // USB reset takes ~10ms
318322
}
319323

320324
sendSetupPacket(setupPacket: Uint8Array) {

0 commit comments

Comments
 (0)