rp2040js 0.17.14 → 0.17.16
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/dist/cjs/cortex-m0-core.js +4 -7
- package/dist/cjs/peripherals/uart.d.ts +4 -1
- package/dist/cjs/peripherals/uart.js +11 -1
- package/dist/cjs/rp2040.js +4 -1
- package/dist/esm/cortex-m0-core.js +4 -7
- package/dist/esm/peripherals/uart.d.ts +4 -1
- package/dist/esm/peripherals/uart.js +11 -1
- package/dist/esm/rp2040.js +4 -1
- package/package.json +4 -1
|
@@ -606,13 +606,12 @@ class CortexM0Core {
|
|
|
606
606
|
const Rm = (opcode >> 3) & 0x7;
|
|
607
607
|
const Rd = opcode & 0x7;
|
|
608
608
|
const input = this.registers[Rm];
|
|
609
|
-
const
|
|
609
|
+
const shiftN = imm5 ? imm5 : 32;
|
|
610
|
+
const result = shiftN < 32 ? input >> shiftN : (input & 0x80000000) >> 31;
|
|
610
611
|
this.registers[Rd] = result;
|
|
611
612
|
this.N = !!(result & 0x80000000);
|
|
612
613
|
this.Z = (result & 0xffffffff) === 0;
|
|
613
|
-
|
|
614
|
-
this.C = input & (1 << (imm5 - 1)) ? true : false;
|
|
615
|
-
}
|
|
614
|
+
this.C = input & (1 << (shiftN - 1)) ? true : false;
|
|
616
615
|
}
|
|
617
616
|
// ASRS (register)
|
|
618
617
|
else if (opcode >> 6 === 0b0100000100) {
|
|
@@ -624,9 +623,7 @@ class CortexM0Core {
|
|
|
624
623
|
this.registers[Rdn] = result;
|
|
625
624
|
this.N = !!(result & 0x80000000);
|
|
626
625
|
this.Z = (result & 0xffffffff) === 0;
|
|
627
|
-
|
|
628
|
-
this.C = input & (1 << (shiftN - 1)) ? true : false;
|
|
629
|
-
}
|
|
626
|
+
this.C = input & (1 << (shiftN - 1)) ? true : false;
|
|
630
627
|
}
|
|
631
628
|
// B (with cond)
|
|
632
629
|
else if (opcode >> 12 === 0b1101 && ((opcode >> 9) & 0x7) !== 0b111) {
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { RP2040 } from '../rp2040';
|
|
2
2
|
import { BasePeripheral, Peripheral } from './peripheral';
|
|
3
3
|
export declare class RPUART extends BasePeripheral implements Peripheral {
|
|
4
|
+
readonly index: number;
|
|
4
5
|
readonly irq: number;
|
|
5
6
|
private ctrlRegister;
|
|
6
7
|
private lineCtrlRegister;
|
|
7
8
|
private rxFIFO;
|
|
8
9
|
private interruptMask;
|
|
9
10
|
private interruptStatus;
|
|
11
|
+
private readonly rxDREQ;
|
|
12
|
+
private readonly txDREQ;
|
|
10
13
|
onByte?: (value: number) => void;
|
|
11
|
-
constructor(rp2040: RP2040, name: string, irq: number);
|
|
14
|
+
constructor(rp2040: RP2040, name: string, index: number, irq: number);
|
|
12
15
|
get enabled(): boolean;
|
|
13
16
|
get txEnabled(): boolean;
|
|
14
17
|
get rxEnabled(): boolean;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RPUART = void 0;
|
|
4
4
|
const fifo_1 = require("../utils/fifo");
|
|
5
|
+
const dma_1 = require("./dma");
|
|
5
6
|
const peripheral_1 = require("./peripheral");
|
|
6
7
|
const UARTDR = 0x0;
|
|
7
8
|
const UARTFR = 0x18;
|
|
@@ -24,14 +25,17 @@ const UARTEN = 1 << 0;
|
|
|
24
25
|
// Interrupt bits
|
|
25
26
|
const UARTRXINTR = 1 << 4;
|
|
26
27
|
class RPUART extends peripheral_1.BasePeripheral {
|
|
27
|
-
constructor(rp2040, name, irq) {
|
|
28
|
+
constructor(rp2040, name, index, irq) {
|
|
28
29
|
super(rp2040, name);
|
|
30
|
+
this.index = index;
|
|
29
31
|
this.irq = irq;
|
|
30
32
|
this.ctrlRegister = RXE | TXE;
|
|
31
33
|
this.lineCtrlRegister = 0;
|
|
32
34
|
this.rxFIFO = new fifo_1.FIFO(32);
|
|
33
35
|
this.interruptMask = 0;
|
|
34
36
|
this.interruptStatus = 0;
|
|
37
|
+
this.rxDREQ = this.index == 0 ? dma_1.DREQChannel.DREQ_UART0_RX : dma_1.DREQChannel.DREQ_UART1_RX;
|
|
38
|
+
this.txDREQ = this.index == 0 ? dma_1.DREQChannel.DREQ_UART0_TX : dma_1.DREQChannel.DREQ_UART1_TX;
|
|
35
39
|
}
|
|
36
40
|
get enabled() {
|
|
37
41
|
return !!(this.ctrlRegister & UARTEN);
|
|
@@ -108,6 +112,12 @@ class RPUART extends peripheral_1.BasePeripheral {
|
|
|
108
112
|
break;
|
|
109
113
|
case UARTCR:
|
|
110
114
|
this.ctrlRegister = value;
|
|
115
|
+
if (this.enabled) {
|
|
116
|
+
this.rp2040.dma.setDREQ(this.txDREQ);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
this.rp2040.dma.clearDREQ(this.txDREQ);
|
|
120
|
+
}
|
|
111
121
|
break;
|
|
112
122
|
case UARTIMSC:
|
|
113
123
|
this.interruptMask = value & 0x7ff;
|
package/dist/cjs/rp2040.js
CHANGED
|
@@ -54,7 +54,10 @@ class RP2040 {
|
|
|
54
54
|
this.clkPeri = 125 * MHz;
|
|
55
55
|
this.ppb = new ppb_1.RPPPB(this, 'PPB');
|
|
56
56
|
this.sio = new sio_1.RPSIO(this);
|
|
57
|
-
this.uart = [
|
|
57
|
+
this.uart = [
|
|
58
|
+
new uart_1.RPUART(this, 'UART0', 0, irq_1.IRQ.UART0),
|
|
59
|
+
new uart_1.RPUART(this, 'UART1', 1, irq_1.IRQ.UART1),
|
|
60
|
+
];
|
|
58
61
|
this.i2c = [new i2c_1.RPI2C(this, 'I2C0', irq_1.IRQ.I2C0), new i2c_1.RPI2C(this, 'I2C1', irq_1.IRQ.I2C1)];
|
|
59
62
|
this.spi = [new spi_1.RPSPI(this, 'SPI0', irq_1.IRQ.SPI0), new spi_1.RPSPI(this, 'SPI1', irq_1.IRQ.SPI1)];
|
|
60
63
|
this.pwm = new pwm_1.RPPWM(this, 'PWM_BASE');
|
|
@@ -603,13 +603,12 @@ export class CortexM0Core {
|
|
|
603
603
|
const Rm = (opcode >> 3) & 0x7;
|
|
604
604
|
const Rd = opcode & 0x7;
|
|
605
605
|
const input = this.registers[Rm];
|
|
606
|
-
const
|
|
606
|
+
const shiftN = imm5 ? imm5 : 32;
|
|
607
|
+
const result = shiftN < 32 ? input >> shiftN : (input & 0x80000000) >> 31;
|
|
607
608
|
this.registers[Rd] = result;
|
|
608
609
|
this.N = !!(result & 0x80000000);
|
|
609
610
|
this.Z = (result & 0xffffffff) === 0;
|
|
610
|
-
|
|
611
|
-
this.C = input & (1 << (imm5 - 1)) ? true : false;
|
|
612
|
-
}
|
|
611
|
+
this.C = input & (1 << (shiftN - 1)) ? true : false;
|
|
613
612
|
}
|
|
614
613
|
// ASRS (register)
|
|
615
614
|
else if (opcode >> 6 === 0b0100000100) {
|
|
@@ -621,9 +620,7 @@ export class CortexM0Core {
|
|
|
621
620
|
this.registers[Rdn] = result;
|
|
622
621
|
this.N = !!(result & 0x80000000);
|
|
623
622
|
this.Z = (result & 0xffffffff) === 0;
|
|
624
|
-
|
|
625
|
-
this.C = input & (1 << (shiftN - 1)) ? true : false;
|
|
626
|
-
}
|
|
623
|
+
this.C = input & (1 << (shiftN - 1)) ? true : false;
|
|
627
624
|
}
|
|
628
625
|
// B (with cond)
|
|
629
626
|
else if (opcode >> 12 === 0b1101 && ((opcode >> 9) & 0x7) !== 0b111) {
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { RP2040 } from '../rp2040';
|
|
2
2
|
import { BasePeripheral, Peripheral } from './peripheral';
|
|
3
3
|
export declare class RPUART extends BasePeripheral implements Peripheral {
|
|
4
|
+
readonly index: number;
|
|
4
5
|
readonly irq: number;
|
|
5
6
|
private ctrlRegister;
|
|
6
7
|
private lineCtrlRegister;
|
|
7
8
|
private rxFIFO;
|
|
8
9
|
private interruptMask;
|
|
9
10
|
private interruptStatus;
|
|
11
|
+
private readonly rxDREQ;
|
|
12
|
+
private readonly txDREQ;
|
|
10
13
|
onByte?: (value: number) => void;
|
|
11
|
-
constructor(rp2040: RP2040, name: string, irq: number);
|
|
14
|
+
constructor(rp2040: RP2040, name: string, index: number, irq: number);
|
|
12
15
|
get enabled(): boolean;
|
|
13
16
|
get txEnabled(): boolean;
|
|
14
17
|
get rxEnabled(): boolean;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FIFO } from '../utils/fifo';
|
|
2
|
+
import { DREQChannel } from './dma';
|
|
2
3
|
import { BasePeripheral } from './peripheral';
|
|
3
4
|
const UARTDR = 0x0;
|
|
4
5
|
const UARTFR = 0x18;
|
|
@@ -21,14 +22,17 @@ const UARTEN = 1 << 0;
|
|
|
21
22
|
// Interrupt bits
|
|
22
23
|
const UARTRXINTR = 1 << 4;
|
|
23
24
|
export class RPUART extends BasePeripheral {
|
|
24
|
-
constructor(rp2040, name, irq) {
|
|
25
|
+
constructor(rp2040, name, index, irq) {
|
|
25
26
|
super(rp2040, name);
|
|
27
|
+
this.index = index;
|
|
26
28
|
this.irq = irq;
|
|
27
29
|
this.ctrlRegister = RXE | TXE;
|
|
28
30
|
this.lineCtrlRegister = 0;
|
|
29
31
|
this.rxFIFO = new FIFO(32);
|
|
30
32
|
this.interruptMask = 0;
|
|
31
33
|
this.interruptStatus = 0;
|
|
34
|
+
this.rxDREQ = this.index == 0 ? DREQChannel.DREQ_UART0_RX : DREQChannel.DREQ_UART1_RX;
|
|
35
|
+
this.txDREQ = this.index == 0 ? DREQChannel.DREQ_UART0_TX : DREQChannel.DREQ_UART1_TX;
|
|
32
36
|
}
|
|
33
37
|
get enabled() {
|
|
34
38
|
return !!(this.ctrlRegister & UARTEN);
|
|
@@ -105,6 +109,12 @@ export class RPUART extends BasePeripheral {
|
|
|
105
109
|
break;
|
|
106
110
|
case UARTCR:
|
|
107
111
|
this.ctrlRegister = value;
|
|
112
|
+
if (this.enabled) {
|
|
113
|
+
this.rp2040.dma.setDREQ(this.txDREQ);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
this.rp2040.dma.clearDREQ(this.txDREQ);
|
|
117
|
+
}
|
|
108
118
|
break;
|
|
109
119
|
case UARTIMSC:
|
|
110
120
|
this.interruptMask = value & 0x7ff;
|
package/dist/esm/rp2040.js
CHANGED
|
@@ -51,7 +51,10 @@ export class RP2040 {
|
|
|
51
51
|
this.clkPeri = 125 * MHz;
|
|
52
52
|
this.ppb = new RPPPB(this, 'PPB');
|
|
53
53
|
this.sio = new RPSIO(this);
|
|
54
|
-
this.uart = [
|
|
54
|
+
this.uart = [
|
|
55
|
+
new RPUART(this, 'UART0', 0, IRQ.UART0),
|
|
56
|
+
new RPUART(this, 'UART1', 1, IRQ.UART1),
|
|
57
|
+
];
|
|
55
58
|
this.i2c = [new RPI2C(this, 'I2C0', IRQ.I2C0), new RPI2C(this, 'I2C1', IRQ.I2C1)];
|
|
56
59
|
this.spi = [new RPSPI(this, 'SPI0', IRQ.SPI0), new RPSPI(this, 'SPI1', IRQ.SPI1)];
|
|
57
60
|
this.pwm = new RPPWM(this, 'PWM_BASE');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rp2040js",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.16",
|
|
4
4
|
"description": "Raspberry Pi Pico (RP2040) Emulator",
|
|
5
5
|
"repository": "https://github.com/wokwi/rp2040js",
|
|
6
6
|
"keywords": [
|
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
"main": "./dist/cjs/index.js",
|
|
17
17
|
"module": "./dist/esm/index.js",
|
|
18
18
|
"typings": "./dist/cjs/index.d.ts",
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=16.0.0"
|
|
21
|
+
},
|
|
19
22
|
"exports": {
|
|
20
23
|
".": {
|
|
21
24
|
"import": "./dist/esm/index.js",
|