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
package/dist/esm/interpolator.js
CHANGED
|
@@ -1,145 +1,145 @@
|
|
|
1
|
-
import { s32, u32 } from './utils/bit';
|
|
2
|
-
export class InterpolatorConfig {
|
|
3
|
-
constructor(value) {
|
|
4
|
-
this.shift = 0;
|
|
5
|
-
this.maskLSB = 0;
|
|
6
|
-
this.maskMSB = 0;
|
|
7
|
-
this.signed = false;
|
|
8
|
-
this.crossInput = false;
|
|
9
|
-
this.crossResult = false;
|
|
10
|
-
this.addRaw = false;
|
|
11
|
-
this.forceMSB = 0;
|
|
12
|
-
this.blend = false;
|
|
13
|
-
this.clamp = false;
|
|
14
|
-
this.overf0 = false;
|
|
15
|
-
this.overf1 = false;
|
|
16
|
-
this.overf = false;
|
|
17
|
-
this.shift = (value >>> 0) & 0b11111;
|
|
18
|
-
this.maskLSB = (value >>> 5) & 0b11111;
|
|
19
|
-
this.maskMSB = (value >>> 10) & 0b11111;
|
|
20
|
-
this.signed = Boolean((value >>> 15) & 1);
|
|
21
|
-
this.crossInput = Boolean((value >>> 16) & 1);
|
|
22
|
-
this.crossResult = Boolean((value >>> 17) & 1);
|
|
23
|
-
this.addRaw = Boolean((value >>> 18) & 1);
|
|
24
|
-
this.forceMSB = (value >>> 19) & 0b11;
|
|
25
|
-
this.blend = Boolean((value >>> 21) & 1);
|
|
26
|
-
this.clamp = Boolean((value >>> 22) & 1);
|
|
27
|
-
this.overf0 = Boolean((value >>> 23) & 1);
|
|
28
|
-
this.overf1 = Boolean((value >>> 24) & 1);
|
|
29
|
-
this.overf = Boolean((value >>> 25) & 1);
|
|
30
|
-
}
|
|
31
|
-
toUint32() {
|
|
32
|
-
return (((this.shift & 0b11111) << 0) |
|
|
33
|
-
((this.maskLSB & 0b11111) << 5) |
|
|
34
|
-
((this.maskMSB & 0b11111) << 10) |
|
|
35
|
-
((Number(this.signed) & 1) << 15) |
|
|
36
|
-
((Number(this.crossInput) & 1) << 16) |
|
|
37
|
-
((Number(this.crossResult) & 1) << 17) |
|
|
38
|
-
((Number(this.addRaw) & 1) << 18) |
|
|
39
|
-
((this.forceMSB & 0b11) << 19) |
|
|
40
|
-
((Number(this.blend) & 1) << 21) |
|
|
41
|
-
((Number(this.clamp) & 1) << 22) |
|
|
42
|
-
((Number(this.overf0) & 1) << 23) |
|
|
43
|
-
((Number(this.overf1) & 1) << 24) |
|
|
44
|
-
((Number(this.overf) & 1) << 25));
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
export class Interpolator {
|
|
48
|
-
constructor(index) {
|
|
49
|
-
this.index = index;
|
|
50
|
-
this.accum0 = 0;
|
|
51
|
-
this.accum1 = 0;
|
|
52
|
-
this.base0 = 0;
|
|
53
|
-
this.base1 = 0;
|
|
54
|
-
this.base2 = 0;
|
|
55
|
-
this.ctrl0 = 0;
|
|
56
|
-
this.ctrl1 = 0;
|
|
57
|
-
this.result0 = 0;
|
|
58
|
-
this.result1 = 0;
|
|
59
|
-
this.result2 = 0;
|
|
60
|
-
this.smresult0 = 0;
|
|
61
|
-
this.smresult1 = 0;
|
|
62
|
-
this.update();
|
|
63
|
-
}
|
|
64
|
-
update() {
|
|
65
|
-
const N = this.index;
|
|
66
|
-
const ctrl0 = new InterpolatorConfig(this.ctrl0);
|
|
67
|
-
const ctrl1 = new InterpolatorConfig(this.ctrl1);
|
|
68
|
-
const do_clamp = ctrl0.clamp && N == 1;
|
|
69
|
-
const do_blend = ctrl0.blend && N == 0;
|
|
70
|
-
ctrl0.clamp = do_clamp;
|
|
71
|
-
ctrl0.blend = do_blend;
|
|
72
|
-
ctrl1.clamp = false;
|
|
73
|
-
ctrl1.blend = false;
|
|
74
|
-
ctrl1.overf0 = false;
|
|
75
|
-
ctrl1.overf1 = false;
|
|
76
|
-
ctrl1.overf = false;
|
|
77
|
-
const input0 = s32(ctrl0.crossInput ? this.accum1 : this.accum0);
|
|
78
|
-
const input1 = s32(ctrl1.crossInput ? this.accum0 : this.accum1);
|
|
79
|
-
const msbmask0 = ctrl0.maskMSB == 31 ? 0xffffffff : (1 << (ctrl0.maskMSB + 1)) - 1;
|
|
80
|
-
const msbmask1 = ctrl1.maskMSB == 31 ? 0xffffffff : (1 << (ctrl1.maskMSB + 1)) - 1;
|
|
81
|
-
const mask0 = msbmask0 & ~((1 << ctrl0.maskLSB) - 1);
|
|
82
|
-
const mask1 = msbmask1 & ~((1 << ctrl1.maskLSB) - 1);
|
|
83
|
-
const uresult0 = (input0 >>> ctrl0.shift) & mask0;
|
|
84
|
-
const uresult1 = (input1 >>> ctrl1.shift) & mask1;
|
|
85
|
-
const overf0 = Boolean((input0 >>> ctrl0.shift) & ~msbmask0);
|
|
86
|
-
const overf1 = Boolean((input1 >>> ctrl1.shift) & ~msbmask1);
|
|
87
|
-
const overf = overf0 || overf1;
|
|
88
|
-
const sextmask0 = uresult0 & (1 << ctrl0.maskMSB) ? -1 << ctrl0.maskMSB : 0;
|
|
89
|
-
const sextmask1 = uresult1 & (1 << ctrl1.maskMSB) ? -1 << ctrl1.maskMSB : 0;
|
|
90
|
-
const sresult0 = uresult0 | sextmask0;
|
|
91
|
-
const sresult1 = uresult1 | sextmask1;
|
|
92
|
-
const result0 = ctrl0.signed ? sresult0 : uresult0;
|
|
93
|
-
const result1 = ctrl1.signed ? sresult1 : uresult1;
|
|
94
|
-
const addresult0 = this.base0 + (ctrl0.addRaw ? input0 : result0);
|
|
95
|
-
const addresult1 = this.base1 + (ctrl1.addRaw ? input1 : result1);
|
|
96
|
-
const addresult2 = this.base2 + result0 + (do_blend ? 0 : result1);
|
|
97
|
-
const uclamp0 = u32(result0) < u32(this.base0)
|
|
98
|
-
? this.base0
|
|
99
|
-
: u32(result0) > u32(this.base1)
|
|
100
|
-
? this.base1
|
|
101
|
-
: result0;
|
|
102
|
-
const sclamp0 = s32(result0) < s32(this.base0)
|
|
103
|
-
? this.base0
|
|
104
|
-
: s32(result0) > s32(this.base1)
|
|
105
|
-
? this.base1
|
|
106
|
-
: result0;
|
|
107
|
-
const clamp0 = ctrl0.signed ? sclamp0 : uclamp0;
|
|
108
|
-
const alpha1 = result1 & 0xff;
|
|
109
|
-
const ublend1 = u32(this.base0) + (Math.floor((alpha1 * (u32(this.base1) - u32(this.base0))) / 256) | 0);
|
|
110
|
-
const sblend1 = s32(this.base0) + (Math.floor((alpha1 * (s32(this.base1) - s32(this.base0))) / 256) | 0);
|
|
111
|
-
const blend1 = ctrl1.signed ? sblend1 : ublend1;
|
|
112
|
-
this.smresult0 = u32(result0);
|
|
113
|
-
this.smresult1 = u32(result1);
|
|
114
|
-
this.result0 = u32(do_blend ? alpha1 : (do_clamp ? clamp0 : addresult0) | (ctrl0.forceMSB << 28));
|
|
115
|
-
this.result1 = u32((do_blend ? blend1 : addresult1) | (ctrl0.forceMSB << 28));
|
|
116
|
-
this.result2 = u32(addresult2);
|
|
117
|
-
ctrl0.overf0 = overf0;
|
|
118
|
-
ctrl0.overf1 = overf1;
|
|
119
|
-
ctrl0.overf = overf;
|
|
120
|
-
this.ctrl0 = ctrl0.toUint32();
|
|
121
|
-
this.ctrl1 = ctrl1.toUint32();
|
|
122
|
-
}
|
|
123
|
-
writeback() {
|
|
124
|
-
const ctrl0 = new InterpolatorConfig(this.ctrl0);
|
|
125
|
-
const ctrl1 = new InterpolatorConfig(this.ctrl1);
|
|
126
|
-
this.accum0 = u32(ctrl0.crossResult ? this.result1 : this.result0);
|
|
127
|
-
this.accum1 = u32(ctrl1.crossResult ? this.result0 : this.result1);
|
|
128
|
-
this.update();
|
|
129
|
-
}
|
|
130
|
-
setBase01(value) {
|
|
131
|
-
const N = this.index;
|
|
132
|
-
const ctrl0 = new InterpolatorConfig(this.ctrl0);
|
|
133
|
-
const ctrl1 = new InterpolatorConfig(this.ctrl1);
|
|
134
|
-
const do_blend = ctrl0.blend && N == 0;
|
|
135
|
-
const input0 = value & 0xffff;
|
|
136
|
-
const input1 = (value >>> 16) & 0xffff;
|
|
137
|
-
const sextmask0 = input0 & (1 << 15) ? -1 << 15 : 0;
|
|
138
|
-
const sextmask1 = input1 & (1 << 15) ? -1 << 15 : 0;
|
|
139
|
-
const base0 = (do_blend ? ctrl1.signed : ctrl0.signed) ? input0 | sextmask0 : input0;
|
|
140
|
-
const base1 = ctrl1.signed ? input1 | sextmask1 : input1;
|
|
141
|
-
this.base0 = u32(base0);
|
|
142
|
-
this.base1 = u32(base1);
|
|
143
|
-
this.update();
|
|
144
|
-
}
|
|
145
|
-
}
|
|
1
|
+
import { s32, u32 } from './utils/bit.js';
|
|
2
|
+
export class InterpolatorConfig {
|
|
3
|
+
constructor(value) {
|
|
4
|
+
this.shift = 0;
|
|
5
|
+
this.maskLSB = 0;
|
|
6
|
+
this.maskMSB = 0;
|
|
7
|
+
this.signed = false;
|
|
8
|
+
this.crossInput = false;
|
|
9
|
+
this.crossResult = false;
|
|
10
|
+
this.addRaw = false;
|
|
11
|
+
this.forceMSB = 0;
|
|
12
|
+
this.blend = false;
|
|
13
|
+
this.clamp = false;
|
|
14
|
+
this.overf0 = false;
|
|
15
|
+
this.overf1 = false;
|
|
16
|
+
this.overf = false;
|
|
17
|
+
this.shift = (value >>> 0) & 0b11111;
|
|
18
|
+
this.maskLSB = (value >>> 5) & 0b11111;
|
|
19
|
+
this.maskMSB = (value >>> 10) & 0b11111;
|
|
20
|
+
this.signed = Boolean((value >>> 15) & 1);
|
|
21
|
+
this.crossInput = Boolean((value >>> 16) & 1);
|
|
22
|
+
this.crossResult = Boolean((value >>> 17) & 1);
|
|
23
|
+
this.addRaw = Boolean((value >>> 18) & 1);
|
|
24
|
+
this.forceMSB = (value >>> 19) & 0b11;
|
|
25
|
+
this.blend = Boolean((value >>> 21) & 1);
|
|
26
|
+
this.clamp = Boolean((value >>> 22) & 1);
|
|
27
|
+
this.overf0 = Boolean((value >>> 23) & 1);
|
|
28
|
+
this.overf1 = Boolean((value >>> 24) & 1);
|
|
29
|
+
this.overf = Boolean((value >>> 25) & 1);
|
|
30
|
+
}
|
|
31
|
+
toUint32() {
|
|
32
|
+
return (((this.shift & 0b11111) << 0) |
|
|
33
|
+
((this.maskLSB & 0b11111) << 5) |
|
|
34
|
+
((this.maskMSB & 0b11111) << 10) |
|
|
35
|
+
((Number(this.signed) & 1) << 15) |
|
|
36
|
+
((Number(this.crossInput) & 1) << 16) |
|
|
37
|
+
((Number(this.crossResult) & 1) << 17) |
|
|
38
|
+
((Number(this.addRaw) & 1) << 18) |
|
|
39
|
+
((this.forceMSB & 0b11) << 19) |
|
|
40
|
+
((Number(this.blend) & 1) << 21) |
|
|
41
|
+
((Number(this.clamp) & 1) << 22) |
|
|
42
|
+
((Number(this.overf0) & 1) << 23) |
|
|
43
|
+
((Number(this.overf1) & 1) << 24) |
|
|
44
|
+
((Number(this.overf) & 1) << 25));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export class Interpolator {
|
|
48
|
+
constructor(index) {
|
|
49
|
+
this.index = index;
|
|
50
|
+
this.accum0 = 0;
|
|
51
|
+
this.accum1 = 0;
|
|
52
|
+
this.base0 = 0;
|
|
53
|
+
this.base1 = 0;
|
|
54
|
+
this.base2 = 0;
|
|
55
|
+
this.ctrl0 = 0;
|
|
56
|
+
this.ctrl1 = 0;
|
|
57
|
+
this.result0 = 0;
|
|
58
|
+
this.result1 = 0;
|
|
59
|
+
this.result2 = 0;
|
|
60
|
+
this.smresult0 = 0;
|
|
61
|
+
this.smresult1 = 0;
|
|
62
|
+
this.update();
|
|
63
|
+
}
|
|
64
|
+
update() {
|
|
65
|
+
const N = this.index;
|
|
66
|
+
const ctrl0 = new InterpolatorConfig(this.ctrl0);
|
|
67
|
+
const ctrl1 = new InterpolatorConfig(this.ctrl1);
|
|
68
|
+
const do_clamp = ctrl0.clamp && N == 1;
|
|
69
|
+
const do_blend = ctrl0.blend && N == 0;
|
|
70
|
+
ctrl0.clamp = do_clamp;
|
|
71
|
+
ctrl0.blend = do_blend;
|
|
72
|
+
ctrl1.clamp = false;
|
|
73
|
+
ctrl1.blend = false;
|
|
74
|
+
ctrl1.overf0 = false;
|
|
75
|
+
ctrl1.overf1 = false;
|
|
76
|
+
ctrl1.overf = false;
|
|
77
|
+
const input0 = s32(ctrl0.crossInput ? this.accum1 : this.accum0);
|
|
78
|
+
const input1 = s32(ctrl1.crossInput ? this.accum0 : this.accum1);
|
|
79
|
+
const msbmask0 = ctrl0.maskMSB == 31 ? 0xffffffff : (1 << (ctrl0.maskMSB + 1)) - 1;
|
|
80
|
+
const msbmask1 = ctrl1.maskMSB == 31 ? 0xffffffff : (1 << (ctrl1.maskMSB + 1)) - 1;
|
|
81
|
+
const mask0 = msbmask0 & ~((1 << ctrl0.maskLSB) - 1);
|
|
82
|
+
const mask1 = msbmask1 & ~((1 << ctrl1.maskLSB) - 1);
|
|
83
|
+
const uresult0 = (input0 >>> ctrl0.shift) & mask0;
|
|
84
|
+
const uresult1 = (input1 >>> ctrl1.shift) & mask1;
|
|
85
|
+
const overf0 = Boolean((input0 >>> ctrl0.shift) & ~msbmask0);
|
|
86
|
+
const overf1 = Boolean((input1 >>> ctrl1.shift) & ~msbmask1);
|
|
87
|
+
const overf = overf0 || overf1;
|
|
88
|
+
const sextmask0 = uresult0 & (1 << ctrl0.maskMSB) ? -1 << ctrl0.maskMSB : 0;
|
|
89
|
+
const sextmask1 = uresult1 & (1 << ctrl1.maskMSB) ? -1 << ctrl1.maskMSB : 0;
|
|
90
|
+
const sresult0 = uresult0 | sextmask0;
|
|
91
|
+
const sresult1 = uresult1 | sextmask1;
|
|
92
|
+
const result0 = ctrl0.signed ? sresult0 : uresult0;
|
|
93
|
+
const result1 = ctrl1.signed ? sresult1 : uresult1;
|
|
94
|
+
const addresult0 = this.base0 + (ctrl0.addRaw ? input0 : result0);
|
|
95
|
+
const addresult1 = this.base1 + (ctrl1.addRaw ? input1 : result1);
|
|
96
|
+
const addresult2 = this.base2 + result0 + (do_blend ? 0 : result1);
|
|
97
|
+
const uclamp0 = u32(result0) < u32(this.base0)
|
|
98
|
+
? this.base0
|
|
99
|
+
: u32(result0) > u32(this.base1)
|
|
100
|
+
? this.base1
|
|
101
|
+
: result0;
|
|
102
|
+
const sclamp0 = s32(result0) < s32(this.base0)
|
|
103
|
+
? this.base0
|
|
104
|
+
: s32(result0) > s32(this.base1)
|
|
105
|
+
? this.base1
|
|
106
|
+
: result0;
|
|
107
|
+
const clamp0 = ctrl0.signed ? sclamp0 : uclamp0;
|
|
108
|
+
const alpha1 = result1 & 0xff;
|
|
109
|
+
const ublend1 = u32(this.base0) + (Math.floor((alpha1 * (u32(this.base1) - u32(this.base0))) / 256) | 0);
|
|
110
|
+
const sblend1 = s32(this.base0) + (Math.floor((alpha1 * (s32(this.base1) - s32(this.base0))) / 256) | 0);
|
|
111
|
+
const blend1 = ctrl1.signed ? sblend1 : ublend1;
|
|
112
|
+
this.smresult0 = u32(result0);
|
|
113
|
+
this.smresult1 = u32(result1);
|
|
114
|
+
this.result0 = u32(do_blend ? alpha1 : (do_clamp ? clamp0 : addresult0) | (ctrl0.forceMSB << 28));
|
|
115
|
+
this.result1 = u32((do_blend ? blend1 : addresult1) | (ctrl0.forceMSB << 28));
|
|
116
|
+
this.result2 = u32(addresult2);
|
|
117
|
+
ctrl0.overf0 = overf0;
|
|
118
|
+
ctrl0.overf1 = overf1;
|
|
119
|
+
ctrl0.overf = overf;
|
|
120
|
+
this.ctrl0 = ctrl0.toUint32();
|
|
121
|
+
this.ctrl1 = ctrl1.toUint32();
|
|
122
|
+
}
|
|
123
|
+
writeback() {
|
|
124
|
+
const ctrl0 = new InterpolatorConfig(this.ctrl0);
|
|
125
|
+
const ctrl1 = new InterpolatorConfig(this.ctrl1);
|
|
126
|
+
this.accum0 = u32(ctrl0.crossResult ? this.result1 : this.result0);
|
|
127
|
+
this.accum1 = u32(ctrl1.crossResult ? this.result0 : this.result1);
|
|
128
|
+
this.update();
|
|
129
|
+
}
|
|
130
|
+
setBase01(value) {
|
|
131
|
+
const N = this.index;
|
|
132
|
+
const ctrl0 = new InterpolatorConfig(this.ctrl0);
|
|
133
|
+
const ctrl1 = new InterpolatorConfig(this.ctrl1);
|
|
134
|
+
const do_blend = ctrl0.blend && N == 0;
|
|
135
|
+
const input0 = value & 0xffff;
|
|
136
|
+
const input1 = (value >>> 16) & 0xffff;
|
|
137
|
+
const sextmask0 = input0 & (1 << 15) ? -1 << 15 : 0;
|
|
138
|
+
const sextmask1 = input1 & (1 << 15) ? -1 << 15 : 0;
|
|
139
|
+
const base0 = (do_blend ? ctrl1.signed : ctrl0.signed) ? input0 | sextmask0 : input0;
|
|
140
|
+
const base1 = ctrl1.signed ? input1 | sextmask1 : input1;
|
|
141
|
+
this.base0 = u32(base0);
|
|
142
|
+
this.base1 = u32(base1);
|
|
143
|
+
this.update();
|
|
144
|
+
}
|
|
145
|
+
}
|
package/dist/esm/irq.d.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
export declare enum IRQ {
|
|
2
|
-
TIMER_0 = 0,
|
|
3
|
-
TIMER_1 = 1,
|
|
4
|
-
TIMER_2 = 2,
|
|
5
|
-
TIMER_3 = 3,
|
|
6
|
-
PWM_WRAP = 4,
|
|
7
|
-
USBCTRL = 5,
|
|
8
|
-
XIP = 6,
|
|
9
|
-
PIO0_IRQ0 = 7,
|
|
10
|
-
PIO0_IRQ1 = 8,
|
|
11
|
-
PIO1_IRQ0 = 9,
|
|
12
|
-
PIO1_IRQ1 = 10,
|
|
13
|
-
DMA_IRQ0 = 11,
|
|
14
|
-
DMA_IRQ1 = 12,
|
|
15
|
-
IO_BANK0 = 13,
|
|
16
|
-
IO_QSPI = 14,
|
|
17
|
-
SIO_PROC0 = 15,
|
|
18
|
-
SIO_PROC1 = 16,
|
|
19
|
-
CLOCKS = 17,
|
|
20
|
-
SPI0 = 18,
|
|
21
|
-
SPI1 = 19,
|
|
22
|
-
UART0 = 20,
|
|
23
|
-
UART1 = 21,
|
|
24
|
-
ADC_FIFO = 22,
|
|
25
|
-
I2C0 = 23,
|
|
26
|
-
I2C1 = 24,
|
|
27
|
-
RTC = 25
|
|
28
|
-
}
|
|
29
|
-
export declare const MAX_HARDWARE_IRQ = IRQ.RTC;
|
|
1
|
+
export declare enum IRQ {
|
|
2
|
+
TIMER_0 = 0,
|
|
3
|
+
TIMER_1 = 1,
|
|
4
|
+
TIMER_2 = 2,
|
|
5
|
+
TIMER_3 = 3,
|
|
6
|
+
PWM_WRAP = 4,
|
|
7
|
+
USBCTRL = 5,
|
|
8
|
+
XIP = 6,
|
|
9
|
+
PIO0_IRQ0 = 7,
|
|
10
|
+
PIO0_IRQ1 = 8,
|
|
11
|
+
PIO1_IRQ0 = 9,
|
|
12
|
+
PIO1_IRQ1 = 10,
|
|
13
|
+
DMA_IRQ0 = 11,
|
|
14
|
+
DMA_IRQ1 = 12,
|
|
15
|
+
IO_BANK0 = 13,
|
|
16
|
+
IO_QSPI = 14,
|
|
17
|
+
SIO_PROC0 = 15,
|
|
18
|
+
SIO_PROC1 = 16,
|
|
19
|
+
CLOCKS = 17,
|
|
20
|
+
SPI0 = 18,
|
|
21
|
+
SPI1 = 19,
|
|
22
|
+
UART0 = 20,
|
|
23
|
+
UART1 = 21,
|
|
24
|
+
ADC_FIFO = 22,
|
|
25
|
+
I2C0 = 23,
|
|
26
|
+
I2C1 = 24,
|
|
27
|
+
RTC = 25
|
|
28
|
+
}
|
|
29
|
+
export declare const MAX_HARDWARE_IRQ = IRQ.RTC;
|
package/dist/esm/irq.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
export var IRQ;
|
|
2
|
-
(function (IRQ) {
|
|
3
|
-
IRQ[IRQ["TIMER_0"] = 0] = "TIMER_0";
|
|
4
|
-
IRQ[IRQ["TIMER_1"] = 1] = "TIMER_1";
|
|
5
|
-
IRQ[IRQ["TIMER_2"] = 2] = "TIMER_2";
|
|
6
|
-
IRQ[IRQ["TIMER_3"] = 3] = "TIMER_3";
|
|
7
|
-
IRQ[IRQ["PWM_WRAP"] = 4] = "PWM_WRAP";
|
|
8
|
-
IRQ[IRQ["USBCTRL"] = 5] = "USBCTRL";
|
|
9
|
-
IRQ[IRQ["XIP"] = 6] = "XIP";
|
|
10
|
-
IRQ[IRQ["PIO0_IRQ0"] = 7] = "PIO0_IRQ0";
|
|
11
|
-
IRQ[IRQ["PIO0_IRQ1"] = 8] = "PIO0_IRQ1";
|
|
12
|
-
IRQ[IRQ["PIO1_IRQ0"] = 9] = "PIO1_IRQ0";
|
|
13
|
-
IRQ[IRQ["PIO1_IRQ1"] = 10] = "PIO1_IRQ1";
|
|
14
|
-
IRQ[IRQ["DMA_IRQ0"] = 11] = "DMA_IRQ0";
|
|
15
|
-
IRQ[IRQ["DMA_IRQ1"] = 12] = "DMA_IRQ1";
|
|
16
|
-
IRQ[IRQ["IO_BANK0"] = 13] = "IO_BANK0";
|
|
17
|
-
IRQ[IRQ["IO_QSPI"] = 14] = "IO_QSPI";
|
|
18
|
-
IRQ[IRQ["SIO_PROC0"] = 15] = "SIO_PROC0";
|
|
19
|
-
IRQ[IRQ["SIO_PROC1"] = 16] = "SIO_PROC1";
|
|
20
|
-
IRQ[IRQ["CLOCKS"] = 17] = "CLOCKS";
|
|
21
|
-
IRQ[IRQ["SPI0"] = 18] = "SPI0";
|
|
22
|
-
IRQ[IRQ["SPI1"] = 19] = "SPI1";
|
|
23
|
-
IRQ[IRQ["UART0"] = 20] = "UART0";
|
|
24
|
-
IRQ[IRQ["UART1"] = 21] = "UART1";
|
|
25
|
-
IRQ[IRQ["ADC_FIFO"] = 22] = "ADC_FIFO";
|
|
26
|
-
IRQ[IRQ["I2C0"] = 23] = "I2C0";
|
|
27
|
-
IRQ[IRQ["I2C1"] = 24] = "I2C1";
|
|
28
|
-
IRQ[IRQ["RTC"] = 25] = "RTC";
|
|
29
|
-
})(IRQ || (IRQ = {}));
|
|
30
|
-
export const MAX_HARDWARE_IRQ = IRQ.RTC;
|
|
1
|
+
export var IRQ;
|
|
2
|
+
(function (IRQ) {
|
|
3
|
+
IRQ[IRQ["TIMER_0"] = 0] = "TIMER_0";
|
|
4
|
+
IRQ[IRQ["TIMER_1"] = 1] = "TIMER_1";
|
|
5
|
+
IRQ[IRQ["TIMER_2"] = 2] = "TIMER_2";
|
|
6
|
+
IRQ[IRQ["TIMER_3"] = 3] = "TIMER_3";
|
|
7
|
+
IRQ[IRQ["PWM_WRAP"] = 4] = "PWM_WRAP";
|
|
8
|
+
IRQ[IRQ["USBCTRL"] = 5] = "USBCTRL";
|
|
9
|
+
IRQ[IRQ["XIP"] = 6] = "XIP";
|
|
10
|
+
IRQ[IRQ["PIO0_IRQ0"] = 7] = "PIO0_IRQ0";
|
|
11
|
+
IRQ[IRQ["PIO0_IRQ1"] = 8] = "PIO0_IRQ1";
|
|
12
|
+
IRQ[IRQ["PIO1_IRQ0"] = 9] = "PIO1_IRQ0";
|
|
13
|
+
IRQ[IRQ["PIO1_IRQ1"] = 10] = "PIO1_IRQ1";
|
|
14
|
+
IRQ[IRQ["DMA_IRQ0"] = 11] = "DMA_IRQ0";
|
|
15
|
+
IRQ[IRQ["DMA_IRQ1"] = 12] = "DMA_IRQ1";
|
|
16
|
+
IRQ[IRQ["IO_BANK0"] = 13] = "IO_BANK0";
|
|
17
|
+
IRQ[IRQ["IO_QSPI"] = 14] = "IO_QSPI";
|
|
18
|
+
IRQ[IRQ["SIO_PROC0"] = 15] = "SIO_PROC0";
|
|
19
|
+
IRQ[IRQ["SIO_PROC1"] = 16] = "SIO_PROC1";
|
|
20
|
+
IRQ[IRQ["CLOCKS"] = 17] = "CLOCKS";
|
|
21
|
+
IRQ[IRQ["SPI0"] = 18] = "SPI0";
|
|
22
|
+
IRQ[IRQ["SPI1"] = 19] = "SPI1";
|
|
23
|
+
IRQ[IRQ["UART0"] = 20] = "UART0";
|
|
24
|
+
IRQ[IRQ["UART1"] = 21] = "UART1";
|
|
25
|
+
IRQ[IRQ["ADC_FIFO"] = 22] = "ADC_FIFO";
|
|
26
|
+
IRQ[IRQ["I2C0"] = 23] = "I2C0";
|
|
27
|
+
IRQ[IRQ["I2C1"] = 24] = "I2C1";
|
|
28
|
+
IRQ[IRQ["RTC"] = 25] = "RTC";
|
|
29
|
+
})(IRQ || (IRQ = {}));
|
|
30
|
+
export const MAX_HARDWARE_IRQ = IRQ.RTC;
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import { RP2040 } from '../rp2040';
|
|
2
|
-
import { FIFO } from '../utils/fifo';
|
|
3
|
-
import { DREQChannel } from './dma';
|
|
4
|
-
import { BasePeripheral, Peripheral } from './peripheral';
|
|
5
|
-
export declare class RPADC extends BasePeripheral implements Peripheral {
|
|
6
|
-
readonly numChannels = 5;
|
|
7
|
-
/** ADC resolution (in bits) */
|
|
8
|
-
readonly resolution = 12;
|
|
9
|
-
/** Time to read a single sample, in microseconds */
|
|
10
|
-
readonly sampleTime = 2;
|
|
11
|
-
/**
|
|
12
|
-
* ADC Channel values. Channels 0...3 are connected to GPIO 26...29, and channel 4 is connected to the built-in
|
|
13
|
-
* temperature sensor: T=27-(ADC_voltage-0.706)/0.001721.
|
|
14
|
-
*
|
|
15
|
-
* Changing the values will change the ADC reading, unless you override onADCRead() with a custom implementation.
|
|
16
|
-
*/
|
|
17
|
-
readonly channelValues: number[];
|
|
18
|
-
/**
|
|
19
|
-
* Invoked whenever the emulated code performs an ADC read.
|
|
20
|
-
*
|
|
21
|
-
* The default implementation reads the result from the `channelValues` array, and then calls
|
|
22
|
-
* completeADCRead() after `sampleTime` milliseconds.
|
|
23
|
-
*
|
|
24
|
-
* If you override the default implementation, make sure to call `completeADCRead()` after
|
|
25
|
-
* `sampleTime` milliseconds (or else the ADC read will never complete).
|
|
26
|
-
*/
|
|
27
|
-
onADCRead: (channel: number) => void;
|
|
28
|
-
readonly fifo: FIFO;
|
|
29
|
-
readonly dreq = DREQChannel.DREQ_ADC;
|
|
30
|
-
cs: number;
|
|
31
|
-
fcs: number;
|
|
32
|
-
clockDiv: number;
|
|
33
|
-
intEnable: number;
|
|
34
|
-
intForce: number;
|
|
35
|
-
result: number;
|
|
36
|
-
busy: boolean;
|
|
37
|
-
err: boolean;
|
|
38
|
-
get temperatueEnable(): number;
|
|
39
|
-
get enabled(): number;
|
|
40
|
-
get divider(): number;
|
|
41
|
-
get intRaw(): number;
|
|
42
|
-
get intStatus(): number;
|
|
43
|
-
private get activeChannel();
|
|
44
|
-
private set activeChannel(value);
|
|
45
|
-
constructor(rp2040: RP2040, name: string);
|
|
46
|
-
checkInterrupts(): void;
|
|
47
|
-
startADCRead(): void;
|
|
48
|
-
private updateDMA;
|
|
49
|
-
completeADCRead(value: number, error: boolean): void;
|
|
50
|
-
readUint32(offset: number): number;
|
|
51
|
-
writeUint32(offset: number, value: number): void;
|
|
52
|
-
}
|
|
1
|
+
import { RP2040 } from '../rp2040.js';
|
|
2
|
+
import { FIFO } from '../utils/fifo.js';
|
|
3
|
+
import { DREQChannel } from './dma.js';
|
|
4
|
+
import { BasePeripheral, Peripheral } from './peripheral.js';
|
|
5
|
+
export declare class RPADC extends BasePeripheral implements Peripheral {
|
|
6
|
+
readonly numChannels = 5;
|
|
7
|
+
/** ADC resolution (in bits) */
|
|
8
|
+
readonly resolution = 12;
|
|
9
|
+
/** Time to read a single sample, in microseconds */
|
|
10
|
+
readonly sampleTime = 2;
|
|
11
|
+
/**
|
|
12
|
+
* ADC Channel values. Channels 0...3 are connected to GPIO 26...29, and channel 4 is connected to the built-in
|
|
13
|
+
* temperature sensor: T=27-(ADC_voltage-0.706)/0.001721.
|
|
14
|
+
*
|
|
15
|
+
* Changing the values will change the ADC reading, unless you override onADCRead() with a custom implementation.
|
|
16
|
+
*/
|
|
17
|
+
readonly channelValues: number[];
|
|
18
|
+
/**
|
|
19
|
+
* Invoked whenever the emulated code performs an ADC read.
|
|
20
|
+
*
|
|
21
|
+
* The default implementation reads the result from the `channelValues` array, and then calls
|
|
22
|
+
* completeADCRead() after `sampleTime` milliseconds.
|
|
23
|
+
*
|
|
24
|
+
* If you override the default implementation, make sure to call `completeADCRead()` after
|
|
25
|
+
* `sampleTime` milliseconds (or else the ADC read will never complete).
|
|
26
|
+
*/
|
|
27
|
+
onADCRead: (channel: number) => void;
|
|
28
|
+
readonly fifo: FIFO;
|
|
29
|
+
readonly dreq = DREQChannel.DREQ_ADC;
|
|
30
|
+
cs: number;
|
|
31
|
+
fcs: number;
|
|
32
|
+
clockDiv: number;
|
|
33
|
+
intEnable: number;
|
|
34
|
+
intForce: number;
|
|
35
|
+
result: number;
|
|
36
|
+
busy: boolean;
|
|
37
|
+
err: boolean;
|
|
38
|
+
get temperatueEnable(): number;
|
|
39
|
+
get enabled(): number;
|
|
40
|
+
get divider(): number;
|
|
41
|
+
get intRaw(): number;
|
|
42
|
+
get intStatus(): number;
|
|
43
|
+
private get activeChannel();
|
|
44
|
+
private set activeChannel(value);
|
|
45
|
+
constructor(rp2040: RP2040, name: string);
|
|
46
|
+
checkInterrupts(): void;
|
|
47
|
+
startADCRead(): void;
|
|
48
|
+
private updateDMA;
|
|
49
|
+
completeADCRead(value: number, error: boolean): void;
|
|
50
|
+
readUint32(offset: number): number;
|
|
51
|
+
writeUint32(offset: number, value: number): void;
|
|
52
|
+
}
|