rp2040js 1.0.1 → 1.0.2
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.
- package/README.md +9 -0
- package/dist/cjs/cortex-m0-core.d.ts +1 -1
- package/dist/cjs/gdb/gdb-tcp-server.d.ts +0 -1
- package/dist/cjs/gdb/gdb-utils.d.ts +2 -2
- package/dist/cjs/gdb/gdb-utils.js +9 -10
- package/dist/cjs/peripherals/peripheral.js +2 -2
- package/dist/cjs/peripherals/pio.d.ts +1 -1
- package/dist/cjs/peripherals/watchdog.d.ts +1 -1
- package/dist/cjs/rp2040.d.ts +8 -8
- package/dist/cjs/usb/cdc.js +2 -2
- package/dist/cjs/usb/setup.d.ts +4 -4
- package/dist/cjs/usb/setup.js +4 -5
- package/dist/cjs/utils/assembler.js +79 -81
- package/dist/cjs/utils/bit.js +3 -4
- package/dist/cjs/utils/pio-assembler.js +10 -10
- package/dist/cjs/utils/time.js +2 -3
- package/dist/cjs/utils/timer32.js +1 -1
- package/dist/esm/cortex-m0-core.d.ts +1 -1
- package/dist/esm/gdb/gdb-tcp-server.d.ts +0 -1
- package/dist/esm/gdb/gdb-utils.d.ts +2 -2
- package/dist/esm/peripherals/pio.d.ts +1 -1
- package/dist/esm/peripherals/watchdog.d.ts +1 -1
- package/dist/esm/rp2040.d.ts +8 -8
- package/dist/esm/usb/setup.d.ts +4 -4
- package/dist/esm/utils/timer32.js +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -28,6 +28,15 @@ npm install
|
|
|
28
28
|
npm start
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
+
You can also specify the path to the image on the command line and/or load an UF2 image:
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
npm run start -- --image ./my-pico-project.uf2
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
A GDB server will be available on port 3333, and the data written to UART0 will be printed
|
|
38
|
+
to the console.
|
|
39
|
+
|
|
31
40
|
### MicroPython code
|
|
32
41
|
|
|
33
42
|
To run the MicroPython demo, first download [RPI_PICO-20230426-v1.20.0.uf2](https://micropython.org/resources/firmware/RPI_PICO-20230426-v1.20.0.uf2), place it in the rp2040js root directory, then run:
|
|
@@ -2,8 +2,8 @@ export declare function encodeHexByte(value: number): string;
|
|
|
2
2
|
export declare function encodeHexBuf(buf: Uint8Array): string;
|
|
3
3
|
export declare function encodeHexUint32BE(value: number): string;
|
|
4
4
|
export declare function encodeHexUint32(value: number): string;
|
|
5
|
-
export declare function decodeHexBuf(encoded: string): Uint8Array
|
|
6
|
-
export declare function decodeHexUint32Array(encoded: string): Uint32Array
|
|
5
|
+
export declare function decodeHexBuf(encoded: string): Uint8Array<ArrayBuffer>;
|
|
6
|
+
export declare function decodeHexUint32Array(encoded: string): Uint32Array<ArrayBuffer>;
|
|
7
7
|
export declare function decodeHexUint32(encoded: string): number;
|
|
8
8
|
export declare function gdbChecksum(text: string): string;
|
|
9
9
|
export declare function gdbMessage(value: string): string;
|
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.encodeHexByte = encodeHexByte;
|
|
4
|
+
exports.encodeHexBuf = encodeHexBuf;
|
|
5
|
+
exports.encodeHexUint32BE = encodeHexUint32BE;
|
|
6
|
+
exports.encodeHexUint32 = encodeHexUint32;
|
|
7
|
+
exports.decodeHexBuf = decodeHexBuf;
|
|
8
|
+
exports.decodeHexUint32Array = decodeHexUint32Array;
|
|
9
|
+
exports.decodeHexUint32 = decodeHexUint32;
|
|
10
|
+
exports.gdbChecksum = gdbChecksum;
|
|
11
|
+
exports.gdbMessage = gdbMessage;
|
|
4
12
|
function encodeHexByte(value) {
|
|
5
13
|
return (value >> 4).toString(16) + (value & 0xf).toString(16);
|
|
6
14
|
}
|
|
7
|
-
exports.encodeHexByte = encodeHexByte;
|
|
8
15
|
function encodeHexBuf(buf) {
|
|
9
16
|
return Array.from(buf).map(encodeHexByte).join('');
|
|
10
17
|
}
|
|
11
|
-
exports.encodeHexBuf = encodeHexBuf;
|
|
12
18
|
function encodeHexUint32BE(value) {
|
|
13
19
|
return encodeHexBuf(new Uint8Array([(value >> 24) & 0xff, (value >> 16) & 0xff, (value >> 8) & 0xff, value & 0xff]));
|
|
14
20
|
}
|
|
15
|
-
exports.encodeHexUint32BE = encodeHexUint32BE;
|
|
16
21
|
function encodeHexUint32(value) {
|
|
17
22
|
const buf = new Uint32Array([value]);
|
|
18
23
|
return encodeHexBuf(new Uint8Array(buf.buffer));
|
|
19
24
|
}
|
|
20
|
-
exports.encodeHexUint32 = encodeHexUint32;
|
|
21
25
|
function decodeHexBuf(encoded) {
|
|
22
26
|
const result = new Uint8Array(encoded.length / 2);
|
|
23
27
|
for (let i = 0; i < result.length; i++) {
|
|
@@ -25,15 +29,12 @@ function decodeHexBuf(encoded) {
|
|
|
25
29
|
}
|
|
26
30
|
return result;
|
|
27
31
|
}
|
|
28
|
-
exports.decodeHexBuf = decodeHexBuf;
|
|
29
32
|
function decodeHexUint32Array(encoded) {
|
|
30
33
|
return new Uint32Array(decodeHexBuf(encoded).buffer);
|
|
31
34
|
}
|
|
32
|
-
exports.decodeHexUint32Array = decodeHexUint32Array;
|
|
33
35
|
function decodeHexUint32(encoded) {
|
|
34
36
|
return decodeHexUint32Array(encoded)[0];
|
|
35
37
|
}
|
|
36
|
-
exports.decodeHexUint32 = decodeHexUint32;
|
|
37
38
|
function gdbChecksum(text) {
|
|
38
39
|
const value = text
|
|
39
40
|
.split('')
|
|
@@ -41,8 +42,6 @@ function gdbChecksum(text) {
|
|
|
41
42
|
.reduce((a, b) => a + b, 0) & 0xff;
|
|
42
43
|
return encodeHexByte(value);
|
|
43
44
|
}
|
|
44
|
-
exports.gdbChecksum = gdbChecksum;
|
|
45
45
|
function gdbMessage(value) {
|
|
46
46
|
return `$${value}#${gdbChecksum(value)}`;
|
|
47
47
|
}
|
|
48
|
-
exports.gdbMessage = gdbMessage;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UnimplementedPeripheral = exports.BasePeripheral =
|
|
3
|
+
exports.UnimplementedPeripheral = exports.BasePeripheral = void 0;
|
|
4
|
+
exports.atomicUpdate = atomicUpdate;
|
|
4
5
|
const ATOMIC_NORMAL = 0;
|
|
5
6
|
const ATOMIC_XOR = 1;
|
|
6
7
|
const ATOMIC_SET = 2;
|
|
@@ -18,7 +19,6 @@ function atomicUpdate(currentValue, atomicType, newValue) {
|
|
|
18
19
|
return newValue;
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
|
-
exports.atomicUpdate = atomicUpdate;
|
|
22
22
|
class BasePeripheral {
|
|
23
23
|
constructor(rp2040, name) {
|
|
24
24
|
this.rp2040 = rp2040;
|
|
@@ -86,7 +86,7 @@ export declare class StateMachine {
|
|
|
86
86
|
export declare class RPPIO extends BasePeripheral implements Peripheral {
|
|
87
87
|
readonly firstIrq: number;
|
|
88
88
|
readonly index: number;
|
|
89
|
-
readonly instructions: Uint32Array
|
|
89
|
+
readonly instructions: Uint32Array<ArrayBuffer>;
|
|
90
90
|
readonly dreqRx: DREQChannel[];
|
|
91
91
|
readonly dreqTx: DREQChannel[];
|
|
92
92
|
readonly machines: StateMachine[];
|
|
@@ -4,7 +4,7 @@ import { BasePeripheral, Peripheral } from './peripheral.js';
|
|
|
4
4
|
export declare class RPWatchdog extends BasePeripheral implements Peripheral {
|
|
5
5
|
readonly timer: Timer32;
|
|
6
6
|
readonly alarm: Timer32PeriodicAlarm;
|
|
7
|
-
readonly scratchData: Uint32Array
|
|
7
|
+
readonly scratchData: Uint32Array<ArrayBuffer>;
|
|
8
8
|
private enable;
|
|
9
9
|
private tickEnable;
|
|
10
10
|
private reason;
|
package/dist/cjs/rp2040.d.ts
CHANGED
|
@@ -21,14 +21,14 @@ export declare const DPRAM_START_ADDRESS = 1343225856;
|
|
|
21
21
|
export declare const SIO_START_ADDRESS = 3489660928;
|
|
22
22
|
export declare class RP2040 {
|
|
23
23
|
readonly clock: IClock;
|
|
24
|
-
readonly bootrom: Uint32Array
|
|
25
|
-
readonly sram: Uint8Array
|
|
26
|
-
readonly sramView: DataView
|
|
27
|
-
readonly flash: Uint8Array
|
|
28
|
-
readonly flash16: Uint16Array
|
|
29
|
-
readonly flashView: DataView
|
|
30
|
-
readonly usbDPRAM: Uint8Array
|
|
31
|
-
readonly usbDPRAMView: DataView
|
|
24
|
+
readonly bootrom: Uint32Array<ArrayBuffer>;
|
|
25
|
+
readonly sram: Uint8Array<ArrayBuffer>;
|
|
26
|
+
readonly sramView: DataView<ArrayBuffer>;
|
|
27
|
+
readonly flash: Uint8Array<ArrayBuffer>;
|
|
28
|
+
readonly flash16: Uint16Array<ArrayBuffer>;
|
|
29
|
+
readonly flashView: DataView<ArrayBuffer>;
|
|
30
|
+
readonly usbDPRAM: Uint8Array<ArrayBuffer>;
|
|
31
|
+
readonly usbDPRAMView: DataView<ArrayBuffer>;
|
|
32
32
|
readonly core: CortexM0Core;
|
|
33
33
|
clkSys: number;
|
|
34
34
|
clkPeri: number;
|
package/dist/cjs/usb/cdc.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.USBCDC =
|
|
3
|
+
exports.USBCDC = void 0;
|
|
4
|
+
exports.extractEndpointNumbers = extractEndpointNumbers;
|
|
4
5
|
const fifo_js_1 = require("../utils/fifo.js");
|
|
5
6
|
const interfaces_js_1 = require("./interfaces.js");
|
|
6
7
|
const setup_js_1 = require("./setup.js");
|
|
@@ -47,7 +48,6 @@ function extractEndpointNumbers(descriptors) {
|
|
|
47
48
|
}
|
|
48
49
|
return result;
|
|
49
50
|
}
|
|
50
|
-
exports.extractEndpointNumbers = extractEndpointNumbers;
|
|
51
51
|
class USBCDC {
|
|
52
52
|
constructor(usb) {
|
|
53
53
|
this.usb = usb;
|
package/dist/cjs/usb/setup.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DescriptorType, ISetupPacketParams } from './interfaces.js';
|
|
2
|
-
export declare function createSetupPacket(params: ISetupPacketParams): Uint8Array
|
|
3
|
-
export declare function setDeviceAddressPacket(address: number): Uint8Array
|
|
4
|
-
export declare function getDescriptorPacket(type: DescriptorType, length: number, index?: number): Uint8Array
|
|
5
|
-
export declare function setDeviceConfigurationPacket(configurationNumber: number): Uint8Array
|
|
2
|
+
export declare function createSetupPacket(params: ISetupPacketParams): Uint8Array<ArrayBuffer>;
|
|
3
|
+
export declare function setDeviceAddressPacket(address: number): Uint8Array<ArrayBuffer>;
|
|
4
|
+
export declare function getDescriptorPacket(type: DescriptorType, length: number, index?: number): Uint8Array<ArrayBuffer>;
|
|
5
|
+
export declare function setDeviceConfigurationPacket(configurationNumber: number): Uint8Array<ArrayBuffer>;
|
package/dist/cjs/usb/setup.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createSetupPacket = createSetupPacket;
|
|
4
|
+
exports.setDeviceAddressPacket = setDeviceAddressPacket;
|
|
5
|
+
exports.getDescriptorPacket = getDescriptorPacket;
|
|
6
|
+
exports.setDeviceConfigurationPacket = setDeviceConfigurationPacket;
|
|
4
7
|
const interfaces_js_1 = require("./interfaces.js");
|
|
5
8
|
function createSetupPacket(params) {
|
|
6
9
|
const setupPacket = new Uint8Array(8);
|
|
@@ -14,7 +17,6 @@ function createSetupPacket(params) {
|
|
|
14
17
|
setupPacket[7] = (params.wLength >> 8) & 0xff;
|
|
15
18
|
return setupPacket;
|
|
16
19
|
}
|
|
17
|
-
exports.createSetupPacket = createSetupPacket;
|
|
18
20
|
function setDeviceAddressPacket(address) {
|
|
19
21
|
return createSetupPacket({
|
|
20
22
|
dataDirection: interfaces_js_1.DataDirection.HostToDevice,
|
|
@@ -26,7 +28,6 @@ function setDeviceAddressPacket(address) {
|
|
|
26
28
|
wLength: 0,
|
|
27
29
|
});
|
|
28
30
|
}
|
|
29
|
-
exports.setDeviceAddressPacket = setDeviceAddressPacket;
|
|
30
31
|
function getDescriptorPacket(type, length, index = 0) {
|
|
31
32
|
return createSetupPacket({
|
|
32
33
|
dataDirection: interfaces_js_1.DataDirection.DeviceToHost,
|
|
@@ -38,7 +39,6 @@ function getDescriptorPacket(type, length, index = 0) {
|
|
|
38
39
|
wLength: length,
|
|
39
40
|
});
|
|
40
41
|
}
|
|
41
|
-
exports.getDescriptorPacket = getDescriptorPacket;
|
|
42
42
|
function setDeviceConfigurationPacket(configurationNumber) {
|
|
43
43
|
return createSetupPacket({
|
|
44
44
|
dataDirection: interfaces_js_1.DataDirection.HostToDevice,
|
|
@@ -50,4 +50,3 @@ function setDeviceConfigurationPacket(configurationNumber) {
|
|
|
50
50
|
wLength: 0,
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
|
-
exports.setDeviceConfigurationPacket = setDeviceConfigurationPacket;
|
|
@@ -1,63 +1,126 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
3
|
+
exports.opcodeADCS = opcodeADCS;
|
|
4
|
+
exports.opcodeADDS1 = opcodeADDS1;
|
|
5
|
+
exports.opcodeADDS2 = opcodeADDS2;
|
|
6
|
+
exports.opcodeADDspPlusImm = opcodeADDspPlusImm;
|
|
7
|
+
exports.opcodeADDsp2 = opcodeADDsp2;
|
|
8
|
+
exports.opcodeADDSreg = opcodeADDSreg;
|
|
9
|
+
exports.opcodeADDreg = opcodeADDreg;
|
|
10
|
+
exports.opcodeADR = opcodeADR;
|
|
11
|
+
exports.opcodeANDS = opcodeANDS;
|
|
12
|
+
exports.opcodeASRS = opcodeASRS;
|
|
13
|
+
exports.opcodeASRSreg = opcodeASRSreg;
|
|
14
|
+
exports.opcodeBT1 = opcodeBT1;
|
|
15
|
+
exports.opcodeBT2 = opcodeBT2;
|
|
16
|
+
exports.opcodeBICS = opcodeBICS;
|
|
17
|
+
exports.opcodeBL = opcodeBL;
|
|
18
|
+
exports.opcodeBLX = opcodeBLX;
|
|
19
|
+
exports.opcodeBX = opcodeBX;
|
|
20
|
+
exports.opcodeCMN = opcodeCMN;
|
|
21
|
+
exports.opcodeCMPimm = opcodeCMPimm;
|
|
22
|
+
exports.opcodeCMPregT1 = opcodeCMPregT1;
|
|
23
|
+
exports.opcodeCMPregT2 = opcodeCMPregT2;
|
|
24
|
+
exports.opcodeDMBSY = opcodeDMBSY;
|
|
25
|
+
exports.opcodeDSBSY = opcodeDSBSY;
|
|
26
|
+
exports.opcodeEORS = opcodeEORS;
|
|
27
|
+
exports.opcodeISBSY = opcodeISBSY;
|
|
28
|
+
exports.opcodeLDMIA = opcodeLDMIA;
|
|
29
|
+
exports.opcodeLDRreg = opcodeLDRreg;
|
|
30
|
+
exports.opcodeLDRimm = opcodeLDRimm;
|
|
31
|
+
exports.opcodeLDRlit = opcodeLDRlit;
|
|
32
|
+
exports.opcodeLDRB = opcodeLDRB;
|
|
33
|
+
exports.opcodeLDRsp = opcodeLDRsp;
|
|
34
|
+
exports.opcodeLDRBreg = opcodeLDRBreg;
|
|
35
|
+
exports.opcodeLDRH = opcodeLDRH;
|
|
36
|
+
exports.opcodeLDRHreg = opcodeLDRHreg;
|
|
37
|
+
exports.opcodeLDRSB = opcodeLDRSB;
|
|
38
|
+
exports.opcodeLDRSH = opcodeLDRSH;
|
|
39
|
+
exports.opcodeLSLSreg = opcodeLSLSreg;
|
|
40
|
+
exports.opcodeLSLSimm = opcodeLSLSimm;
|
|
41
|
+
exports.opcodeLSRS = opcodeLSRS;
|
|
42
|
+
exports.opcodeLSRSreg = opcodeLSRSreg;
|
|
43
|
+
exports.opcodeMOV = opcodeMOV;
|
|
44
|
+
exports.opcodeMOVS = opcodeMOVS;
|
|
45
|
+
exports.opcodeMOVSreg = opcodeMOVSreg;
|
|
46
|
+
exports.opcodeMRS = opcodeMRS;
|
|
47
|
+
exports.opcodeMSR = opcodeMSR;
|
|
48
|
+
exports.opcodeMULS = opcodeMULS;
|
|
49
|
+
exports.opcodeMVNS = opcodeMVNS;
|
|
50
|
+
exports.opcodeNOP = opcodeNOP;
|
|
51
|
+
exports.opcodeORRS = opcodeORRS;
|
|
52
|
+
exports.opcodePOP = opcodePOP;
|
|
53
|
+
exports.opcodePUSH = opcodePUSH;
|
|
54
|
+
exports.opcodeREV = opcodeREV;
|
|
55
|
+
exports.opcodeREV16 = opcodeREV16;
|
|
56
|
+
exports.opcodeREVSH = opcodeREVSH;
|
|
57
|
+
exports.opcodeROR = opcodeROR;
|
|
58
|
+
exports.opcodeRSBS = opcodeRSBS;
|
|
59
|
+
exports.opcodeSBCS = opcodeSBCS;
|
|
60
|
+
exports.opcodeSTMIA = opcodeSTMIA;
|
|
61
|
+
exports.opcodeSTR = opcodeSTR;
|
|
62
|
+
exports.opcodeSTRsp = opcodeSTRsp;
|
|
63
|
+
exports.opcodeSTRreg = opcodeSTRreg;
|
|
64
|
+
exports.opcodeSTRB = opcodeSTRB;
|
|
65
|
+
exports.opcodeSTRBreg = opcodeSTRBreg;
|
|
66
|
+
exports.opcodeSTRH = opcodeSTRH;
|
|
67
|
+
exports.opcodeSTRHreg = opcodeSTRHreg;
|
|
68
|
+
exports.opcodeSUBS1 = opcodeSUBS1;
|
|
69
|
+
exports.opcodeSUBS2 = opcodeSUBS2;
|
|
70
|
+
exports.opcodeSUBSreg = opcodeSUBSreg;
|
|
71
|
+
exports.opcodeSUBsp = opcodeSUBsp;
|
|
72
|
+
exports.opcodeSVC = opcodeSVC;
|
|
73
|
+
exports.opcodeSXTB = opcodeSXTB;
|
|
74
|
+
exports.opcodeSXTH = opcodeSXTH;
|
|
75
|
+
exports.opcodeTST = opcodeTST;
|
|
76
|
+
exports.opcodeUXTB = opcodeUXTB;
|
|
77
|
+
exports.opcodeUDF = opcodeUDF;
|
|
78
|
+
exports.opcodeUDF2 = opcodeUDF2;
|
|
79
|
+
exports.opcodeUXTH = opcodeUXTH;
|
|
80
|
+
exports.opcodeWFI = opcodeWFI;
|
|
81
|
+
exports.opcodeYIELD = opcodeYIELD;
|
|
5
82
|
function opcodeADCS(Rdn, Rm) {
|
|
6
83
|
return (0b0100000101 << 6) | ((Rm & 7) << 3) | (Rdn & 7);
|
|
7
84
|
}
|
|
8
|
-
exports.opcodeADCS = opcodeADCS;
|
|
9
85
|
function opcodeADDS1(Rd, Rn, imm3) {
|
|
10
86
|
return (0b0001110 << 9) | ((imm3 & 0x7) << 6) | ((Rn & 7) << 3) | (Rd & 7);
|
|
11
87
|
}
|
|
12
|
-
exports.opcodeADDS1 = opcodeADDS1;
|
|
13
88
|
function opcodeADDS2(Rdn, imm8) {
|
|
14
89
|
return (0b00110 << 11) | ((Rdn & 7) << 8) | (imm8 & 0xff);
|
|
15
90
|
}
|
|
16
|
-
exports.opcodeADDS2 = opcodeADDS2;
|
|
17
91
|
function opcodeADDspPlusImm(Rd, imm8) {
|
|
18
92
|
return (0b10101 << 11) | ((Rd & 7) << 8) | ((imm8 >> 2) & 0xff);
|
|
19
93
|
}
|
|
20
|
-
exports.opcodeADDspPlusImm = opcodeADDspPlusImm;
|
|
21
94
|
function opcodeADDsp2(imm) {
|
|
22
95
|
return (0b101100000 << 7) | ((imm >> 2) & 0x7f);
|
|
23
96
|
}
|
|
24
|
-
exports.opcodeADDsp2 = opcodeADDsp2;
|
|
25
97
|
function opcodeADDSreg(Rd, Rn, Rm) {
|
|
26
98
|
return (0b0001100 << 9) | ((Rm & 0x7) << 6) | ((Rn & 7) << 3) | (Rd & 7);
|
|
27
99
|
}
|
|
28
|
-
exports.opcodeADDSreg = opcodeADDSreg;
|
|
29
100
|
function opcodeADDreg(Rdn, Rm) {
|
|
30
101
|
return (0b01000100 << 8) | ((Rdn & 0x8) << 4) | ((Rm & 0xf) << 3) | (Rdn & 0x7);
|
|
31
102
|
}
|
|
32
|
-
exports.opcodeADDreg = opcodeADDreg;
|
|
33
103
|
function opcodeADR(Rd, imm8) {
|
|
34
104
|
return (0b10100 << 11) | ((Rd & 7) << 8) | ((imm8 >> 2) & 0xff);
|
|
35
105
|
}
|
|
36
|
-
exports.opcodeADR = opcodeADR;
|
|
37
106
|
function opcodeANDS(Rn, Rm) {
|
|
38
107
|
return (0b0100000000 << 6) | ((Rm & 7) << 3) | (Rn & 0x7);
|
|
39
108
|
}
|
|
40
|
-
exports.opcodeANDS = opcodeANDS;
|
|
41
109
|
function opcodeASRS(Rd, Rm, imm5) {
|
|
42
110
|
return (0b00010 << 11) | ((imm5 & 0x1f) << 6) | ((Rm & 0x7) << 3) | (Rd & 0x7);
|
|
43
111
|
}
|
|
44
|
-
exports.opcodeASRS = opcodeASRS;
|
|
45
112
|
function opcodeASRSreg(Rdn, Rm) {
|
|
46
113
|
return (0b0100000100 << 6) | ((Rm & 0x7) << 3) | ((Rm & 0x7) << 3) | (Rdn & 0x7);
|
|
47
114
|
}
|
|
48
|
-
exports.opcodeASRSreg = opcodeASRSreg;
|
|
49
115
|
function opcodeBT1(cond, imm8) {
|
|
50
116
|
return (0b1101 << 12) | ((cond & 0xf) << 8) | ((imm8 >> 1) & 0x1ff);
|
|
51
117
|
}
|
|
52
|
-
exports.opcodeBT1 = opcodeBT1;
|
|
53
118
|
function opcodeBT2(imm11) {
|
|
54
119
|
return (0b11100 << 11) | ((imm11 >> 1) & 0x7ff);
|
|
55
120
|
}
|
|
56
|
-
exports.opcodeBT2 = opcodeBT2;
|
|
57
121
|
function opcodeBICS(Rdn, Rm) {
|
|
58
122
|
return (0b0100001110 << 6) | ((Rm & 7) << 3) | (Rdn & 7);
|
|
59
123
|
}
|
|
60
|
-
exports.opcodeBICS = opcodeBICS;
|
|
61
124
|
function opcodeBL(imm) {
|
|
62
125
|
const imm11 = (imm >> 1) & 0x7ff;
|
|
63
126
|
const imm10 = (imm >> 12) & 0x3ff;
|
|
@@ -67,262 +130,197 @@ function opcodeBL(imm) {
|
|
|
67
130
|
const opcode = (0b1101 << 28) | (j1 << 29) | (j2 << 27) | (imm11 << 16) | (0b11110 << 11) | (s << 10) | imm10;
|
|
68
131
|
return opcode >>> 0;
|
|
69
132
|
}
|
|
70
|
-
exports.opcodeBL = opcodeBL;
|
|
71
133
|
function opcodeBLX(Rm) {
|
|
72
134
|
return (0b010001111 << 7) | (Rm << 3);
|
|
73
135
|
}
|
|
74
|
-
exports.opcodeBLX = opcodeBLX;
|
|
75
136
|
function opcodeBX(Rm) {
|
|
76
137
|
return (0b010001110 << 7) | (Rm << 3);
|
|
77
138
|
}
|
|
78
|
-
exports.opcodeBX = opcodeBX;
|
|
79
139
|
function opcodeCMN(Rn, Rm) {
|
|
80
140
|
return (0b0100001011 << 6) | ((Rm & 0x7) << 3) | (Rn & 0x7);
|
|
81
141
|
}
|
|
82
|
-
exports.opcodeCMN = opcodeCMN;
|
|
83
142
|
function opcodeCMPimm(Rn, Imm8) {
|
|
84
143
|
return (0b00101 << 11) | ((Rn & 0x7) << 8) | (Imm8 & 0xff);
|
|
85
144
|
}
|
|
86
|
-
exports.opcodeCMPimm = opcodeCMPimm;
|
|
87
145
|
function opcodeCMPregT1(Rn, Rm) {
|
|
88
146
|
return (0b0100001010 << 6) | ((Rm & 0x7) << 3) | (Rn & 0x7);
|
|
89
147
|
}
|
|
90
|
-
exports.opcodeCMPregT1 = opcodeCMPregT1;
|
|
91
148
|
function opcodeCMPregT2(Rn, Rm) {
|
|
92
149
|
return (0b01000101 << 8) | (((Rn >> 3) & 0x1) << 7) | ((Rm & 0xf) << 3) | (Rn & 0x7);
|
|
93
150
|
}
|
|
94
|
-
exports.opcodeCMPregT2 = opcodeCMPregT2;
|
|
95
151
|
function opcodeDMBSY() {
|
|
96
152
|
return 0x8f50f3bf;
|
|
97
153
|
}
|
|
98
|
-
exports.opcodeDMBSY = opcodeDMBSY;
|
|
99
154
|
function opcodeDSBSY() {
|
|
100
155
|
return 0x8f4ff3bf;
|
|
101
156
|
}
|
|
102
|
-
exports.opcodeDSBSY = opcodeDSBSY;
|
|
103
157
|
function opcodeEORS(Rdn, Rm) {
|
|
104
158
|
return (0b0100000001 << 6) | ((Rm & 0x7) << 3) | (Rdn & 0x7);
|
|
105
159
|
}
|
|
106
|
-
exports.opcodeEORS = opcodeEORS;
|
|
107
160
|
function opcodeISBSY() {
|
|
108
161
|
return 0x8f6ff3bf;
|
|
109
162
|
}
|
|
110
|
-
exports.opcodeISBSY = opcodeISBSY;
|
|
111
163
|
function opcodeLDMIA(Rn, registers) {
|
|
112
164
|
return (0b11001 << 11) | ((Rn & 0x7) << 8) | (registers & 0xff);
|
|
113
165
|
}
|
|
114
|
-
exports.opcodeLDMIA = opcodeLDMIA;
|
|
115
166
|
function opcodeLDRreg(Rt, Rn, Rm) {
|
|
116
167
|
return (0b0101100 << 9) | ((Rm & 0x7) << 6) | ((Rn & 0x7) << 3) | (Rt & 0x7);
|
|
117
168
|
}
|
|
118
|
-
exports.opcodeLDRreg = opcodeLDRreg;
|
|
119
169
|
function opcodeLDRimm(Rt, Rn, imm5) {
|
|
120
170
|
return (0b01101 << 11) | (((imm5 >> 2) & 0x1f) << 6) | ((Rn & 0x7) << 3) | (Rt & 0x7);
|
|
121
171
|
}
|
|
122
|
-
exports.opcodeLDRimm = opcodeLDRimm;
|
|
123
172
|
function opcodeLDRlit(Rt, imm8) {
|
|
124
173
|
return (0b01001 << 11) | ((imm8 >> 2) & 0xff) | ((Rt & 0x7) << 8);
|
|
125
174
|
}
|
|
126
|
-
exports.opcodeLDRlit = opcodeLDRlit;
|
|
127
175
|
function opcodeLDRB(Rt, Rn, imm5) {
|
|
128
176
|
return (0b01111 << 11) | ((imm5 & 0x1f) << 6) | ((Rn & 0x7) << 3) | (Rt & 0x7);
|
|
129
177
|
}
|
|
130
|
-
exports.opcodeLDRB = opcodeLDRB;
|
|
131
178
|
function opcodeLDRsp(Rt, imm8) {
|
|
132
179
|
return (0b10011 << 11) | ((Rt & 7) << 8) | ((imm8 >> 2) & 0xff);
|
|
133
180
|
}
|
|
134
|
-
exports.opcodeLDRsp = opcodeLDRsp;
|
|
135
181
|
function opcodeLDRBreg(Rt, Rn, Rm) {
|
|
136
182
|
return (0b0101110 << 9) | ((Rm & 0x7) << 6) | ((Rn & 0x7) << 3) | (Rt & 0x7);
|
|
137
183
|
}
|
|
138
|
-
exports.opcodeLDRBreg = opcodeLDRBreg;
|
|
139
184
|
function opcodeLDRH(Rt, Rn, imm5) {
|
|
140
185
|
return (0b10001 << 11) | (((imm5 >> 1) & 0xf) << 6) | ((Rn & 0x7) << 3) | (Rt & 0x7);
|
|
141
186
|
}
|
|
142
|
-
exports.opcodeLDRH = opcodeLDRH;
|
|
143
187
|
function opcodeLDRHreg(Rt, Rn, Rm) {
|
|
144
188
|
return (0b0101101 << 9) | ((Rm & 0x7) << 6) | ((Rn & 0x7) << 3) | (Rt & 0x7);
|
|
145
189
|
}
|
|
146
|
-
exports.opcodeLDRHreg = opcodeLDRHreg;
|
|
147
190
|
function opcodeLDRSB(Rt, Rn, Rm) {
|
|
148
191
|
return (0b0101011 << 9) | ((Rm & 0x7) << 6) | ((Rn & 0x7) << 3) | (Rt & 0x7);
|
|
149
192
|
}
|
|
150
|
-
exports.opcodeLDRSB = opcodeLDRSB;
|
|
151
193
|
function opcodeLDRSH(Rt, Rn, Rm) {
|
|
152
194
|
return (0b0101111 << 9) | ((Rm & 0x7) << 6) | ((Rn & 0x7) << 3) | (Rt & 0x7);
|
|
153
195
|
}
|
|
154
|
-
exports.opcodeLDRSH = opcodeLDRSH;
|
|
155
196
|
function opcodeLSLSreg(Rdn, Rm) {
|
|
156
197
|
return (0b0100000010 << 6) | ((Rm & 0x7) << 3) | (Rdn & 0x7);
|
|
157
198
|
}
|
|
158
|
-
exports.opcodeLSLSreg = opcodeLSLSreg;
|
|
159
199
|
function opcodeLSLSimm(Rd, Rm, Imm5) {
|
|
160
200
|
return (0b00000 << 11) | ((Imm5 & 0x1f) << 6) | ((Rm & 0x7) << 3) | (Rd & 0x7);
|
|
161
201
|
}
|
|
162
|
-
exports.opcodeLSLSimm = opcodeLSLSimm;
|
|
163
202
|
function opcodeLSRS(Rd, Rm, imm5) {
|
|
164
203
|
return (0b00001 << 11) | ((imm5 & 0x1f) << 6) | ((Rm & 0x7) << 3) | (Rd & 0x7);
|
|
165
204
|
}
|
|
166
|
-
exports.opcodeLSRS = opcodeLSRS;
|
|
167
205
|
function opcodeLSRSreg(Rdn, Rm) {
|
|
168
206
|
return (0b0100000011 << 6) | ((Rm & 0x7) << 3) | (Rdn & 0x7);
|
|
169
207
|
}
|
|
170
|
-
exports.opcodeLSRSreg = opcodeLSRSreg;
|
|
171
208
|
function opcodeMOV(Rd, Rm) {
|
|
172
209
|
return (0b01000110 << 8) | ((Rd & 0x8 ? 1 : 0) << 7) | (Rm << 3) | (Rd & 0x7);
|
|
173
210
|
}
|
|
174
|
-
exports.opcodeMOV = opcodeMOV;
|
|
175
211
|
function opcodeMOVS(Rd, imm8) {
|
|
176
212
|
return (0b00100 << 11) | ((Rd & 0x7) << 8) | (imm8 & 0xff);
|
|
177
213
|
}
|
|
178
|
-
exports.opcodeMOVS = opcodeMOVS;
|
|
179
214
|
function opcodeMOVSreg(Rd, Rm) {
|
|
180
215
|
return (0b000000000 << 6) | ((Rm & 0x7) << 3) | (Rd & 0x7);
|
|
181
216
|
}
|
|
182
|
-
exports.opcodeMOVSreg = opcodeMOVSreg;
|
|
183
217
|
function opcodeMRS(Rd, specReg) {
|
|
184
218
|
return (((0b1000 << 28) | ((Rd & 0xf) << 24) | ((specReg & 0xff) << 16) | 0b1111001111101111) >>> 0);
|
|
185
219
|
}
|
|
186
|
-
exports.opcodeMRS = opcodeMRS;
|
|
187
220
|
function opcodeMSR(specReg, Rn) {
|
|
188
221
|
return ((0b10001000 << 24) | ((specReg & 0xff) << 16) | (0b111100111000 << 4) | (Rn & 0xf)) >>> 0;
|
|
189
222
|
}
|
|
190
|
-
exports.opcodeMSR = opcodeMSR;
|
|
191
223
|
function opcodeMULS(Rn, Rdm) {
|
|
192
224
|
return (0b0100001101 << 6) | ((Rn & 7) << 3) | (Rdm & 7);
|
|
193
225
|
}
|
|
194
|
-
exports.opcodeMULS = opcodeMULS;
|
|
195
226
|
function opcodeMVNS(Rd, Rm) {
|
|
196
227
|
return (0b0100001111 << 6) | ((Rm & 7) << 3) | (Rd & 7);
|
|
197
228
|
}
|
|
198
|
-
exports.opcodeMVNS = opcodeMVNS;
|
|
199
229
|
function opcodeNOP() {
|
|
200
230
|
return 0b1011111100000000;
|
|
201
231
|
}
|
|
202
|
-
exports.opcodeNOP = opcodeNOP;
|
|
203
232
|
function opcodeORRS(Rn, Rm) {
|
|
204
233
|
return (0b0100001100 << 6) | ((Rm & 0x7) << 3) | (Rn & 0x7);
|
|
205
234
|
}
|
|
206
|
-
exports.opcodeORRS = opcodeORRS;
|
|
207
235
|
function opcodePOP(P, registerList) {
|
|
208
236
|
return (0b1011110 << 9) | ((P ? 1 : 0) << 8) | registerList;
|
|
209
237
|
}
|
|
210
|
-
exports.opcodePOP = opcodePOP;
|
|
211
238
|
function opcodePUSH(M, registerList) {
|
|
212
239
|
return (0b1011010 << 9) | ((M ? 1 : 0) << 8) | registerList;
|
|
213
240
|
}
|
|
214
|
-
exports.opcodePUSH = opcodePUSH;
|
|
215
241
|
function opcodeREV(Rd, Rn) {
|
|
216
242
|
return (0b1011101000 << 6) | ((Rn & 0x7) << 3) | (Rd & 0x7);
|
|
217
243
|
}
|
|
218
|
-
exports.opcodeREV = opcodeREV;
|
|
219
244
|
function opcodeREV16(Rd, Rn) {
|
|
220
245
|
return (0b1011101001 << 6) | ((Rn & 0x7) << 3) | (Rd & 0x7);
|
|
221
246
|
}
|
|
222
|
-
exports.opcodeREV16 = opcodeREV16;
|
|
223
247
|
function opcodeREVSH(Rd, Rn) {
|
|
224
248
|
return (0b1011101011 << 6) | ((Rn & 0x7) << 3) | (Rd & 0x7);
|
|
225
249
|
}
|
|
226
|
-
exports.opcodeREVSH = opcodeREVSH;
|
|
227
250
|
function opcodeROR(Rdn, Rm) {
|
|
228
251
|
return (0b0100000111 << 6) | ((Rm & 0x7) << 3) | (Rdn & 0x7);
|
|
229
252
|
}
|
|
230
|
-
exports.opcodeROR = opcodeROR;
|
|
231
253
|
function opcodeRSBS(Rd, Rn) {
|
|
232
254
|
return (0b0100001001 << 6) | ((Rn & 0x7) << 3) | (Rd & 0x7);
|
|
233
255
|
}
|
|
234
|
-
exports.opcodeRSBS = opcodeRSBS;
|
|
235
256
|
function opcodeSBCS(Rn, Rm) {
|
|
236
257
|
return (0b0100000110 << 6) | ((Rm & 0x7) << 3) | (Rn & 0x7);
|
|
237
258
|
}
|
|
238
|
-
exports.opcodeSBCS = opcodeSBCS;
|
|
239
259
|
function opcodeSTMIA(Rn, registers) {
|
|
240
260
|
return (0b11000 << 11) | ((Rn & 0x7) << 8) | (registers & 0xff);
|
|
241
261
|
}
|
|
242
|
-
exports.opcodeSTMIA = opcodeSTMIA;
|
|
243
262
|
function opcodeSTR(Rt, Rm, imm5) {
|
|
244
263
|
return (0b01100 << 11) | (((imm5 >> 2) & 0x1f) << 6) | ((Rm & 0x7) << 3) | (Rt & 0x7);
|
|
245
264
|
}
|
|
246
|
-
exports.opcodeSTR = opcodeSTR;
|
|
247
265
|
function opcodeSTRsp(Rt, imm8) {
|
|
248
266
|
return (0b10010 << 11) | ((Rt & 7) << 8) | ((imm8 >> 2) & 0xff);
|
|
249
267
|
}
|
|
250
|
-
exports.opcodeSTRsp = opcodeSTRsp;
|
|
251
268
|
function opcodeSTRreg(Rt, Rn, Rm) {
|
|
252
269
|
return (0b0101000 << 9) | ((Rm & 0x7) << 6) | ((Rn & 0x7) << 3) | (Rt & 0x7);
|
|
253
270
|
}
|
|
254
|
-
exports.opcodeSTRreg = opcodeSTRreg;
|
|
255
271
|
function opcodeSTRB(Rt, Rm, imm5) {
|
|
256
272
|
return (0b01110 << 11) | ((imm5 & 0x1f) << 6) | ((Rm & 0x7) << 3) | (Rt & 0x7);
|
|
257
273
|
}
|
|
258
|
-
exports.opcodeSTRB = opcodeSTRB;
|
|
259
274
|
function opcodeSTRBreg(Rt, Rn, Rm) {
|
|
260
275
|
return (0b0101010 << 9) | ((Rm & 0x7) << 6) | ((Rn & 0x7) << 3) | (Rt & 0x7);
|
|
261
276
|
}
|
|
262
|
-
exports.opcodeSTRBreg = opcodeSTRBreg;
|
|
263
277
|
function opcodeSTRH(Rt, Rm, imm5) {
|
|
264
278
|
return (0b10000 << 11) | (((imm5 >> 1) & 0x1f) << 6) | ((Rm & 0x7) << 3) | (Rt & 0x7);
|
|
265
279
|
}
|
|
266
|
-
exports.opcodeSTRH = opcodeSTRH;
|
|
267
280
|
function opcodeSTRHreg(Rt, Rn, Rm) {
|
|
268
281
|
return (0b0101001 << 9) | ((Rm & 0x7) << 6) | ((Rn & 0x7) << 3) | (Rt & 0x7);
|
|
269
282
|
}
|
|
270
|
-
exports.opcodeSTRHreg = opcodeSTRHreg;
|
|
271
283
|
function opcodeSUBS1(Rd, Rn, imm3) {
|
|
272
284
|
return (0b0001111 << 9) | ((imm3 & 0x7) << 6) | ((Rn & 7) << 3) | (Rd & 7);
|
|
273
285
|
}
|
|
274
|
-
exports.opcodeSUBS1 = opcodeSUBS1;
|
|
275
286
|
function opcodeSUBS2(Rdn, imm8) {
|
|
276
287
|
return (0b00111 << 11) | ((Rdn & 7) << 8) | (imm8 & 0xff);
|
|
277
288
|
}
|
|
278
|
-
exports.opcodeSUBS2 = opcodeSUBS2;
|
|
279
289
|
function opcodeSUBSreg(Rd, Rn, Rm) {
|
|
280
290
|
return (0b0001101 << 9) | ((Rm & 0x7) << 6) | ((Rn & 7) << 3) | (Rd & 7);
|
|
281
291
|
}
|
|
282
|
-
exports.opcodeSUBSreg = opcodeSUBSreg;
|
|
283
292
|
function opcodeSUBsp(imm) {
|
|
284
293
|
return (0b101100001 << 7) | ((imm >> 2) & 0x7f);
|
|
285
294
|
}
|
|
286
|
-
exports.opcodeSUBsp = opcodeSUBsp;
|
|
287
295
|
function opcodeSVC(imm8) {
|
|
288
296
|
return (0b11011111 << 8) | (imm8 & 0xff);
|
|
289
297
|
}
|
|
290
|
-
exports.opcodeSVC = opcodeSVC;
|
|
291
298
|
function opcodeSXTB(Rd, Rm) {
|
|
292
299
|
return (0b1011001001 << 6) | ((Rm & 7) << 3) | (Rd & 7);
|
|
293
300
|
}
|
|
294
|
-
exports.opcodeSXTB = opcodeSXTB;
|
|
295
301
|
function opcodeSXTH(Rd, Rm) {
|
|
296
302
|
return (0b1011001000 << 6) | ((Rm & 7) << 3) | (Rd & 7);
|
|
297
303
|
}
|
|
298
|
-
exports.opcodeSXTH = opcodeSXTH;
|
|
299
304
|
function opcodeTST(Rm, Rn) {
|
|
300
305
|
return (0b0100001000 << 6) | ((Rn & 7) << 3) | (Rm & 7);
|
|
301
306
|
}
|
|
302
|
-
exports.opcodeTST = opcodeTST;
|
|
303
307
|
function opcodeUXTB(Rd, Rm) {
|
|
304
308
|
return (0b1011001011 << 6) | ((Rm & 7) << 3) | (Rd & 7);
|
|
305
309
|
}
|
|
306
|
-
exports.opcodeUXTB = opcodeUXTB;
|
|
307
310
|
function opcodeUDF(imm8) {
|
|
308
311
|
return ((0b11011110 << 8) | (imm8 & 0xff)) >>> 0;
|
|
309
312
|
}
|
|
310
|
-
exports.opcodeUDF = opcodeUDF;
|
|
311
313
|
function opcodeUDF2(imm16) {
|
|
312
314
|
const imm12 = imm16 & 0xfff;
|
|
313
315
|
const imm4 = (imm16 >> 12) & 0xf;
|
|
314
316
|
return ((0b111101111111 << 4) | imm4 | (0b1010 << 28) | (imm12 << 16)) >>> 0;
|
|
315
317
|
}
|
|
316
|
-
exports.opcodeUDF2 = opcodeUDF2;
|
|
317
318
|
function opcodeUXTH(Rd, Rm) {
|
|
318
319
|
return (0b1011001010 << 6) | ((Rm & 7) << 3) | (Rd & 7);
|
|
319
320
|
}
|
|
320
|
-
exports.opcodeUXTH = opcodeUXTH;
|
|
321
321
|
function opcodeWFI() {
|
|
322
322
|
return 0b1011111100110000;
|
|
323
323
|
}
|
|
324
|
-
exports.opcodeWFI = opcodeWFI;
|
|
325
324
|
function opcodeYIELD() {
|
|
326
325
|
return 0b1011111100010000;
|
|
327
326
|
}
|
|
328
|
-
exports.opcodeYIELD = opcodeYIELD;
|
package/dist/cjs/utils/bit.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.bit = bit;
|
|
4
|
+
exports.s32 = s32;
|
|
5
|
+
exports.u32 = u32;
|
|
4
6
|
function bit(n) {
|
|
5
7
|
return 1 << n;
|
|
6
8
|
}
|
|
7
|
-
exports.bit = bit;
|
|
8
9
|
function s32(n) {
|
|
9
10
|
return n | 0;
|
|
10
11
|
}
|
|
11
|
-
exports.s32 = s32;
|
|
12
12
|
function u32(n) {
|
|
13
13
|
return n >>> 0;
|
|
14
14
|
}
|
|
15
|
-
exports.u32 = u32;
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.PIO_COND_NOTEMPTYOSR = exports.PIO_COND_PIN = exports.PIO_COND_XNEY = exports.PIO_COND_YDEC = exports.PIO_COND_NOTY = exports.PIO_COND_XDEC = exports.PIO_COND_NOTX = exports.PIO_COND_ALWAYS = exports.PIO_WAIT_SRC_IRQ = exports.PIO_WAIT_SRC_PIN = exports.PIO_WAIT_SRC_GPIO = exports.PIO_OP_BITREV = exports.PIO_OP_INVERT = exports.PIO_OP_NONE = exports.PIO_MOV_DEST_OSR = exports.PIO_MOV_DEST_ISR = exports.PIO_MOV_DEST_PC = exports.PIO_MOV_DEST_EXEC = exports.PIO_MOV_DEST_Y = exports.PIO_MOV_DEST_X = exports.PIO_MOV_DEST_PINS = exports.PIO_DEST_EXEC = exports.PIO_DEST_ISR = exports.PIO_DEST_PC = exports.PIO_DEST_PINDIRS = exports.PIO_DEST_NULL = exports.PIO_DEST_Y = exports.PIO_DEST_X = exports.PIO_DEST_PINS = exports.PIO_SRC_OSR = exports.PIO_SRC_ISR = exports.PIO_SRC_STATUS = exports.PIO_SRC_NULL = exports.PIO_SRC_Y = exports.PIO_SRC_X = exports.PIO_SRC_PINS = void 0;
|
|
4
|
+
exports.pioJMP = pioJMP;
|
|
5
|
+
exports.pioWAIT = pioWAIT;
|
|
6
|
+
exports.pioIN = pioIN;
|
|
7
|
+
exports.pioOUT = pioOUT;
|
|
8
|
+
exports.pioPUSH = pioPUSH;
|
|
9
|
+
exports.pioPULL = pioPULL;
|
|
10
|
+
exports.pioMOV = pioMOV;
|
|
11
|
+
exports.pioIRQ = pioIRQ;
|
|
12
|
+
exports.pioSET = pioSET;
|
|
4
13
|
exports.PIO_SRC_PINS = 0;
|
|
5
14
|
exports.PIO_SRC_X = 1;
|
|
6
15
|
exports.PIO_SRC_Y = 2;
|
|
@@ -40,7 +49,6 @@ exports.PIO_COND_NOTEMPTYOSR = 7;
|
|
|
40
49
|
function pioJMP(cond = 0, address, delay = 0) {
|
|
41
50
|
return ((delay & 0x1f) << 8) | ((cond & 0x7) << 5) | (address & 0x1f);
|
|
42
51
|
}
|
|
43
|
-
exports.pioJMP = pioJMP;
|
|
44
52
|
function pioWAIT(polarity, src, index, delay = 0) {
|
|
45
53
|
return ((1 << 13) |
|
|
46
54
|
((delay & 0x1f) << 8) |
|
|
@@ -48,19 +56,15 @@ function pioWAIT(polarity, src, index, delay = 0) {
|
|
|
48
56
|
((src & 0x3) << 5) |
|
|
49
57
|
(index & 0x1f));
|
|
50
58
|
}
|
|
51
|
-
exports.pioWAIT = pioWAIT;
|
|
52
59
|
function pioIN(src, bitCount, delay = 0) {
|
|
53
60
|
return (2 << 13) | ((delay & 0x1f) << 8) | ((src & 0x7) << 5) | (bitCount & 0x1f);
|
|
54
61
|
}
|
|
55
|
-
exports.pioIN = pioIN;
|
|
56
62
|
function pioOUT(Dest, bitCount, delay = 0) {
|
|
57
63
|
return (3 << 13) | ((delay & 0x1f) << 8) | ((Dest & 0x7) << 5) | (bitCount & 0x1f);
|
|
58
64
|
}
|
|
59
|
-
exports.pioOUT = pioOUT;
|
|
60
65
|
function pioPUSH(ifFull, noBlock, delay = 0) {
|
|
61
66
|
return (4 << 13) | ((delay & 0x1f) << 8) | ((ifFull ? 1 : 0) << 6) | ((noBlock ? 1 : 0) << 5);
|
|
62
67
|
}
|
|
63
|
-
exports.pioPUSH = pioPUSH;
|
|
64
68
|
function pioPULL(ifEmpty, noBlock, delay = 0) {
|
|
65
69
|
return ((4 << 13) |
|
|
66
70
|
((delay & 0x1f) << 8) |
|
|
@@ -68,11 +72,9 @@ function pioPULL(ifEmpty, noBlock, delay = 0) {
|
|
|
68
72
|
((ifEmpty ? 1 : 0) << 6) |
|
|
69
73
|
((noBlock ? 1 : 0) << 5));
|
|
70
74
|
}
|
|
71
|
-
exports.pioPULL = pioPULL;
|
|
72
75
|
function pioMOV(dest, op = 0, src, delay = 0) {
|
|
73
76
|
return (5 << 13) | ((delay & 0x1f) << 8) | ((dest & 0x7) << 5) | ((op & 0x3) << 3) | (src & 0x7);
|
|
74
77
|
}
|
|
75
|
-
exports.pioMOV = pioMOV;
|
|
76
78
|
function pioIRQ(clear, wait, index, delay = 0) {
|
|
77
79
|
return ((6 << 13) |
|
|
78
80
|
((delay & 0x1f) << 8) |
|
|
@@ -80,8 +82,6 @@ function pioIRQ(clear, wait, index, delay = 0) {
|
|
|
80
82
|
((wait ? 1 : 0) << 5) |
|
|
81
83
|
(index & 0x1f));
|
|
82
84
|
}
|
|
83
|
-
exports.pioIRQ = pioIRQ;
|
|
84
85
|
function pioSET(dest, data, delay = 0) {
|
|
85
86
|
return (7 << 13) | ((delay & 0x1f) << 8) | ((dest & 0x7) << 5) | (data & 0x1f);
|
|
86
87
|
}
|
|
87
|
-
exports.pioSET = pioSET;
|
package/dist/cjs/utils/time.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getCurrentMicroseconds = getCurrentMicroseconds;
|
|
4
|
+
exports.formatTime = formatTime;
|
|
4
5
|
function getCurrentMicroseconds() {
|
|
5
6
|
if (typeof performance != 'undefined') {
|
|
6
7
|
return Math.floor(performance.now() * 1000);
|
|
@@ -9,7 +10,6 @@ function getCurrentMicroseconds() {
|
|
|
9
10
|
return Math.floor(eval('require')('perf_hooks').performance.now() * 1000);
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
|
-
exports.getCurrentMicroseconds = getCurrentMicroseconds;
|
|
13
13
|
function leftPad(value, minLength, padChar = ' ') {
|
|
14
14
|
if (value.length < minLength) {
|
|
15
15
|
value = padChar + value;
|
|
@@ -29,4 +29,3 @@ function formatTime(date) {
|
|
|
29
29
|
const milliseconds = rightPad(date.getMilliseconds().toString(), 3);
|
|
30
30
|
return `${hours}:${minutes}:${seconds}.${milliseconds}`;
|
|
31
31
|
}
|
|
32
|
-
exports.formatTime = formatTime;
|
|
@@ -2,8 +2,8 @@ export declare function encodeHexByte(value: number): string;
|
|
|
2
2
|
export declare function encodeHexBuf(buf: Uint8Array): string;
|
|
3
3
|
export declare function encodeHexUint32BE(value: number): string;
|
|
4
4
|
export declare function encodeHexUint32(value: number): string;
|
|
5
|
-
export declare function decodeHexBuf(encoded: string): Uint8Array
|
|
6
|
-
export declare function decodeHexUint32Array(encoded: string): Uint32Array
|
|
5
|
+
export declare function decodeHexBuf(encoded: string): Uint8Array<ArrayBuffer>;
|
|
6
|
+
export declare function decodeHexUint32Array(encoded: string): Uint32Array<ArrayBuffer>;
|
|
7
7
|
export declare function decodeHexUint32(encoded: string): number;
|
|
8
8
|
export declare function gdbChecksum(text: string): string;
|
|
9
9
|
export declare function gdbMessage(value: string): string;
|
|
@@ -86,7 +86,7 @@ export declare class StateMachine {
|
|
|
86
86
|
export declare class RPPIO extends BasePeripheral implements Peripheral {
|
|
87
87
|
readonly firstIrq: number;
|
|
88
88
|
readonly index: number;
|
|
89
|
-
readonly instructions: Uint32Array
|
|
89
|
+
readonly instructions: Uint32Array<ArrayBuffer>;
|
|
90
90
|
readonly dreqRx: DREQChannel[];
|
|
91
91
|
readonly dreqTx: DREQChannel[];
|
|
92
92
|
readonly machines: StateMachine[];
|
|
@@ -4,7 +4,7 @@ import { BasePeripheral, Peripheral } from './peripheral.js';
|
|
|
4
4
|
export declare class RPWatchdog extends BasePeripheral implements Peripheral {
|
|
5
5
|
readonly timer: Timer32;
|
|
6
6
|
readonly alarm: Timer32PeriodicAlarm;
|
|
7
|
-
readonly scratchData: Uint32Array
|
|
7
|
+
readonly scratchData: Uint32Array<ArrayBuffer>;
|
|
8
8
|
private enable;
|
|
9
9
|
private tickEnable;
|
|
10
10
|
private reason;
|
package/dist/esm/rp2040.d.ts
CHANGED
|
@@ -21,14 +21,14 @@ export declare const DPRAM_START_ADDRESS = 1343225856;
|
|
|
21
21
|
export declare const SIO_START_ADDRESS = 3489660928;
|
|
22
22
|
export declare class RP2040 {
|
|
23
23
|
readonly clock: IClock;
|
|
24
|
-
readonly bootrom: Uint32Array
|
|
25
|
-
readonly sram: Uint8Array
|
|
26
|
-
readonly sramView: DataView
|
|
27
|
-
readonly flash: Uint8Array
|
|
28
|
-
readonly flash16: Uint16Array
|
|
29
|
-
readonly flashView: DataView
|
|
30
|
-
readonly usbDPRAM: Uint8Array
|
|
31
|
-
readonly usbDPRAMView: DataView
|
|
24
|
+
readonly bootrom: Uint32Array<ArrayBuffer>;
|
|
25
|
+
readonly sram: Uint8Array<ArrayBuffer>;
|
|
26
|
+
readonly sramView: DataView<ArrayBuffer>;
|
|
27
|
+
readonly flash: Uint8Array<ArrayBuffer>;
|
|
28
|
+
readonly flash16: Uint16Array<ArrayBuffer>;
|
|
29
|
+
readonly flashView: DataView<ArrayBuffer>;
|
|
30
|
+
readonly usbDPRAM: Uint8Array<ArrayBuffer>;
|
|
31
|
+
readonly usbDPRAMView: DataView<ArrayBuffer>;
|
|
32
32
|
readonly core: CortexM0Core;
|
|
33
33
|
clkSys: number;
|
|
34
34
|
clkPeri: number;
|
package/dist/esm/usb/setup.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DescriptorType, ISetupPacketParams } from './interfaces.js';
|
|
2
|
-
export declare function createSetupPacket(params: ISetupPacketParams): Uint8Array
|
|
3
|
-
export declare function setDeviceAddressPacket(address: number): Uint8Array
|
|
4
|
-
export declare function getDescriptorPacket(type: DescriptorType, length: number, index?: number): Uint8Array
|
|
5
|
-
export declare function setDeviceConfigurationPacket(configurationNumber: number): Uint8Array
|
|
2
|
+
export declare function createSetupPacket(params: ISetupPacketParams): Uint8Array<ArrayBuffer>;
|
|
3
|
+
export declare function setDeviceAddressPacket(address: number): Uint8Array<ArrayBuffer>;
|
|
4
|
+
export declare function getDescriptorPacket(type: DescriptorType, length: number, index?: number): Uint8Array<ArrayBuffer>;
|
|
5
|
+
export declare function setDeviceConfigurationPacket(configurationNumber: number): Uint8Array<ArrayBuffer>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rp2040js",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Raspberry Pi Pico (RP2040) Emulator",
|
|
5
5
|
"repository": "https://github.com/wokwi/rp2040js",
|
|
6
6
|
"keywords": [
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"module": "./dist/esm/index.js",
|
|
19
19
|
"typings": "./dist/cjs/index.d.ts",
|
|
20
20
|
"engines": {
|
|
21
|
-
"node": ">=
|
|
21
|
+
"node": ">=18.0.0"
|
|
22
22
|
},
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
@@ -58,19 +58,19 @@
|
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@types/minimist": "^1.2.2",
|
|
61
|
-
"@types/node": "^
|
|
61
|
+
"@types/node": "^18",
|
|
62
62
|
"@typescript-eslint/eslint-plugin": "^6.7.3",
|
|
63
63
|
"@typescript-eslint/parser": "^6.7.3",
|
|
64
64
|
"eslint": "^8.50.0",
|
|
65
65
|
"husky": "^8.0.3",
|
|
66
|
-
"lint-staged": "^
|
|
66
|
+
"lint-staged": "^15.4.3",
|
|
67
67
|
"minimist": "^1.2.7",
|
|
68
68
|
"prettier": "^3.0.3",
|
|
69
69
|
"rimraf": "^5.0.5",
|
|
70
|
-
"tsx": "^4.
|
|
71
|
-
"typescript": "^5.
|
|
70
|
+
"tsx": "^4.19.3",
|
|
71
|
+
"typescript": "^5.7.3",
|
|
72
72
|
"uf2": "^1.0.0",
|
|
73
|
-
"vitest": "^0.
|
|
73
|
+
"vitest": "^3.0.6"
|
|
74
74
|
},
|
|
75
75
|
"lint-staged": {
|
|
76
76
|
"**/*.ts": [
|