rp2040js 0.17.16 → 0.18.0
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 +1 -1
- package/dist/cjs/clock/clock.d.ts +11 -11
- package/dist/cjs/clock/clock.js +2 -2
- package/dist/cjs/clock/mock-clock.d.ts +17 -17
- package/dist/cjs/clock/mock-clock.js +52 -52
- package/dist/cjs/clock/realtime-clock.d.ts +23 -23
- package/dist/cjs/clock/realtime-clock.js +73 -73
- package/dist/cjs/cortex-m0-core.d.ts +87 -87
- package/dist/cjs/cortex-m0-core.js +1251 -1251
- package/dist/cjs/gdb/gdb-connection.d.ts +11 -11
- package/dist/cjs/gdb/gdb-connection.js +57 -57
- package/dist/cjs/gdb/gdb-server.d.ts +23 -23
- package/dist/cjs/gdb/gdb-server.js +232 -232
- package/dist/cjs/gdb/gdb-tcp-server.d.ts +10 -10
- package/dist/cjs/gdb/gdb-tcp-server.js +34 -34
- package/dist/cjs/gdb/gdb-utils.d.ts +9 -9
- package/dist/cjs/gdb/gdb-utils.js +48 -48
- package/dist/cjs/gpio-pin.d.ts +56 -56
- package/dist/cjs/gpio-pin.js +216 -216
- package/dist/cjs/index.d.ts +11 -11
- package/dist/cjs/index.js +36 -36
- package/dist/cjs/interpolator.d.ts +36 -36
- package/dist/cjs/interpolator.js +150 -150
- package/dist/cjs/irq.d.ts +29 -29
- package/dist/cjs/irq.js +33 -33
- package/dist/cjs/peripherals/adc.d.ts +52 -52
- package/dist/cjs/peripherals/adc.js +261 -261
- package/dist/cjs/peripherals/busctrl.d.ts +10 -10
- package/dist/cjs/peripherals/busctrl.js +84 -84
- package/dist/cjs/peripherals/clocks.d.ts +9 -9
- package/dist/cjs/peripherals/clocks.js +42 -42
- package/dist/cjs/peripherals/dma.d.ts +109 -109
- package/dist/cjs/peripherals/dma.js +520 -520
- package/dist/cjs/peripherals/i2c.d.ts +54 -54
- package/dist/cjs/peripherals/i2c.js +458 -458
- package/dist/cjs/peripherals/io.d.ts +11 -11
- package/dist/cjs/peripherals/io.js +100 -100
- package/dist/cjs/peripherals/pads.d.ts +13 -13
- package/dist/cjs/peripherals/pads.js +58 -58
- package/dist/cjs/peripherals/peripheral.d.ts +22 -22
- package/dist/cjs/peripherals/peripheral.js +61 -61
- package/dist/cjs/peripherals/pio.d.ts +120 -120
- package/dist/cjs/peripherals/pio.js +1086 -1086
- package/dist/cjs/peripherals/ppb.d.ts +25 -25
- package/dist/cjs/peripherals/ppb.js +229 -229
- package/dist/cjs/peripherals/pwm.d.ts +65 -65
- package/dist/cjs/peripherals/pwm.js +372 -372
- package/dist/cjs/peripherals/reset.d.ts +8 -8
- package/dist/cjs/peripherals/reset.js +40 -40
- package/dist/cjs/peripherals/rtc.d.ts +10 -10
- package/dist/cjs/peripherals/rtc.js +74 -74
- package/dist/cjs/peripherals/spi.d.ts +38 -30
- package/dist/cjs/peripherals/spi.js +240 -218
- package/dist/cjs/peripherals/ssi.d.ts +6 -6
- package/dist/cjs/peripherals/ssi.js +43 -43
- package/dist/cjs/peripherals/syscfg.d.ts +5 -5
- package/dist/cjs/peripherals/syscfg.js +26 -26
- package/dist/cjs/peripherals/sysinfo.d.ts +4 -4
- package/dist/cjs/peripherals/sysinfo.js +22 -22
- package/dist/cjs/peripherals/tbman.d.ts +4 -4
- package/dist/cjs/peripherals/tbman.js +17 -17
- package/dist/cjs/peripherals/timer.d.ts +18 -18
- package/dist/cjs/peripherals/timer.js +156 -156
- package/dist/cjs/peripherals/uart.d.ts +31 -28
- package/dist/cjs/peripherals/uart.js +132 -135
- package/dist/cjs/peripherals/usb.d.ts +29 -29
- package/dist/cjs/peripherals/usb.js +309 -309
- package/dist/cjs/rp2040.d.ts +71 -71
- package/dist/cjs/rp2040.js +361 -346
- package/dist/cjs/sio.d.ts +21 -21
- package/dist/cjs/sio.js +425 -425
- package/dist/cjs/usb/cdc.d.ts +20 -20
- package/dist/cjs/usb/cdc.js +126 -126
- package/dist/cjs/usb/interfaces.d.ts +47 -47
- package/dist/cjs/usb/interfaces.js +46 -46
- package/dist/cjs/usb/setup.d.ts +5 -5
- package/dist/cjs/usb/setup.js +53 -53
- package/dist/cjs/utils/assembler.d.ts +79 -79
- package/dist/cjs/utils/assembler.js +328 -328
- package/dist/cjs/utils/bit.d.ts +3 -3
- package/dist/cjs/utils/bit.js +15 -15
- package/dist/cjs/utils/fifo.d.ts +15 -15
- package/dist/cjs/utils/fifo.js +56 -56
- package/dist/cjs/utils/logging.d.ts +23 -23
- package/dist/cjs/utils/logging.js +48 -48
- package/dist/cjs/utils/pio-assembler.d.ts +45 -45
- package/dist/cjs/utils/pio-assembler.js +87 -87
- package/dist/cjs/utils/time.d.ts +2 -2
- package/dist/cjs/utils/time.js +32 -32
- package/dist/cjs/utils/timer32.d.ts +57 -57
- package/dist/cjs/utils/timer32.js +208 -208
- package/dist/esm/clock/clock.d.ts +11 -11
- package/dist/esm/clock/clock.js +1 -1
- package/dist/esm/clock/mock-clock.d.ts +17 -17
- package/dist/esm/clock/mock-clock.js +47 -47
- package/dist/esm/clock/realtime-clock.d.ts +23 -23
- package/dist/esm/clock/realtime-clock.js +68 -68
- package/dist/esm/cortex-m0-core.d.ts +87 -87
- package/dist/esm/cortex-m0-core.js +1247 -1247
- package/dist/esm/gdb/gdb-connection.d.ts +11 -11
- package/dist/esm/gdb/gdb-connection.js +53 -53
- package/dist/esm/gdb/gdb-server.d.ts +23 -23
- package/dist/esm/gdb/gdb-server.js +228 -228
- package/dist/esm/gdb/gdb-tcp-server.d.ts +10 -10
- package/dist/esm/gdb/gdb-tcp-server.js +30 -30
- package/dist/esm/gdb/gdb-utils.d.ts +9 -9
- package/dist/esm/gdb/gdb-utils.js +36 -36
- package/dist/esm/gpio-pin.d.ts +56 -56
- package/dist/esm/gpio-pin.js +212 -212
- package/dist/esm/index.d.ts +11 -11
- package/dist/esm/index.js +11 -11
- package/dist/esm/interpolator.d.ts +36 -36
- package/dist/esm/interpolator.js +145 -145
- package/dist/esm/irq.d.ts +29 -29
- package/dist/esm/irq.js +30 -30
- package/dist/esm/peripherals/adc.d.ts +52 -52
- package/dist/esm/peripherals/adc.js +257 -257
- package/dist/esm/peripherals/busctrl.d.ts +10 -10
- package/dist/esm/peripherals/busctrl.js +80 -80
- package/dist/esm/peripherals/clocks.d.ts +9 -9
- package/dist/esm/peripherals/clocks.js +38 -38
- package/dist/esm/peripherals/dma.d.ts +109 -109
- package/dist/esm/peripherals/dma.js +515 -515
- package/dist/esm/peripherals/i2c.d.ts +54 -54
- package/dist/esm/peripherals/i2c.js +454 -454
- package/dist/esm/peripherals/io.d.ts +11 -11
- package/dist/esm/peripherals/io.js +96 -96
- package/dist/esm/peripherals/pads.d.ts +13 -13
- package/dist/esm/peripherals/pads.js +54 -54
- package/dist/esm/peripherals/peripheral.d.ts +22 -22
- package/dist/esm/peripherals/peripheral.js +55 -55
- package/dist/esm/peripherals/pio.d.ts +120 -120
- package/dist/esm/peripherals/pio.js +1081 -1081
- package/dist/esm/peripherals/ppb.d.ts +25 -25
- package/dist/esm/peripherals/ppb.js +225 -225
- package/dist/esm/peripherals/pwm.d.ts +65 -65
- package/dist/esm/peripherals/pwm.js +368 -368
- package/dist/esm/peripherals/reset.d.ts +8 -8
- package/dist/esm/peripherals/reset.js +36 -36
- package/dist/esm/peripherals/rtc.d.ts +10 -10
- package/dist/esm/peripherals/rtc.js +70 -70
- package/dist/esm/peripherals/spi.d.ts +38 -30
- package/dist/esm/peripherals/spi.js +236 -214
- package/dist/esm/peripherals/ssi.d.ts +6 -6
- package/dist/esm/peripherals/ssi.js +39 -39
- package/dist/esm/peripherals/syscfg.d.ts +5 -5
- package/dist/esm/peripherals/syscfg.js +22 -22
- package/dist/esm/peripherals/sysinfo.d.ts +4 -4
- package/dist/esm/peripherals/sysinfo.js +18 -18
- package/dist/esm/peripherals/tbman.d.ts +4 -4
- package/dist/esm/peripherals/tbman.js +13 -13
- package/dist/esm/peripherals/timer.d.ts +18 -18
- package/dist/esm/peripherals/timer.js +152 -152
- package/dist/esm/peripherals/uart.d.ts +31 -28
- package/dist/esm/peripherals/uart.js +128 -131
- package/dist/esm/peripherals/usb.d.ts +29 -29
- package/dist/esm/peripherals/usb.js +305 -305
- package/dist/esm/rp2040.d.ts +71 -71
- package/dist/esm/rp2040.js +357 -342
- package/dist/esm/sio.d.ts +21 -21
- package/dist/esm/sio.js +421 -421
- package/dist/esm/usb/cdc.d.ts +20 -20
- package/dist/esm/usb/cdc.js +121 -121
- package/dist/esm/usb/interfaces.d.ts +47 -47
- package/dist/esm/usb/interfaces.js +43 -43
- package/dist/esm/usb/setup.d.ts +5 -5
- package/dist/esm/usb/setup.js +46 -46
- package/dist/esm/utils/assembler.d.ts +79 -79
- package/dist/esm/utils/assembler.js +245 -245
- package/dist/esm/utils/bit.d.ts +3 -3
- package/dist/esm/utils/bit.js +9 -9
- package/dist/esm/utils/fifo.d.ts +15 -15
- package/dist/esm/utils/fifo.js +52 -52
- package/dist/esm/utils/logging.d.ts +23 -23
- package/dist/esm/utils/logging.js +44 -44
- package/dist/esm/utils/pio-assembler.d.ts +45 -45
- package/dist/esm/utils/pio-assembler.js +75 -75
- package/dist/esm/utils/time.d.ts +2 -2
- package/dist/esm/utils/time.js +27 -27
- package/dist/esm/utils/timer32.d.ts +57 -57
- package/dist/esm/utils/timer32.js +203 -203
- package/package.json +34 -22
- package/dist/esm/package.json +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { RP2040 } from '../rp2040';
|
|
2
|
-
import { BasePeripheral, Peripheral } from './peripheral';
|
|
3
|
-
export declare class RPIO extends BasePeripheral implements Peripheral {
|
|
4
|
-
constructor(rp2040: RP2040, name: string);
|
|
5
|
-
getPinFromOffset(offset: number): {
|
|
6
|
-
gpio: import("
|
|
7
|
-
isCtrl: boolean;
|
|
8
|
-
};
|
|
9
|
-
readUint32(offset: number): number;
|
|
10
|
-
writeUint32(offset: number, value: number): void;
|
|
11
|
-
}
|
|
1
|
+
import { RP2040 } from '../rp2040.js';
|
|
2
|
+
import { BasePeripheral, Peripheral } from './peripheral.js';
|
|
3
|
+
export declare class RPIO extends BasePeripheral implements Peripheral {
|
|
4
|
+
constructor(rp2040: RP2040, name: string);
|
|
5
|
+
getPinFromOffset(offset: number): {
|
|
6
|
+
gpio: import("../gpio-pin.js").GPIOPin;
|
|
7
|
+
isCtrl: boolean;
|
|
8
|
+
};
|
|
9
|
+
readUint32(offset: number): number;
|
|
10
|
+
writeUint32(offset: number, value: number): void;
|
|
11
|
+
}
|
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RPIO = void 0;
|
|
4
|
-
const
|
|
5
|
-
const GPIO_CTRL_LAST = 0x0ec;
|
|
6
|
-
const INTR0 = 0xf0;
|
|
7
|
-
const PROC0_INTE0 = 0x100;
|
|
8
|
-
const PROC0_INTF0 = 0x110;
|
|
9
|
-
const PROC0_INTS0 = 0x120;
|
|
10
|
-
const PROC0_INTS3 = 0x12c;
|
|
11
|
-
class RPIO extends
|
|
12
|
-
constructor(rp2040, name) {
|
|
13
|
-
super(rp2040, name);
|
|
14
|
-
}
|
|
15
|
-
getPinFromOffset(offset) {
|
|
16
|
-
const gpioIndex = offset >>> 3;
|
|
17
|
-
return {
|
|
18
|
-
gpio: this.rp2040.gpio[gpioIndex],
|
|
19
|
-
isCtrl: !!(offset & 0x4),
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
readUint32(offset) {
|
|
23
|
-
if (offset <= GPIO_CTRL_LAST) {
|
|
24
|
-
const { gpio, isCtrl } = this.getPinFromOffset(offset);
|
|
25
|
-
return isCtrl ? gpio.ctrl : gpio.status;
|
|
26
|
-
}
|
|
27
|
-
if (offset >= INTR0 && offset <= PROC0_INTS3) {
|
|
28
|
-
const startIndex = (offset & 0xf) * 2;
|
|
29
|
-
const register = offset & ~0xf;
|
|
30
|
-
const { gpio } = this.rp2040;
|
|
31
|
-
let result = 0;
|
|
32
|
-
for (let index = 7; index >= 0; index--) {
|
|
33
|
-
const pin = gpio[index + startIndex];
|
|
34
|
-
if (!pin) {
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
result <<= 4;
|
|
38
|
-
switch (register) {
|
|
39
|
-
case INTR0:
|
|
40
|
-
result |= pin.irqStatus;
|
|
41
|
-
break;
|
|
42
|
-
case PROC0_INTE0:
|
|
43
|
-
result |= pin.irqEnableMask;
|
|
44
|
-
break;
|
|
45
|
-
case PROC0_INTF0:
|
|
46
|
-
result |= pin.irqForceMask;
|
|
47
|
-
break;
|
|
48
|
-
case PROC0_INTS0:
|
|
49
|
-
result |= (pin.irqStatus & pin.irqEnableMask) | pin.irqForceMask;
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return result;
|
|
54
|
-
}
|
|
55
|
-
return super.readUint32(offset);
|
|
56
|
-
}
|
|
57
|
-
writeUint32(offset, value) {
|
|
58
|
-
if (offset <= GPIO_CTRL_LAST) {
|
|
59
|
-
const { gpio, isCtrl } = this.getPinFromOffset(offset);
|
|
60
|
-
if (isCtrl) {
|
|
61
|
-
gpio.ctrl = value;
|
|
62
|
-
gpio.checkForUpdates();
|
|
63
|
-
}
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
if (offset >= INTR0 && offset <= PROC0_INTS3) {
|
|
67
|
-
const startIndex = (offset & 0xf) * 2;
|
|
68
|
-
const register = offset & ~0xf;
|
|
69
|
-
const { gpio } = this.rp2040;
|
|
70
|
-
for (let index = 0; index < 8; index++) {
|
|
71
|
-
const pin = gpio[index + startIndex];
|
|
72
|
-
if (!pin) {
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
const pinValue = (value >> (index * 4)) & 0xf;
|
|
76
|
-
const pinRawWriteValue = (this.rawWriteValue >> (index * 4)) & 0xf;
|
|
77
|
-
switch (register) {
|
|
78
|
-
case INTR0:
|
|
79
|
-
pin.updateIRQValue(pinRawWriteValue);
|
|
80
|
-
break;
|
|
81
|
-
case PROC0_INTE0:
|
|
82
|
-
if (pin.irqEnableMask !== pinValue) {
|
|
83
|
-
pin.irqEnableMask = pinValue;
|
|
84
|
-
this.rp2040.updateIOInterrupt();
|
|
85
|
-
}
|
|
86
|
-
break;
|
|
87
|
-
case PROC0_INTF0:
|
|
88
|
-
if (pin.irqForceMask !== pinValue) {
|
|
89
|
-
pin.irqForceMask = pinValue;
|
|
90
|
-
this.rp2040.updateIOInterrupt();
|
|
91
|
-
}
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
super.writeUint32(offset, value);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
exports.RPIO = RPIO;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RPIO = void 0;
|
|
4
|
+
const peripheral_js_1 = require("./peripheral.js");
|
|
5
|
+
const GPIO_CTRL_LAST = 0x0ec;
|
|
6
|
+
const INTR0 = 0xf0;
|
|
7
|
+
const PROC0_INTE0 = 0x100;
|
|
8
|
+
const PROC0_INTF0 = 0x110;
|
|
9
|
+
const PROC0_INTS0 = 0x120;
|
|
10
|
+
const PROC0_INTS3 = 0x12c;
|
|
11
|
+
class RPIO extends peripheral_js_1.BasePeripheral {
|
|
12
|
+
constructor(rp2040, name) {
|
|
13
|
+
super(rp2040, name);
|
|
14
|
+
}
|
|
15
|
+
getPinFromOffset(offset) {
|
|
16
|
+
const gpioIndex = offset >>> 3;
|
|
17
|
+
return {
|
|
18
|
+
gpio: this.rp2040.gpio[gpioIndex],
|
|
19
|
+
isCtrl: !!(offset & 0x4),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
readUint32(offset) {
|
|
23
|
+
if (offset <= GPIO_CTRL_LAST) {
|
|
24
|
+
const { gpio, isCtrl } = this.getPinFromOffset(offset);
|
|
25
|
+
return isCtrl ? gpio.ctrl : gpio.status;
|
|
26
|
+
}
|
|
27
|
+
if (offset >= INTR0 && offset <= PROC0_INTS3) {
|
|
28
|
+
const startIndex = (offset & 0xf) * 2;
|
|
29
|
+
const register = offset & ~0xf;
|
|
30
|
+
const { gpio } = this.rp2040;
|
|
31
|
+
let result = 0;
|
|
32
|
+
for (let index = 7; index >= 0; index--) {
|
|
33
|
+
const pin = gpio[index + startIndex];
|
|
34
|
+
if (!pin) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
result <<= 4;
|
|
38
|
+
switch (register) {
|
|
39
|
+
case INTR0:
|
|
40
|
+
result |= pin.irqStatus;
|
|
41
|
+
break;
|
|
42
|
+
case PROC0_INTE0:
|
|
43
|
+
result |= pin.irqEnableMask;
|
|
44
|
+
break;
|
|
45
|
+
case PROC0_INTF0:
|
|
46
|
+
result |= pin.irqForceMask;
|
|
47
|
+
break;
|
|
48
|
+
case PROC0_INTS0:
|
|
49
|
+
result |= (pin.irqStatus & pin.irqEnableMask) | pin.irqForceMask;
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
return super.readUint32(offset);
|
|
56
|
+
}
|
|
57
|
+
writeUint32(offset, value) {
|
|
58
|
+
if (offset <= GPIO_CTRL_LAST) {
|
|
59
|
+
const { gpio, isCtrl } = this.getPinFromOffset(offset);
|
|
60
|
+
if (isCtrl) {
|
|
61
|
+
gpio.ctrl = value;
|
|
62
|
+
gpio.checkForUpdates();
|
|
63
|
+
}
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (offset >= INTR0 && offset <= PROC0_INTS3) {
|
|
67
|
+
const startIndex = (offset & 0xf) * 2;
|
|
68
|
+
const register = offset & ~0xf;
|
|
69
|
+
const { gpio } = this.rp2040;
|
|
70
|
+
for (let index = 0; index < 8; index++) {
|
|
71
|
+
const pin = gpio[index + startIndex];
|
|
72
|
+
if (!pin) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const pinValue = (value >> (index * 4)) & 0xf;
|
|
76
|
+
const pinRawWriteValue = (this.rawWriteValue >> (index * 4)) & 0xf;
|
|
77
|
+
switch (register) {
|
|
78
|
+
case INTR0:
|
|
79
|
+
pin.updateIRQValue(pinRawWriteValue);
|
|
80
|
+
break;
|
|
81
|
+
case PROC0_INTE0:
|
|
82
|
+
if (pin.irqEnableMask !== pinValue) {
|
|
83
|
+
pin.irqEnableMask = pinValue;
|
|
84
|
+
this.rp2040.updateIOInterrupt();
|
|
85
|
+
}
|
|
86
|
+
break;
|
|
87
|
+
case PROC0_INTF0:
|
|
88
|
+
if (pin.irqForceMask !== pinValue) {
|
|
89
|
+
pin.irqForceMask = pinValue;
|
|
90
|
+
this.rp2040.updateIOInterrupt();
|
|
91
|
+
}
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
super.writeUint32(offset, value);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
exports.RPIO = RPIO;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { RP2040 } from '../rp2040';
|
|
2
|
-
import { BasePeripheral, Peripheral } from './peripheral';
|
|
3
|
-
export
|
|
4
|
-
export declare class RPPADS extends BasePeripheral implements Peripheral {
|
|
5
|
-
readonly bank: IIOBank;
|
|
6
|
-
voltageSelect: number;
|
|
7
|
-
private readonly firstPadRegister;
|
|
8
|
-
private readonly lastPadRegister;
|
|
9
|
-
constructor(rp2040: RP2040, name: string, bank: IIOBank);
|
|
10
|
-
getPinFromOffset(offset: number): import("
|
|
11
|
-
readUint32(offset: number): number;
|
|
12
|
-
writeUint32(offset: number, value: number): void;
|
|
13
|
-
}
|
|
1
|
+
import { RP2040 } from '../rp2040.js';
|
|
2
|
+
import { BasePeripheral, Peripheral } from './peripheral.js';
|
|
3
|
+
export type IIOBank = 'qspi' | 'bank0';
|
|
4
|
+
export declare class RPPADS extends BasePeripheral implements Peripheral {
|
|
5
|
+
readonly bank: IIOBank;
|
|
6
|
+
voltageSelect: number;
|
|
7
|
+
private readonly firstPadRegister;
|
|
8
|
+
private readonly lastPadRegister;
|
|
9
|
+
constructor(rp2040: RP2040, name: string, bank: IIOBank);
|
|
10
|
+
getPinFromOffset(offset: number): import("../gpio-pin.js").GPIOPin;
|
|
11
|
+
readUint32(offset: number): number;
|
|
12
|
+
writeUint32(offset: number, value: number): void;
|
|
13
|
+
}
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RPPADS = void 0;
|
|
4
|
-
const
|
|
5
|
-
const VOLTAGE_SELECT = 0;
|
|
6
|
-
const GPIO_FIRST = 0x4;
|
|
7
|
-
const GPIO_LAST = 0x78;
|
|
8
|
-
const QSPI_FIRST = 0x4;
|
|
9
|
-
const QSPI_LAST = 0x18;
|
|
10
|
-
class RPPADS extends
|
|
11
|
-
constructor(rp2040, name, bank) {
|
|
12
|
-
super(rp2040, name);
|
|
13
|
-
this.bank = bank;
|
|
14
|
-
this.voltageSelect = 0;
|
|
15
|
-
this.firstPadRegister = this.bank === 'qspi' ? QSPI_FIRST : GPIO_FIRST;
|
|
16
|
-
this.lastPadRegister = this.bank === 'qspi' ? QSPI_LAST : GPIO_LAST;
|
|
17
|
-
}
|
|
18
|
-
getPinFromOffset(offset) {
|
|
19
|
-
const gpioIndex = (offset - this.firstPadRegister) >>> 2;
|
|
20
|
-
if (this.bank === 'qspi') {
|
|
21
|
-
return this.rp2040.qspi[gpioIndex];
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
return this.rp2040.gpio[gpioIndex];
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
readUint32(offset) {
|
|
28
|
-
if (offset >= this.firstPadRegister && offset <= this.lastPadRegister) {
|
|
29
|
-
const gpio = this.getPinFromOffset(offset);
|
|
30
|
-
return gpio.padValue;
|
|
31
|
-
}
|
|
32
|
-
switch (offset) {
|
|
33
|
-
case VOLTAGE_SELECT:
|
|
34
|
-
return this.voltageSelect;
|
|
35
|
-
}
|
|
36
|
-
return super.readUint32(offset);
|
|
37
|
-
}
|
|
38
|
-
writeUint32(offset, value) {
|
|
39
|
-
if (offset >= this.firstPadRegister && offset <= this.lastPadRegister) {
|
|
40
|
-
const gpio = this.getPinFromOffset(offset);
|
|
41
|
-
const oldInputEnable = gpio.inputEnable;
|
|
42
|
-
gpio.padValue = value;
|
|
43
|
-
gpio.checkForUpdates();
|
|
44
|
-
if (oldInputEnable !== gpio.inputEnable) {
|
|
45
|
-
gpio.refreshInput();
|
|
46
|
-
}
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
switch (offset) {
|
|
50
|
-
case VOLTAGE_SELECT:
|
|
51
|
-
this.voltageSelect = value & 1;
|
|
52
|
-
break;
|
|
53
|
-
default:
|
|
54
|
-
super.writeUint32(offset, value);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
exports.RPPADS = RPPADS;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RPPADS = void 0;
|
|
4
|
+
const peripheral_js_1 = require("./peripheral.js");
|
|
5
|
+
const VOLTAGE_SELECT = 0;
|
|
6
|
+
const GPIO_FIRST = 0x4;
|
|
7
|
+
const GPIO_LAST = 0x78;
|
|
8
|
+
const QSPI_FIRST = 0x4;
|
|
9
|
+
const QSPI_LAST = 0x18;
|
|
10
|
+
class RPPADS extends peripheral_js_1.BasePeripheral {
|
|
11
|
+
constructor(rp2040, name, bank) {
|
|
12
|
+
super(rp2040, name);
|
|
13
|
+
this.bank = bank;
|
|
14
|
+
this.voltageSelect = 0;
|
|
15
|
+
this.firstPadRegister = this.bank === 'qspi' ? QSPI_FIRST : GPIO_FIRST;
|
|
16
|
+
this.lastPadRegister = this.bank === 'qspi' ? QSPI_LAST : GPIO_LAST;
|
|
17
|
+
}
|
|
18
|
+
getPinFromOffset(offset) {
|
|
19
|
+
const gpioIndex = (offset - this.firstPadRegister) >>> 2;
|
|
20
|
+
if (this.bank === 'qspi') {
|
|
21
|
+
return this.rp2040.qspi[gpioIndex];
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
return this.rp2040.gpio[gpioIndex];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
readUint32(offset) {
|
|
28
|
+
if (offset >= this.firstPadRegister && offset <= this.lastPadRegister) {
|
|
29
|
+
const gpio = this.getPinFromOffset(offset);
|
|
30
|
+
return gpio.padValue;
|
|
31
|
+
}
|
|
32
|
+
switch (offset) {
|
|
33
|
+
case VOLTAGE_SELECT:
|
|
34
|
+
return this.voltageSelect;
|
|
35
|
+
}
|
|
36
|
+
return super.readUint32(offset);
|
|
37
|
+
}
|
|
38
|
+
writeUint32(offset, value) {
|
|
39
|
+
if (offset >= this.firstPadRegister && offset <= this.lastPadRegister) {
|
|
40
|
+
const gpio = this.getPinFromOffset(offset);
|
|
41
|
+
const oldInputEnable = gpio.inputEnable;
|
|
42
|
+
gpio.padValue = value;
|
|
43
|
+
gpio.checkForUpdates();
|
|
44
|
+
if (oldInputEnable !== gpio.inputEnable) {
|
|
45
|
+
gpio.refreshInput();
|
|
46
|
+
}
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
switch (offset) {
|
|
50
|
+
case VOLTAGE_SELECT:
|
|
51
|
+
this.voltageSelect = value & 1;
|
|
52
|
+
break;
|
|
53
|
+
default:
|
|
54
|
+
super.writeUint32(offset, value);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.RPPADS = RPPADS;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { RP2040 } from '../rp2040';
|
|
2
|
-
export declare function atomicUpdate(currentValue: number, atomicType: number, newValue: number): number;
|
|
3
|
-
export interface Peripheral {
|
|
4
|
-
readUint32(offset: number): number;
|
|
5
|
-
writeUint32(offset: number, value: number): void;
|
|
6
|
-
writeUint32Atomic(offset: number, value: number, atomicType: number): void;
|
|
7
|
-
}
|
|
8
|
-
export declare class BasePeripheral implements Peripheral {
|
|
9
|
-
protected rp2040: RP2040;
|
|
10
|
-
readonly name: string;
|
|
11
|
-
protected rawWriteValue: number;
|
|
12
|
-
constructor(rp2040: RP2040, name: string);
|
|
13
|
-
readUint32(offset: number): number;
|
|
14
|
-
writeUint32(offset: number, value: number): void;
|
|
15
|
-
writeUint32Atomic(offset: number, value: number, atomicType: number): void;
|
|
16
|
-
debug(msg: string): void;
|
|
17
|
-
info(msg: string): void;
|
|
18
|
-
warn(msg: string): void;
|
|
19
|
-
error(msg: string): void;
|
|
20
|
-
}
|
|
21
|
-
export declare class UnimplementedPeripheral extends BasePeripheral {
|
|
22
|
-
}
|
|
1
|
+
import { RP2040 } from '../rp2040.js';
|
|
2
|
+
export declare function atomicUpdate(currentValue: number, atomicType: number, newValue: number): number;
|
|
3
|
+
export interface Peripheral {
|
|
4
|
+
readUint32(offset: number): number;
|
|
5
|
+
writeUint32(offset: number, value: number): void;
|
|
6
|
+
writeUint32Atomic(offset: number, value: number, atomicType: number): void;
|
|
7
|
+
}
|
|
8
|
+
export declare class BasePeripheral implements Peripheral {
|
|
9
|
+
protected rp2040: RP2040;
|
|
10
|
+
readonly name: string;
|
|
11
|
+
protected rawWriteValue: number;
|
|
12
|
+
constructor(rp2040: RP2040, name: string);
|
|
13
|
+
readUint32(offset: number): number;
|
|
14
|
+
writeUint32(offset: number, value: number): void;
|
|
15
|
+
writeUint32Atomic(offset: number, value: number, atomicType: number): void;
|
|
16
|
+
debug(msg: string): void;
|
|
17
|
+
info(msg: string): void;
|
|
18
|
+
warn(msg: string): void;
|
|
19
|
+
error(msg: string): void;
|
|
20
|
+
}
|
|
21
|
+
export declare class UnimplementedPeripheral extends BasePeripheral {
|
|
22
|
+
}
|
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UnimplementedPeripheral = exports.BasePeripheral = exports.atomicUpdate = void 0;
|
|
4
|
-
const ATOMIC_NORMAL = 0;
|
|
5
|
-
const ATOMIC_XOR = 1;
|
|
6
|
-
const ATOMIC_SET = 2;
|
|
7
|
-
const ATOMIC_CLEAR = 3;
|
|
8
|
-
function atomicUpdate(currentValue, atomicType, newValue) {
|
|
9
|
-
switch (atomicType) {
|
|
10
|
-
case ATOMIC_XOR:
|
|
11
|
-
return currentValue ^ newValue;
|
|
12
|
-
case ATOMIC_SET:
|
|
13
|
-
return currentValue | newValue;
|
|
14
|
-
case ATOMIC_CLEAR:
|
|
15
|
-
return currentValue & ~newValue;
|
|
16
|
-
default:
|
|
17
|
-
console.warn('Atomic update called with invalid writeType', atomicType);
|
|
18
|
-
return newValue;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.atomicUpdate = atomicUpdate;
|
|
22
|
-
class BasePeripheral {
|
|
23
|
-
constructor(rp2040, name) {
|
|
24
|
-
this.rp2040 = rp2040;
|
|
25
|
-
this.name = name;
|
|
26
|
-
this.rawWriteValue = 0;
|
|
27
|
-
}
|
|
28
|
-
readUint32(offset) {
|
|
29
|
-
this.warn(`Unimplemented peripheral read from ${offset.toString(16)}`);
|
|
30
|
-
if (offset > 0x1000) {
|
|
31
|
-
this.warn('Unimplemented read from peripheral in the atomic operation region');
|
|
32
|
-
}
|
|
33
|
-
return 0xffffffff;
|
|
34
|
-
}
|
|
35
|
-
writeUint32(offset, value) {
|
|
36
|
-
this.warn(`Unimplemented peripheral write to ${offset.toString(16)}: ${value}`);
|
|
37
|
-
}
|
|
38
|
-
writeUint32Atomic(offset, value, atomicType) {
|
|
39
|
-
this.rawWriteValue = value;
|
|
40
|
-
const newValue = atomicType != ATOMIC_NORMAL
|
|
41
|
-
? atomicUpdate(this.readUint32(offset), atomicType, value)
|
|
42
|
-
: value;
|
|
43
|
-
this.writeUint32(offset, newValue);
|
|
44
|
-
}
|
|
45
|
-
debug(msg) {
|
|
46
|
-
this.rp2040.logger.debug(this.name, msg);
|
|
47
|
-
}
|
|
48
|
-
info(msg) {
|
|
49
|
-
this.rp2040.logger.info(this.name, msg);
|
|
50
|
-
}
|
|
51
|
-
warn(msg) {
|
|
52
|
-
this.rp2040.logger.warn(this.name, msg);
|
|
53
|
-
}
|
|
54
|
-
error(msg) {
|
|
55
|
-
this.rp2040.logger.error(this.name, msg);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
exports.BasePeripheral = BasePeripheral;
|
|
59
|
-
class UnimplementedPeripheral extends BasePeripheral {
|
|
60
|
-
}
|
|
61
|
-
exports.UnimplementedPeripheral = UnimplementedPeripheral;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnimplementedPeripheral = exports.BasePeripheral = exports.atomicUpdate = void 0;
|
|
4
|
+
const ATOMIC_NORMAL = 0;
|
|
5
|
+
const ATOMIC_XOR = 1;
|
|
6
|
+
const ATOMIC_SET = 2;
|
|
7
|
+
const ATOMIC_CLEAR = 3;
|
|
8
|
+
function atomicUpdate(currentValue, atomicType, newValue) {
|
|
9
|
+
switch (atomicType) {
|
|
10
|
+
case ATOMIC_XOR:
|
|
11
|
+
return currentValue ^ newValue;
|
|
12
|
+
case ATOMIC_SET:
|
|
13
|
+
return currentValue | newValue;
|
|
14
|
+
case ATOMIC_CLEAR:
|
|
15
|
+
return currentValue & ~newValue;
|
|
16
|
+
default:
|
|
17
|
+
console.warn('Atomic update called with invalid writeType', atomicType);
|
|
18
|
+
return newValue;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.atomicUpdate = atomicUpdate;
|
|
22
|
+
class BasePeripheral {
|
|
23
|
+
constructor(rp2040, name) {
|
|
24
|
+
this.rp2040 = rp2040;
|
|
25
|
+
this.name = name;
|
|
26
|
+
this.rawWriteValue = 0;
|
|
27
|
+
}
|
|
28
|
+
readUint32(offset) {
|
|
29
|
+
this.warn(`Unimplemented peripheral read from ${offset.toString(16)}`);
|
|
30
|
+
if (offset > 0x1000) {
|
|
31
|
+
this.warn('Unimplemented read from peripheral in the atomic operation region');
|
|
32
|
+
}
|
|
33
|
+
return 0xffffffff;
|
|
34
|
+
}
|
|
35
|
+
writeUint32(offset, value) {
|
|
36
|
+
this.warn(`Unimplemented peripheral write to ${offset.toString(16)}: ${value}`);
|
|
37
|
+
}
|
|
38
|
+
writeUint32Atomic(offset, value, atomicType) {
|
|
39
|
+
this.rawWriteValue = value;
|
|
40
|
+
const newValue = atomicType != ATOMIC_NORMAL
|
|
41
|
+
? atomicUpdate(this.readUint32(offset), atomicType, value)
|
|
42
|
+
: value;
|
|
43
|
+
this.writeUint32(offset, newValue);
|
|
44
|
+
}
|
|
45
|
+
debug(msg) {
|
|
46
|
+
this.rp2040.logger.debug(this.name, msg);
|
|
47
|
+
}
|
|
48
|
+
info(msg) {
|
|
49
|
+
this.rp2040.logger.info(this.name, msg);
|
|
50
|
+
}
|
|
51
|
+
warn(msg) {
|
|
52
|
+
this.rp2040.logger.warn(this.name, msg);
|
|
53
|
+
}
|
|
54
|
+
error(msg) {
|
|
55
|
+
this.rp2040.logger.error(this.name, msg);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.BasePeripheral = BasePeripheral;
|
|
59
|
+
class UnimplementedPeripheral extends BasePeripheral {
|
|
60
|
+
}
|
|
61
|
+
exports.UnimplementedPeripheral = UnimplementedPeripheral;
|