rp2040js 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -9,6 +9,7 @@ export declare class RPUSBController extends BasePeripheral {
|
|
|
9
9
|
private buffStatus;
|
|
10
10
|
private readonly endpointReadAlarms;
|
|
11
11
|
private readonly endpointWriteAlarms;
|
|
12
|
+
private readonly resetAlarm;
|
|
12
13
|
onUSBEnabled?: () => void;
|
|
13
14
|
onResetReceived?: () => void;
|
|
14
15
|
onEndpointWrite?: (endpoint: number, buffer: Uint8Array) => void;
|
|
@@ -103,7 +103,7 @@ class RPUSBController extends peripheral_js_1.BasePeripheral {
|
|
|
103
103
|
this.intForce = 0;
|
|
104
104
|
this.sieStatus = 0;
|
|
105
105
|
this.buffStatus = 0;
|
|
106
|
-
this.readDelayMicroseconds =
|
|
106
|
+
this.readDelayMicroseconds = 10;
|
|
107
107
|
this.writeDelayMicroseconds = 10; // Determined empirically
|
|
108
108
|
const clock = rp2040.clock;
|
|
109
109
|
this.endpointReadAlarms = [];
|
|
@@ -123,6 +123,10 @@ class RPUSBController extends peripheral_js_1.BasePeripheral {
|
|
|
123
123
|
this.endpointWriteAlarms[i].buffers = [];
|
|
124
124
|
})));
|
|
125
125
|
}
|
|
126
|
+
this.resetAlarm = clock.createAlarm(() => {
|
|
127
|
+
this.sieStatus |= SIE_BUS_RESET;
|
|
128
|
+
this.sieStatusUpdated();
|
|
129
|
+
});
|
|
126
130
|
}
|
|
127
131
|
readUint32(offset) {
|
|
128
132
|
switch (offset) {
|
|
@@ -265,8 +269,7 @@ class RPUSBController extends peripheral_js_1.BasePeripheral {
|
|
|
265
269
|
this.rp2040.setInterrupt(irq_js_1.IRQ.USBCTRL, !!intStatus);
|
|
266
270
|
}
|
|
267
271
|
resetDevice() {
|
|
268
|
-
this.
|
|
269
|
-
this.sieStatusUpdated();
|
|
272
|
+
this.resetAlarm.schedule(10000000); // USB reset takes ~10ms
|
|
270
273
|
}
|
|
271
274
|
sendSetupPacket(setupPacket) {
|
|
272
275
|
this.rp2040.usbDPRAM.set(setupPacket);
|
|
@@ -9,6 +9,7 @@ export declare class RPUSBController extends BasePeripheral {
|
|
|
9
9
|
private buffStatus;
|
|
10
10
|
private readonly endpointReadAlarms;
|
|
11
11
|
private readonly endpointWriteAlarms;
|
|
12
|
+
private readonly resetAlarm;
|
|
12
13
|
onUSBEnabled?: () => void;
|
|
13
14
|
onResetReceived?: () => void;
|
|
14
15
|
onEndpointWrite?: (endpoint: number, buffer: Uint8Array) => void;
|
|
@@ -100,7 +100,7 @@ export class RPUSBController extends BasePeripheral {
|
|
|
100
100
|
this.intForce = 0;
|
|
101
101
|
this.sieStatus = 0;
|
|
102
102
|
this.buffStatus = 0;
|
|
103
|
-
this.readDelayMicroseconds =
|
|
103
|
+
this.readDelayMicroseconds = 10;
|
|
104
104
|
this.writeDelayMicroseconds = 10; // Determined empirically
|
|
105
105
|
const clock = rp2040.clock;
|
|
106
106
|
this.endpointReadAlarms = [];
|
|
@@ -120,6 +120,10 @@ export class RPUSBController extends BasePeripheral {
|
|
|
120
120
|
this.endpointWriteAlarms[i].buffers = [];
|
|
121
121
|
})));
|
|
122
122
|
}
|
|
123
|
+
this.resetAlarm = clock.createAlarm(() => {
|
|
124
|
+
this.sieStatus |= SIE_BUS_RESET;
|
|
125
|
+
this.sieStatusUpdated();
|
|
126
|
+
});
|
|
123
127
|
}
|
|
124
128
|
readUint32(offset) {
|
|
125
129
|
switch (offset) {
|
|
@@ -262,8 +266,7 @@ export class RPUSBController extends BasePeripheral {
|
|
|
262
266
|
this.rp2040.setInterrupt(IRQ.USBCTRL, !!intStatus);
|
|
263
267
|
}
|
|
264
268
|
resetDevice() {
|
|
265
|
-
this.
|
|
266
|
-
this.sieStatusUpdated();
|
|
269
|
+
this.resetAlarm.schedule(10000000); // USB reset takes ~10ms
|
|
267
270
|
}
|
|
268
271
|
sendSetupPacket(setupPacket) {
|
|
269
272
|
this.rp2040.usbDPRAM.set(setupPacket);
|