rp2040js 0.17.15 → 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.
|
@@ -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');
|
|
@@ -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",
|