rp2040js 0.17.17 → 0.18.1
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/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 -38
- package/dist/cjs/peripherals/spi.js +240 -240
- 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 -31
- package/dist/cjs/peripherals/uart.js +132 -132
- 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 -361
- 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 -38
- package/dist/esm/peripherals/spi.js +236 -236
- 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 -31
- package/dist/esm/peripherals/uart.js +128 -128
- 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 -357
- 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 +38 -27
- package/dist/esm/package.json +0 -1
|
@@ -1,520 +1,520 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RPDMA = exports.RPDMAChannel = exports.DREQChannel = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
var DREQChannel;
|
|
7
|
-
(function (DREQChannel) {
|
|
8
|
-
DREQChannel[DREQChannel["DREQ_PIO0_TX0"] = 0] = "DREQ_PIO0_TX0";
|
|
9
|
-
DREQChannel[DREQChannel["DREQ_PIO0_TX1"] = 1] = "DREQ_PIO0_TX1";
|
|
10
|
-
DREQChannel[DREQChannel["DREQ_PIO0_TX2"] = 2] = "DREQ_PIO0_TX2";
|
|
11
|
-
DREQChannel[DREQChannel["DREQ_PIO0_TX3"] = 3] = "DREQ_PIO0_TX3";
|
|
12
|
-
DREQChannel[DREQChannel["DREQ_PIO0_RX0"] = 4] = "DREQ_PIO0_RX0";
|
|
13
|
-
DREQChannel[DREQChannel["DREQ_PIO0_RX1"] = 5] = "DREQ_PIO0_RX1";
|
|
14
|
-
DREQChannel[DREQChannel["DREQ_PIO0_RX2"] = 6] = "DREQ_PIO0_RX2";
|
|
15
|
-
DREQChannel[DREQChannel["DREQ_PIO0_RX3"] = 7] = "DREQ_PIO0_RX3";
|
|
16
|
-
DREQChannel[DREQChannel["DREQ_PIO1_TX0"] = 8] = "DREQ_PIO1_TX0";
|
|
17
|
-
DREQChannel[DREQChannel["DREQ_PIO1_TX1"] = 9] = "DREQ_PIO1_TX1";
|
|
18
|
-
DREQChannel[DREQChannel["DREQ_PIO1_TX2"] = 10] = "DREQ_PIO1_TX2";
|
|
19
|
-
DREQChannel[DREQChannel["DREQ_PIO1_TX3"] = 11] = "DREQ_PIO1_TX3";
|
|
20
|
-
DREQChannel[DREQChannel["DREQ_PIO1_RX0"] = 12] = "DREQ_PIO1_RX0";
|
|
21
|
-
DREQChannel[DREQChannel["DREQ_PIO1_RX1"] = 13] = "DREQ_PIO1_RX1";
|
|
22
|
-
DREQChannel[DREQChannel["DREQ_PIO1_RX2"] = 14] = "DREQ_PIO1_RX2";
|
|
23
|
-
DREQChannel[DREQChannel["DREQ_PIO1_RX3"] = 15] = "DREQ_PIO1_RX3";
|
|
24
|
-
DREQChannel[DREQChannel["DREQ_SPI0_TX"] = 16] = "DREQ_SPI0_TX";
|
|
25
|
-
DREQChannel[DREQChannel["DREQ_SPI0_RX"] = 17] = "DREQ_SPI0_RX";
|
|
26
|
-
DREQChannel[DREQChannel["DREQ_SPI1_TX"] = 18] = "DREQ_SPI1_TX";
|
|
27
|
-
DREQChannel[DREQChannel["DREQ_SPI1_RX"] = 19] = "DREQ_SPI1_RX";
|
|
28
|
-
DREQChannel[DREQChannel["DREQ_UART0_TX"] = 20] = "DREQ_UART0_TX";
|
|
29
|
-
DREQChannel[DREQChannel["DREQ_UART0_RX"] = 21] = "DREQ_UART0_RX";
|
|
30
|
-
DREQChannel[DREQChannel["DREQ_UART1_TX"] = 22] = "DREQ_UART1_TX";
|
|
31
|
-
DREQChannel[DREQChannel["DREQ_UART1_RX"] = 23] = "DREQ_UART1_RX";
|
|
32
|
-
DREQChannel[DREQChannel["DREQ_PWM_WRAP0"] = 24] = "DREQ_PWM_WRAP0";
|
|
33
|
-
DREQChannel[DREQChannel["DREQ_PWM_WRAP1"] = 25] = "DREQ_PWM_WRAP1";
|
|
34
|
-
DREQChannel[DREQChannel["DREQ_PWM_WRAP2"] = 26] = "DREQ_PWM_WRAP2";
|
|
35
|
-
DREQChannel[DREQChannel["DREQ_PWM_WRAP3"] = 27] = "DREQ_PWM_WRAP3";
|
|
36
|
-
DREQChannel[DREQChannel["DREQ_PWM_WRAP4"] = 28] = "DREQ_PWM_WRAP4";
|
|
37
|
-
DREQChannel[DREQChannel["DREQ_PWM_WRAP5"] = 29] = "DREQ_PWM_WRAP5";
|
|
38
|
-
DREQChannel[DREQChannel["DREQ_PWM_WRAP6"] = 30] = "DREQ_PWM_WRAP6";
|
|
39
|
-
DREQChannel[DREQChannel["DREQ_PWM_WRAP7"] = 31] = "DREQ_PWM_WRAP7";
|
|
40
|
-
DREQChannel[DREQChannel["DREQ_I2C0_TX"] = 32] = "DREQ_I2C0_TX";
|
|
41
|
-
DREQChannel[DREQChannel["DREQ_I2C0_RX"] = 33] = "DREQ_I2C0_RX";
|
|
42
|
-
DREQChannel[DREQChannel["DREQ_I2C1_TX"] = 34] = "DREQ_I2C1_TX";
|
|
43
|
-
DREQChannel[DREQChannel["DREQ_I2C1_RX"] = 35] = "DREQ_I2C1_RX";
|
|
44
|
-
DREQChannel[DREQChannel["DREQ_ADC"] = 36] = "DREQ_ADC";
|
|
45
|
-
DREQChannel[DREQChannel["DREQ_XIP_STREAM"] = 37] = "DREQ_XIP_STREAM";
|
|
46
|
-
DREQChannel[DREQChannel["DREQ_XIP_SSITX"] = 38] = "DREQ_XIP_SSITX";
|
|
47
|
-
DREQChannel[DREQChannel["DREQ_XIP_SSIRX"] = 39] = "DREQ_XIP_SSIRX";
|
|
48
|
-
DREQChannel[DREQChannel["DREQ_MAX"] = 40] = "DREQ_MAX";
|
|
49
|
-
})(DREQChannel
|
|
50
|
-
var TREQ;
|
|
51
|
-
(function (TREQ) {
|
|
52
|
-
TREQ[TREQ["Timer0"] = 59] = "Timer0";
|
|
53
|
-
TREQ[TREQ["Timer1"] = 60] = "Timer1";
|
|
54
|
-
TREQ[TREQ["Timer2"] = 61] = "Timer2";
|
|
55
|
-
TREQ[TREQ["Timer3"] = 62] = "Timer3";
|
|
56
|
-
TREQ[TREQ["Permanent"] = 63] = "Permanent";
|
|
57
|
-
})(TREQ || (TREQ = {}));
|
|
58
|
-
// Per-channel registers
|
|
59
|
-
const CHn_READ_ADDR = 0x000; // DMA Channel n Read Address pointer
|
|
60
|
-
const CHn_WRITE_ADDR = 0x004; // DMA Channel n Write Address pointer
|
|
61
|
-
const CHn_TRANS_COUNT = 0x008; // DMA Channel n Transfer Count
|
|
62
|
-
const CHn_CTRL_TRIG = 0x00c; // DMA Channel n Control and Status
|
|
63
|
-
const CHn_AL1_CTRL = 0x010; // Alias for channel n CTRL register
|
|
64
|
-
const CHn_AL1_READ_ADDR = 0x014; // Alias for channel n READ_ADDR register
|
|
65
|
-
const CHn_AL1_WRITE_ADDR = 0x018; // Alias for channel n WRITE_ADDR register
|
|
66
|
-
const CHn_AL1_TRANS_COUNT_TRIG = 0x01c; // Alias for channel n TRANS_COUNT register
|
|
67
|
-
const CHn_AL2_CTRL = 0x020; // Alias for channel n CTRL register
|
|
68
|
-
const CHn_AL2_TRANS_COUNT = 0x024; // Alias for channel n TRANS_COUNT register
|
|
69
|
-
const CHn_AL2_READ_ADDR = 0x028; // Alias for channel n READ_ADDR register
|
|
70
|
-
const CHn_AL2_WRITE_ADDR_TRIG = 0x02c; // Alias for channel n WRITE_ADDR register
|
|
71
|
-
const CHn_AL3_CTRL = 0x030; // Alias for channel n CTRL register
|
|
72
|
-
const CHn_AL3_WRITE_ADDR = 0x034; // Alias for channel n WRITE_ADDR register
|
|
73
|
-
const CHn_AL3_TRANS_COUNT = 0x038; // Alias for channel n TRANS_COUNT register
|
|
74
|
-
const CHn_AL3_READ_ADDR_TRIG = 0x03c; // Alias for channel n READ_ADDR register
|
|
75
|
-
const CHn_DBG_CTDREQ = 0x800;
|
|
76
|
-
const CHn_DBG_TCR = 0x804;
|
|
77
|
-
const CHANNEL_REGISTERS_SIZE = 12 * 0x40;
|
|
78
|
-
const CHANNEL_REGISTERS_MASK = 0x83f;
|
|
79
|
-
// General DMA registers
|
|
80
|
-
const INTR = 0x400; // Interrupt Status (raw)
|
|
81
|
-
const INTE0 = 0x404; // Interrupt Enables for IRQ 0
|
|
82
|
-
const INTF0 = 0x408; // Force Interrupts
|
|
83
|
-
const INTS0 = 0x40c; // Interrupt Status for IRQ 0
|
|
84
|
-
const INTE1 = 0x414; // Interrupt Enables for IRQ 1
|
|
85
|
-
const INTF1 = 0x418; // Force Interrupts for IRQ 1
|
|
86
|
-
const INTS1 = 0x41c; // Interrupt Status (masked) for IRQ 1
|
|
87
|
-
const TIMER0 = 0x420; // Pacing (X/Y) Fractional Timer
|
|
88
|
-
const TIMER1 = 0x424; // Pacing (X/Y) Fractional Timer
|
|
89
|
-
const TIMER2 = 0x428; // Pacing (X/Y) Fractional Timer
|
|
90
|
-
const TIMER3 = 0x42c; // Pacing (X/Y) Fractional Timer
|
|
91
|
-
const MULTI_CHAN_TRIGGER = 0x430; // Trigger one or more channels simultaneously
|
|
92
|
-
const SNIFF_CTRL = 0x434; // Sniffer Control
|
|
93
|
-
const SNIFF_DATA = 0x438; // Data accumulator for sniff hardware
|
|
94
|
-
const FIFO_LEVELS = 0x440; // Debug RAF, WAF, TDF levels
|
|
95
|
-
const CHAN_ABORT = 0x444; // Abort an in-progress transfer sequence on one or more channels
|
|
96
|
-
const N_CHANNELS = 0x448;
|
|
97
|
-
// CHn_CTRL_TRIG bits
|
|
98
|
-
const AHB_ERROR = 1 << 31;
|
|
99
|
-
const READ_ERROR = 1 << 30;
|
|
100
|
-
const WRITE_ERROR = 1 << 29;
|
|
101
|
-
const BUSY = 1 << 24;
|
|
102
|
-
const SNIFF_EN = 1 << 23;
|
|
103
|
-
const BSWAP = 1 << 22;
|
|
104
|
-
const IRQ_QUIET = 1 << 21;
|
|
105
|
-
const TREQ_SEL_MASK = 0x3f;
|
|
106
|
-
const TREQ_SEL_SHIFT = 15;
|
|
107
|
-
const CHAIN_TO_MASK = 0xf;
|
|
108
|
-
const CHAIN_TO_SHIFT = 11;
|
|
109
|
-
const RING_SEL = 1 << 10;
|
|
110
|
-
const RING_SIZE_MASK = 0xf;
|
|
111
|
-
const RING_SIZE_SHIFT = 6;
|
|
112
|
-
const INCR_WRITE = 1 << 5;
|
|
113
|
-
const INCR_READ = 1 << 4;
|
|
114
|
-
const DATA_SIZE_MASK = 0x3;
|
|
115
|
-
const DATA_SIZE_SHIFT = 2;
|
|
116
|
-
const HIGH_PRIORITY = 1 << 1;
|
|
117
|
-
const EN = 1 << 0;
|
|
118
|
-
const CHn_CTRL_TRIG_WRITE_MASK = 0xffffff;
|
|
119
|
-
const CHn_CTRL_TRIG_WC_MASK = READ_ERROR | WRITE_ERROR;
|
|
120
|
-
class RPDMAChannel {
|
|
121
|
-
constructor(dma, rp2040, index) {
|
|
122
|
-
this.dma = dma;
|
|
123
|
-
this.rp2040 = rp2040;
|
|
124
|
-
this.index = index;
|
|
125
|
-
this.ctrl = 0;
|
|
126
|
-
this.readAddr = 0;
|
|
127
|
-
this.writeAddr = 0;
|
|
128
|
-
this.transCount = 0;
|
|
129
|
-
this.dreqCounter = 0;
|
|
130
|
-
this.transCountReload = 0;
|
|
131
|
-
this.treqValue = 0;
|
|
132
|
-
this.dataSize = 1;
|
|
133
|
-
this.chainTo = 0;
|
|
134
|
-
this.ringMask = 0;
|
|
135
|
-
this.transferFn = () => 0;
|
|
136
|
-
this.transferTimer = null;
|
|
137
|
-
this.transfer8 = () => {
|
|
138
|
-
const { rp2040 } = this;
|
|
139
|
-
rp2040.writeUint8(this.writeAddr, rp2040.readUint8(this.readAddr));
|
|
140
|
-
};
|
|
141
|
-
this.transfer16 = () => {
|
|
142
|
-
const { rp2040 } = this;
|
|
143
|
-
rp2040.writeUint16(this.writeAddr, rp2040.readUint16(this.readAddr));
|
|
144
|
-
};
|
|
145
|
-
this.transferSwap16 = () => {
|
|
146
|
-
const { rp2040 } = this;
|
|
147
|
-
const input = rp2040.readUint16(this.readAddr);
|
|
148
|
-
rp2040.writeUint16(this.writeAddr, ((input & 0xff) << 8) | (input >> 8));
|
|
149
|
-
};
|
|
150
|
-
this.transfer32 = () => {
|
|
151
|
-
const { rp2040 } = this;
|
|
152
|
-
rp2040.writeUint32(this.writeAddr, rp2040.readUint32(this.readAddr));
|
|
153
|
-
};
|
|
154
|
-
this.transferSwap32 = () => {
|
|
155
|
-
const { rp2040 } = this;
|
|
156
|
-
const input = rp2040.readUint32(this.readAddr);
|
|
157
|
-
rp2040.writeUint32(this.writeAddr, ((input & 0x000000ff) << 24) |
|
|
158
|
-
((input & 0x0000ff00) << 8) |
|
|
159
|
-
((input & 0x00ff0000) >> 8) |
|
|
160
|
-
((input >> 24) & 0xff));
|
|
161
|
-
};
|
|
162
|
-
this.transfer = () => {
|
|
163
|
-
var _a;
|
|
164
|
-
const { ctrl, dataSize, ringMask } = this;
|
|
165
|
-
this.transferTimer = null;
|
|
166
|
-
this.transferFn();
|
|
167
|
-
if (ctrl & INCR_READ) {
|
|
168
|
-
if (ringMask && !(ctrl & RING_SEL)) {
|
|
169
|
-
this.readAddr = (this.readAddr & ~ringMask) | ((this.readAddr + dataSize) & ringMask);
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
this.readAddr += dataSize;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
if (ctrl & INCR_WRITE) {
|
|
176
|
-
if (ringMask && ctrl & RING_SEL) {
|
|
177
|
-
this.writeAddr = (this.writeAddr & ~ringMask) | ((this.writeAddr + dataSize) & ringMask);
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
this.writeAddr += dataSize;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
this.transCount--;
|
|
184
|
-
if (this.transCount > 0) {
|
|
185
|
-
this.scheduleTransfer();
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
this.ctrl &= ~BUSY;
|
|
189
|
-
if (!(this.ctrl & IRQ_QUIET)) {
|
|
190
|
-
this.dma.intRaw |= 1 << this.index;
|
|
191
|
-
this.dma.checkInterrupts();
|
|
192
|
-
}
|
|
193
|
-
if (this.chainTo !== this.index) {
|
|
194
|
-
(_a = this.dma.channels[this.chainTo]) === null || _a === void 0 ? void 0 : _a.start();
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
this.reset();
|
|
199
|
-
}
|
|
200
|
-
start() {
|
|
201
|
-
if (!(this.ctrl & EN) || this.ctrl & BUSY) {
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
this.ctrl |= BUSY;
|
|
205
|
-
this.transCount = this.transCountReload;
|
|
206
|
-
if (this.transCount) {
|
|
207
|
-
this.scheduleTransfer();
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
get treq() {
|
|
211
|
-
return this.treqValue;
|
|
212
|
-
}
|
|
213
|
-
get active() {
|
|
214
|
-
return this.ctrl & EN && this.ctrl & BUSY;
|
|
215
|
-
}
|
|
216
|
-
scheduleTransfer() {
|
|
217
|
-
if (this.transferTimer) {
|
|
218
|
-
// Already scheduled; do nothing.
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
if (this.dma.dreq[this.treqValue] || this.treqValue === TREQ.Permanent) {
|
|
222
|
-
this.transferTimer = this.rp2040.clock.createTimer(0, this.transfer);
|
|
223
|
-
}
|
|
224
|
-
else {
|
|
225
|
-
const delay = this.dma.getTimer(this.treqValue);
|
|
226
|
-
if (delay) {
|
|
227
|
-
this.transferTimer = this.rp2040.clock.createTimer(delay, this.transfer);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
abort() {
|
|
232
|
-
this.ctrl &= ~BUSY;
|
|
233
|
-
if (this.transferTimer) {
|
|
234
|
-
this.rp2040.clock.deleteTimer(this.transferTimer);
|
|
235
|
-
this.transferTimer = null;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
readUint32(offset) {
|
|
239
|
-
switch (offset) {
|
|
240
|
-
case CHn_READ_ADDR:
|
|
241
|
-
case CHn_AL1_READ_ADDR:
|
|
242
|
-
case CHn_AL2_READ_ADDR:
|
|
243
|
-
case CHn_AL3_READ_ADDR_TRIG:
|
|
244
|
-
return this.readAddr;
|
|
245
|
-
case CHn_WRITE_ADDR:
|
|
246
|
-
case CHn_AL1_WRITE_ADDR:
|
|
247
|
-
case CHn_AL2_WRITE_ADDR_TRIG:
|
|
248
|
-
case CHn_AL3_WRITE_ADDR:
|
|
249
|
-
return this.writeAddr;
|
|
250
|
-
case CHn_TRANS_COUNT:
|
|
251
|
-
case CHn_AL1_TRANS_COUNT_TRIG:
|
|
252
|
-
case CHn_AL2_TRANS_COUNT:
|
|
253
|
-
case CHn_AL3_TRANS_COUNT:
|
|
254
|
-
return this.transCount;
|
|
255
|
-
case CHn_CTRL_TRIG:
|
|
256
|
-
case CHn_AL1_CTRL:
|
|
257
|
-
case CHn_AL2_CTRL:
|
|
258
|
-
case CHn_AL3_CTRL:
|
|
259
|
-
return this.ctrl;
|
|
260
|
-
case CHn_DBG_CTDREQ:
|
|
261
|
-
return this.dreqCounter;
|
|
262
|
-
case CHn_DBG_TCR:
|
|
263
|
-
return this.transCountReload;
|
|
264
|
-
}
|
|
265
|
-
return 0;
|
|
266
|
-
}
|
|
267
|
-
writeUint32(offset, value) {
|
|
268
|
-
switch (offset) {
|
|
269
|
-
case CHn_READ_ADDR:
|
|
270
|
-
case CHn_AL1_READ_ADDR:
|
|
271
|
-
case CHn_AL2_READ_ADDR:
|
|
272
|
-
case CHn_AL3_READ_ADDR_TRIG:
|
|
273
|
-
this.readAddr = value;
|
|
274
|
-
break;
|
|
275
|
-
case CHn_WRITE_ADDR:
|
|
276
|
-
case CHn_AL1_WRITE_ADDR:
|
|
277
|
-
case CHn_AL2_WRITE_ADDR_TRIG:
|
|
278
|
-
case CHn_AL3_WRITE_ADDR:
|
|
279
|
-
this.writeAddr = value;
|
|
280
|
-
break;
|
|
281
|
-
case CHn_TRANS_COUNT:
|
|
282
|
-
case CHn_AL1_TRANS_COUNT_TRIG:
|
|
283
|
-
case CHn_AL2_TRANS_COUNT:
|
|
284
|
-
case CHn_AL3_TRANS_COUNT:
|
|
285
|
-
this.transCountReload = value;
|
|
286
|
-
break;
|
|
287
|
-
case CHn_CTRL_TRIG:
|
|
288
|
-
case CHn_AL1_CTRL:
|
|
289
|
-
case CHn_AL2_CTRL:
|
|
290
|
-
case CHn_AL3_CTRL: {
|
|
291
|
-
this.ctrl = (this.ctrl & ~CHn_CTRL_TRIG_WRITE_MASK) | (value & CHn_CTRL_TRIG_WRITE_MASK);
|
|
292
|
-
this.ctrl &= ~(value & CHn_CTRL_TRIG_WC_MASK); // Handle write-clear (WC) bits
|
|
293
|
-
this.treqValue = (this.ctrl >> TREQ_SEL_SHIFT) & TREQ_SEL_MASK;
|
|
294
|
-
this.chainTo = (this.ctrl >> CHAIN_TO_SHIFT) & CHAIN_TO_MASK;
|
|
295
|
-
const ringSize = (this.ctrl >> RING_SIZE_SHIFT) & RING_SIZE_MASK;
|
|
296
|
-
this.ringMask = ringSize ? (1 << ringSize) - 1 : 0;
|
|
297
|
-
switch ((this.ctrl >> DATA_SIZE_SHIFT) & DATA_SIZE_MASK) {
|
|
298
|
-
case 1:
|
|
299
|
-
this.dataSize = 2;
|
|
300
|
-
this.transferFn = this.ctrl & BSWAP ? this.transferSwap16 : this.transfer16;
|
|
301
|
-
break;
|
|
302
|
-
case 2:
|
|
303
|
-
this.dataSize = 4;
|
|
304
|
-
this.transferFn = this.ctrl & BSWAP ? this.transferSwap32 : this.transfer32;
|
|
305
|
-
break;
|
|
306
|
-
case 0:
|
|
307
|
-
default:
|
|
308
|
-
this.transferFn = this.transfer8;
|
|
309
|
-
this.dataSize = 1;
|
|
310
|
-
}
|
|
311
|
-
if (this.ctrl & EN && this.ctrl & BUSY) {
|
|
312
|
-
this.scheduleTransfer();
|
|
313
|
-
}
|
|
314
|
-
if (!(this.ctrl & EN) && this.transferTimer) {
|
|
315
|
-
this.rp2040.clock.deleteTimer(this.transferTimer);
|
|
316
|
-
this.transferTimer = null;
|
|
317
|
-
}
|
|
318
|
-
break;
|
|
319
|
-
}
|
|
320
|
-
case CHn_DBG_CTDREQ:
|
|
321
|
-
this.dreqCounter = 0;
|
|
322
|
-
break;
|
|
323
|
-
}
|
|
324
|
-
if (offset === CHn_AL3_READ_ADDR_TRIG ||
|
|
325
|
-
offset === CHn_AL2_WRITE_ADDR_TRIG ||
|
|
326
|
-
offset === CHn_AL1_TRANS_COUNT_TRIG ||
|
|
327
|
-
offset === CHn_CTRL_TRIG) {
|
|
328
|
-
if (value) {
|
|
329
|
-
this.start();
|
|
330
|
-
}
|
|
331
|
-
else if (this.ctrl & IRQ_QUIET) {
|
|
332
|
-
// Null trigger interrupts
|
|
333
|
-
this.dma.intRaw |= 1 << this.index;
|
|
334
|
-
this.dma.checkInterrupts();
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
reset() {
|
|
339
|
-
this.writeUint32(CHn_CTRL_TRIG, this.index << CHAIN_TO_SHIFT);
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
exports.RPDMAChannel = RPDMAChannel;
|
|
343
|
-
class RPDMA extends
|
|
344
|
-
constructor() {
|
|
345
|
-
super(...arguments);
|
|
346
|
-
this.channels = [
|
|
347
|
-
new RPDMAChannel(this, this.rp2040, 0),
|
|
348
|
-
new RPDMAChannel(this, this.rp2040, 1),
|
|
349
|
-
new RPDMAChannel(this, this.rp2040, 2),
|
|
350
|
-
new RPDMAChannel(this, this.rp2040, 3),
|
|
351
|
-
new RPDMAChannel(this, this.rp2040, 4),
|
|
352
|
-
new RPDMAChannel(this, this.rp2040, 5),
|
|
353
|
-
new RPDMAChannel(this, this.rp2040, 6),
|
|
354
|
-
new RPDMAChannel(this, this.rp2040, 7),
|
|
355
|
-
new RPDMAChannel(this, this.rp2040, 8),
|
|
356
|
-
new RPDMAChannel(this, this.rp2040, 9),
|
|
357
|
-
new RPDMAChannel(this, this.rp2040, 10),
|
|
358
|
-
new RPDMAChannel(this, this.rp2040, 11),
|
|
359
|
-
];
|
|
360
|
-
this.intRaw = 0;
|
|
361
|
-
this.intEnable0 = 0;
|
|
362
|
-
this.intForce0 = 0;
|
|
363
|
-
this.intEnable1 = 0;
|
|
364
|
-
this.intForce1 = 0;
|
|
365
|
-
this.timer0 = 0;
|
|
366
|
-
this.timer1 = 0;
|
|
367
|
-
this.timer2 = 0;
|
|
368
|
-
this.timer3 = 0;
|
|
369
|
-
this.dreq = Array(DREQChannel.DREQ_MAX);
|
|
370
|
-
}
|
|
371
|
-
get intStatus0() {
|
|
372
|
-
return (this.intRaw & this.intEnable0) | this.intForce0;
|
|
373
|
-
}
|
|
374
|
-
get intStatus1() {
|
|
375
|
-
return (this.intRaw & this.intEnable1) | this.intForce1;
|
|
376
|
-
}
|
|
377
|
-
readUint32(offset) {
|
|
378
|
-
if ((offset & 0x7ff) <= CHANNEL_REGISTERS_SIZE) {
|
|
379
|
-
const channelIndex = (offset & 0x7ff) >> 6;
|
|
380
|
-
return this.channels[channelIndex].readUint32(offset & CHANNEL_REGISTERS_MASK);
|
|
381
|
-
}
|
|
382
|
-
switch (offset) {
|
|
383
|
-
case TIMER0:
|
|
384
|
-
return this.timer0;
|
|
385
|
-
case TIMER1:
|
|
386
|
-
return this.timer1;
|
|
387
|
-
case TIMER2:
|
|
388
|
-
return this.timer2;
|
|
389
|
-
case TIMER3:
|
|
390
|
-
return this.timer3;
|
|
391
|
-
case INTR:
|
|
392
|
-
return this.intRaw;
|
|
393
|
-
case INTE0:
|
|
394
|
-
return this.intEnable0;
|
|
395
|
-
case INTF0:
|
|
396
|
-
return this.intForce0;
|
|
397
|
-
case INTS0:
|
|
398
|
-
return this.intStatus0;
|
|
399
|
-
case INTE1:
|
|
400
|
-
return this.intEnable1;
|
|
401
|
-
case INTF1:
|
|
402
|
-
return this.intForce1;
|
|
403
|
-
case INTS1:
|
|
404
|
-
return this.intStatus1;
|
|
405
|
-
case N_CHANNELS:
|
|
406
|
-
return this.channels.length;
|
|
407
|
-
}
|
|
408
|
-
return super.readUint32(offset);
|
|
409
|
-
}
|
|
410
|
-
writeUint32(offset, value) {
|
|
411
|
-
if ((offset & 0x7ff) <= CHANNEL_REGISTERS_SIZE) {
|
|
412
|
-
const channelIndex = (offset & 0x7ff) >> 6;
|
|
413
|
-
this.channels[channelIndex].writeUint32(offset & CHANNEL_REGISTERS_MASK, value);
|
|
414
|
-
return;
|
|
415
|
-
}
|
|
416
|
-
switch (offset) {
|
|
417
|
-
case TIMER0:
|
|
418
|
-
this.timer0 = value;
|
|
419
|
-
return;
|
|
420
|
-
case TIMER1:
|
|
421
|
-
this.timer1 = value;
|
|
422
|
-
return;
|
|
423
|
-
case TIMER2:
|
|
424
|
-
this.timer2 = value;
|
|
425
|
-
return;
|
|
426
|
-
case TIMER3:
|
|
427
|
-
this.timer3 = value;
|
|
428
|
-
return;
|
|
429
|
-
case INTR:
|
|
430
|
-
case INTS0:
|
|
431
|
-
case INTS1:
|
|
432
|
-
this.intRaw &= ~this.rawWriteValue;
|
|
433
|
-
this.checkInterrupts();
|
|
434
|
-
return;
|
|
435
|
-
case INTE0:
|
|
436
|
-
this.intEnable0 = value & 0xffff;
|
|
437
|
-
this.checkInterrupts();
|
|
438
|
-
return;
|
|
439
|
-
case INTF0:
|
|
440
|
-
this.intForce0 = value & 0xffff;
|
|
441
|
-
this.checkInterrupts();
|
|
442
|
-
return;
|
|
443
|
-
case INTE1:
|
|
444
|
-
this.intEnable1 = value & 0xffff;
|
|
445
|
-
this.checkInterrupts();
|
|
446
|
-
return;
|
|
447
|
-
case INTF1:
|
|
448
|
-
this.intForce1 = value & 0xffff;
|
|
449
|
-
this.checkInterrupts();
|
|
450
|
-
return;
|
|
451
|
-
case MULTI_CHAN_TRIGGER:
|
|
452
|
-
for (const chan of this.channels) {
|
|
453
|
-
if (value & (1 << chan.index)) {
|
|
454
|
-
chan.start();
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
return;
|
|
458
|
-
case CHAN_ABORT:
|
|
459
|
-
for (const chan of this.channels) {
|
|
460
|
-
if (value & (1 << chan.index)) {
|
|
461
|
-
chan.abort();
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
return;
|
|
465
|
-
default:
|
|
466
|
-
super.writeUint32(offset, value);
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
setDREQ(dreqChannel) {
|
|
470
|
-
const { dreq } = this;
|
|
471
|
-
if (!dreq[dreqChannel]) {
|
|
472
|
-
dreq[dreqChannel] = true;
|
|
473
|
-
for (const channel of this.channels) {
|
|
474
|
-
if (channel.treq === dreqChannel && channel.active) {
|
|
475
|
-
channel.scheduleTransfer();
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
clearDREQ(dreqChannel) {
|
|
481
|
-
this.dreq[dreqChannel] = false;
|
|
482
|
-
}
|
|
483
|
-
/**
|
|
484
|
-
* Returns the number of microseconds for a cycle of the given DMA timer, or 0 if the timer is disabled.
|
|
485
|
-
*/
|
|
486
|
-
getTimer(treq) {
|
|
487
|
-
let dividend = 0, divisor = 1;
|
|
488
|
-
switch (treq) {
|
|
489
|
-
case TREQ.Permanent:
|
|
490
|
-
dividend = 1;
|
|
491
|
-
divisor = 1;
|
|
492
|
-
break;
|
|
493
|
-
case TREQ.Timer0:
|
|
494
|
-
dividend = this.timer0 >>> 16;
|
|
495
|
-
divisor = this.timer0 & 0xffff;
|
|
496
|
-
break;
|
|
497
|
-
case TREQ.Timer1:
|
|
498
|
-
dividend = this.timer1 >>> 16;
|
|
499
|
-
divisor = this.timer1 & 0xffff;
|
|
500
|
-
break;
|
|
501
|
-
case TREQ.Timer2:
|
|
502
|
-
dividend = this.timer2 >>> 16;
|
|
503
|
-
divisor = this.timer2 & 0xffff;
|
|
504
|
-
break;
|
|
505
|
-
case TREQ.Timer3:
|
|
506
|
-
dividend = this.timer3 >>> 36;
|
|
507
|
-
divisor = this.timer3 & 0xffff;
|
|
508
|
-
break;
|
|
509
|
-
}
|
|
510
|
-
if (divisor === 0) {
|
|
511
|
-
return 0;
|
|
512
|
-
}
|
|
513
|
-
return ((dividend / divisor) * 1e6) / this.rp2040.clkSys;
|
|
514
|
-
}
|
|
515
|
-
checkInterrupts() {
|
|
516
|
-
this.rp2040.setInterrupt(
|
|
517
|
-
this.rp2040.setInterrupt(
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
exports.RPDMA = RPDMA;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RPDMA = exports.RPDMAChannel = exports.DREQChannel = void 0;
|
|
4
|
+
const irq_js_1 = require("../irq.js");
|
|
5
|
+
const peripheral_js_1 = require("./peripheral.js");
|
|
6
|
+
var DREQChannel;
|
|
7
|
+
(function (DREQChannel) {
|
|
8
|
+
DREQChannel[DREQChannel["DREQ_PIO0_TX0"] = 0] = "DREQ_PIO0_TX0";
|
|
9
|
+
DREQChannel[DREQChannel["DREQ_PIO0_TX1"] = 1] = "DREQ_PIO0_TX1";
|
|
10
|
+
DREQChannel[DREQChannel["DREQ_PIO0_TX2"] = 2] = "DREQ_PIO0_TX2";
|
|
11
|
+
DREQChannel[DREQChannel["DREQ_PIO0_TX3"] = 3] = "DREQ_PIO0_TX3";
|
|
12
|
+
DREQChannel[DREQChannel["DREQ_PIO0_RX0"] = 4] = "DREQ_PIO0_RX0";
|
|
13
|
+
DREQChannel[DREQChannel["DREQ_PIO0_RX1"] = 5] = "DREQ_PIO0_RX1";
|
|
14
|
+
DREQChannel[DREQChannel["DREQ_PIO0_RX2"] = 6] = "DREQ_PIO0_RX2";
|
|
15
|
+
DREQChannel[DREQChannel["DREQ_PIO0_RX3"] = 7] = "DREQ_PIO0_RX3";
|
|
16
|
+
DREQChannel[DREQChannel["DREQ_PIO1_TX0"] = 8] = "DREQ_PIO1_TX0";
|
|
17
|
+
DREQChannel[DREQChannel["DREQ_PIO1_TX1"] = 9] = "DREQ_PIO1_TX1";
|
|
18
|
+
DREQChannel[DREQChannel["DREQ_PIO1_TX2"] = 10] = "DREQ_PIO1_TX2";
|
|
19
|
+
DREQChannel[DREQChannel["DREQ_PIO1_TX3"] = 11] = "DREQ_PIO1_TX3";
|
|
20
|
+
DREQChannel[DREQChannel["DREQ_PIO1_RX0"] = 12] = "DREQ_PIO1_RX0";
|
|
21
|
+
DREQChannel[DREQChannel["DREQ_PIO1_RX1"] = 13] = "DREQ_PIO1_RX1";
|
|
22
|
+
DREQChannel[DREQChannel["DREQ_PIO1_RX2"] = 14] = "DREQ_PIO1_RX2";
|
|
23
|
+
DREQChannel[DREQChannel["DREQ_PIO1_RX3"] = 15] = "DREQ_PIO1_RX3";
|
|
24
|
+
DREQChannel[DREQChannel["DREQ_SPI0_TX"] = 16] = "DREQ_SPI0_TX";
|
|
25
|
+
DREQChannel[DREQChannel["DREQ_SPI0_RX"] = 17] = "DREQ_SPI0_RX";
|
|
26
|
+
DREQChannel[DREQChannel["DREQ_SPI1_TX"] = 18] = "DREQ_SPI1_TX";
|
|
27
|
+
DREQChannel[DREQChannel["DREQ_SPI1_RX"] = 19] = "DREQ_SPI1_RX";
|
|
28
|
+
DREQChannel[DREQChannel["DREQ_UART0_TX"] = 20] = "DREQ_UART0_TX";
|
|
29
|
+
DREQChannel[DREQChannel["DREQ_UART0_RX"] = 21] = "DREQ_UART0_RX";
|
|
30
|
+
DREQChannel[DREQChannel["DREQ_UART1_TX"] = 22] = "DREQ_UART1_TX";
|
|
31
|
+
DREQChannel[DREQChannel["DREQ_UART1_RX"] = 23] = "DREQ_UART1_RX";
|
|
32
|
+
DREQChannel[DREQChannel["DREQ_PWM_WRAP0"] = 24] = "DREQ_PWM_WRAP0";
|
|
33
|
+
DREQChannel[DREQChannel["DREQ_PWM_WRAP1"] = 25] = "DREQ_PWM_WRAP1";
|
|
34
|
+
DREQChannel[DREQChannel["DREQ_PWM_WRAP2"] = 26] = "DREQ_PWM_WRAP2";
|
|
35
|
+
DREQChannel[DREQChannel["DREQ_PWM_WRAP3"] = 27] = "DREQ_PWM_WRAP3";
|
|
36
|
+
DREQChannel[DREQChannel["DREQ_PWM_WRAP4"] = 28] = "DREQ_PWM_WRAP4";
|
|
37
|
+
DREQChannel[DREQChannel["DREQ_PWM_WRAP5"] = 29] = "DREQ_PWM_WRAP5";
|
|
38
|
+
DREQChannel[DREQChannel["DREQ_PWM_WRAP6"] = 30] = "DREQ_PWM_WRAP6";
|
|
39
|
+
DREQChannel[DREQChannel["DREQ_PWM_WRAP7"] = 31] = "DREQ_PWM_WRAP7";
|
|
40
|
+
DREQChannel[DREQChannel["DREQ_I2C0_TX"] = 32] = "DREQ_I2C0_TX";
|
|
41
|
+
DREQChannel[DREQChannel["DREQ_I2C0_RX"] = 33] = "DREQ_I2C0_RX";
|
|
42
|
+
DREQChannel[DREQChannel["DREQ_I2C1_TX"] = 34] = "DREQ_I2C1_TX";
|
|
43
|
+
DREQChannel[DREQChannel["DREQ_I2C1_RX"] = 35] = "DREQ_I2C1_RX";
|
|
44
|
+
DREQChannel[DREQChannel["DREQ_ADC"] = 36] = "DREQ_ADC";
|
|
45
|
+
DREQChannel[DREQChannel["DREQ_XIP_STREAM"] = 37] = "DREQ_XIP_STREAM";
|
|
46
|
+
DREQChannel[DREQChannel["DREQ_XIP_SSITX"] = 38] = "DREQ_XIP_SSITX";
|
|
47
|
+
DREQChannel[DREQChannel["DREQ_XIP_SSIRX"] = 39] = "DREQ_XIP_SSIRX";
|
|
48
|
+
DREQChannel[DREQChannel["DREQ_MAX"] = 40] = "DREQ_MAX";
|
|
49
|
+
})(DREQChannel || (exports.DREQChannel = DREQChannel = {}));
|
|
50
|
+
var TREQ;
|
|
51
|
+
(function (TREQ) {
|
|
52
|
+
TREQ[TREQ["Timer0"] = 59] = "Timer0";
|
|
53
|
+
TREQ[TREQ["Timer1"] = 60] = "Timer1";
|
|
54
|
+
TREQ[TREQ["Timer2"] = 61] = "Timer2";
|
|
55
|
+
TREQ[TREQ["Timer3"] = 62] = "Timer3";
|
|
56
|
+
TREQ[TREQ["Permanent"] = 63] = "Permanent";
|
|
57
|
+
})(TREQ || (TREQ = {}));
|
|
58
|
+
// Per-channel registers
|
|
59
|
+
const CHn_READ_ADDR = 0x000; // DMA Channel n Read Address pointer
|
|
60
|
+
const CHn_WRITE_ADDR = 0x004; // DMA Channel n Write Address pointer
|
|
61
|
+
const CHn_TRANS_COUNT = 0x008; // DMA Channel n Transfer Count
|
|
62
|
+
const CHn_CTRL_TRIG = 0x00c; // DMA Channel n Control and Status
|
|
63
|
+
const CHn_AL1_CTRL = 0x010; // Alias for channel n CTRL register
|
|
64
|
+
const CHn_AL1_READ_ADDR = 0x014; // Alias for channel n READ_ADDR register
|
|
65
|
+
const CHn_AL1_WRITE_ADDR = 0x018; // Alias for channel n WRITE_ADDR register
|
|
66
|
+
const CHn_AL1_TRANS_COUNT_TRIG = 0x01c; // Alias for channel n TRANS_COUNT register
|
|
67
|
+
const CHn_AL2_CTRL = 0x020; // Alias for channel n CTRL register
|
|
68
|
+
const CHn_AL2_TRANS_COUNT = 0x024; // Alias for channel n TRANS_COUNT register
|
|
69
|
+
const CHn_AL2_READ_ADDR = 0x028; // Alias for channel n READ_ADDR register
|
|
70
|
+
const CHn_AL2_WRITE_ADDR_TRIG = 0x02c; // Alias for channel n WRITE_ADDR register
|
|
71
|
+
const CHn_AL3_CTRL = 0x030; // Alias for channel n CTRL register
|
|
72
|
+
const CHn_AL3_WRITE_ADDR = 0x034; // Alias for channel n WRITE_ADDR register
|
|
73
|
+
const CHn_AL3_TRANS_COUNT = 0x038; // Alias for channel n TRANS_COUNT register
|
|
74
|
+
const CHn_AL3_READ_ADDR_TRIG = 0x03c; // Alias for channel n READ_ADDR register
|
|
75
|
+
const CHn_DBG_CTDREQ = 0x800;
|
|
76
|
+
const CHn_DBG_TCR = 0x804;
|
|
77
|
+
const CHANNEL_REGISTERS_SIZE = 12 * 0x40;
|
|
78
|
+
const CHANNEL_REGISTERS_MASK = 0x83f;
|
|
79
|
+
// General DMA registers
|
|
80
|
+
const INTR = 0x400; // Interrupt Status (raw)
|
|
81
|
+
const INTE0 = 0x404; // Interrupt Enables for IRQ 0
|
|
82
|
+
const INTF0 = 0x408; // Force Interrupts
|
|
83
|
+
const INTS0 = 0x40c; // Interrupt Status for IRQ 0
|
|
84
|
+
const INTE1 = 0x414; // Interrupt Enables for IRQ 1
|
|
85
|
+
const INTF1 = 0x418; // Force Interrupts for IRQ 1
|
|
86
|
+
const INTS1 = 0x41c; // Interrupt Status (masked) for IRQ 1
|
|
87
|
+
const TIMER0 = 0x420; // Pacing (X/Y) Fractional Timer
|
|
88
|
+
const TIMER1 = 0x424; // Pacing (X/Y) Fractional Timer
|
|
89
|
+
const TIMER2 = 0x428; // Pacing (X/Y) Fractional Timer
|
|
90
|
+
const TIMER3 = 0x42c; // Pacing (X/Y) Fractional Timer
|
|
91
|
+
const MULTI_CHAN_TRIGGER = 0x430; // Trigger one or more channels simultaneously
|
|
92
|
+
const SNIFF_CTRL = 0x434; // Sniffer Control
|
|
93
|
+
const SNIFF_DATA = 0x438; // Data accumulator for sniff hardware
|
|
94
|
+
const FIFO_LEVELS = 0x440; // Debug RAF, WAF, TDF levels
|
|
95
|
+
const CHAN_ABORT = 0x444; // Abort an in-progress transfer sequence on one or more channels
|
|
96
|
+
const N_CHANNELS = 0x448;
|
|
97
|
+
// CHn_CTRL_TRIG bits
|
|
98
|
+
const AHB_ERROR = 1 << 31;
|
|
99
|
+
const READ_ERROR = 1 << 30;
|
|
100
|
+
const WRITE_ERROR = 1 << 29;
|
|
101
|
+
const BUSY = 1 << 24;
|
|
102
|
+
const SNIFF_EN = 1 << 23;
|
|
103
|
+
const BSWAP = 1 << 22;
|
|
104
|
+
const IRQ_QUIET = 1 << 21;
|
|
105
|
+
const TREQ_SEL_MASK = 0x3f;
|
|
106
|
+
const TREQ_SEL_SHIFT = 15;
|
|
107
|
+
const CHAIN_TO_MASK = 0xf;
|
|
108
|
+
const CHAIN_TO_SHIFT = 11;
|
|
109
|
+
const RING_SEL = 1 << 10;
|
|
110
|
+
const RING_SIZE_MASK = 0xf;
|
|
111
|
+
const RING_SIZE_SHIFT = 6;
|
|
112
|
+
const INCR_WRITE = 1 << 5;
|
|
113
|
+
const INCR_READ = 1 << 4;
|
|
114
|
+
const DATA_SIZE_MASK = 0x3;
|
|
115
|
+
const DATA_SIZE_SHIFT = 2;
|
|
116
|
+
const HIGH_PRIORITY = 1 << 1;
|
|
117
|
+
const EN = 1 << 0;
|
|
118
|
+
const CHn_CTRL_TRIG_WRITE_MASK = 0xffffff;
|
|
119
|
+
const CHn_CTRL_TRIG_WC_MASK = READ_ERROR | WRITE_ERROR;
|
|
120
|
+
class RPDMAChannel {
|
|
121
|
+
constructor(dma, rp2040, index) {
|
|
122
|
+
this.dma = dma;
|
|
123
|
+
this.rp2040 = rp2040;
|
|
124
|
+
this.index = index;
|
|
125
|
+
this.ctrl = 0;
|
|
126
|
+
this.readAddr = 0;
|
|
127
|
+
this.writeAddr = 0;
|
|
128
|
+
this.transCount = 0;
|
|
129
|
+
this.dreqCounter = 0;
|
|
130
|
+
this.transCountReload = 0;
|
|
131
|
+
this.treqValue = 0;
|
|
132
|
+
this.dataSize = 1;
|
|
133
|
+
this.chainTo = 0;
|
|
134
|
+
this.ringMask = 0;
|
|
135
|
+
this.transferFn = () => 0;
|
|
136
|
+
this.transferTimer = null;
|
|
137
|
+
this.transfer8 = () => {
|
|
138
|
+
const { rp2040 } = this;
|
|
139
|
+
rp2040.writeUint8(this.writeAddr, rp2040.readUint8(this.readAddr));
|
|
140
|
+
};
|
|
141
|
+
this.transfer16 = () => {
|
|
142
|
+
const { rp2040 } = this;
|
|
143
|
+
rp2040.writeUint16(this.writeAddr, rp2040.readUint16(this.readAddr));
|
|
144
|
+
};
|
|
145
|
+
this.transferSwap16 = () => {
|
|
146
|
+
const { rp2040 } = this;
|
|
147
|
+
const input = rp2040.readUint16(this.readAddr);
|
|
148
|
+
rp2040.writeUint16(this.writeAddr, ((input & 0xff) << 8) | (input >> 8));
|
|
149
|
+
};
|
|
150
|
+
this.transfer32 = () => {
|
|
151
|
+
const { rp2040 } = this;
|
|
152
|
+
rp2040.writeUint32(this.writeAddr, rp2040.readUint32(this.readAddr));
|
|
153
|
+
};
|
|
154
|
+
this.transferSwap32 = () => {
|
|
155
|
+
const { rp2040 } = this;
|
|
156
|
+
const input = rp2040.readUint32(this.readAddr);
|
|
157
|
+
rp2040.writeUint32(this.writeAddr, ((input & 0x000000ff) << 24) |
|
|
158
|
+
((input & 0x0000ff00) << 8) |
|
|
159
|
+
((input & 0x00ff0000) >> 8) |
|
|
160
|
+
((input >> 24) & 0xff));
|
|
161
|
+
};
|
|
162
|
+
this.transfer = () => {
|
|
163
|
+
var _a;
|
|
164
|
+
const { ctrl, dataSize, ringMask } = this;
|
|
165
|
+
this.transferTimer = null;
|
|
166
|
+
this.transferFn();
|
|
167
|
+
if (ctrl & INCR_READ) {
|
|
168
|
+
if (ringMask && !(ctrl & RING_SEL)) {
|
|
169
|
+
this.readAddr = (this.readAddr & ~ringMask) | ((this.readAddr + dataSize) & ringMask);
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
this.readAddr += dataSize;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (ctrl & INCR_WRITE) {
|
|
176
|
+
if (ringMask && ctrl & RING_SEL) {
|
|
177
|
+
this.writeAddr = (this.writeAddr & ~ringMask) | ((this.writeAddr + dataSize) & ringMask);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
this.writeAddr += dataSize;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
this.transCount--;
|
|
184
|
+
if (this.transCount > 0) {
|
|
185
|
+
this.scheduleTransfer();
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
this.ctrl &= ~BUSY;
|
|
189
|
+
if (!(this.ctrl & IRQ_QUIET)) {
|
|
190
|
+
this.dma.intRaw |= 1 << this.index;
|
|
191
|
+
this.dma.checkInterrupts();
|
|
192
|
+
}
|
|
193
|
+
if (this.chainTo !== this.index) {
|
|
194
|
+
(_a = this.dma.channels[this.chainTo]) === null || _a === void 0 ? void 0 : _a.start();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
this.reset();
|
|
199
|
+
}
|
|
200
|
+
start() {
|
|
201
|
+
if (!(this.ctrl & EN) || this.ctrl & BUSY) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
this.ctrl |= BUSY;
|
|
205
|
+
this.transCount = this.transCountReload;
|
|
206
|
+
if (this.transCount) {
|
|
207
|
+
this.scheduleTransfer();
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
get treq() {
|
|
211
|
+
return this.treqValue;
|
|
212
|
+
}
|
|
213
|
+
get active() {
|
|
214
|
+
return this.ctrl & EN && this.ctrl & BUSY;
|
|
215
|
+
}
|
|
216
|
+
scheduleTransfer() {
|
|
217
|
+
if (this.transferTimer) {
|
|
218
|
+
// Already scheduled; do nothing.
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
if (this.dma.dreq[this.treqValue] || this.treqValue === TREQ.Permanent) {
|
|
222
|
+
this.transferTimer = this.rp2040.clock.createTimer(0, this.transfer);
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
const delay = this.dma.getTimer(this.treqValue);
|
|
226
|
+
if (delay) {
|
|
227
|
+
this.transferTimer = this.rp2040.clock.createTimer(delay, this.transfer);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
abort() {
|
|
232
|
+
this.ctrl &= ~BUSY;
|
|
233
|
+
if (this.transferTimer) {
|
|
234
|
+
this.rp2040.clock.deleteTimer(this.transferTimer);
|
|
235
|
+
this.transferTimer = null;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
readUint32(offset) {
|
|
239
|
+
switch (offset) {
|
|
240
|
+
case CHn_READ_ADDR:
|
|
241
|
+
case CHn_AL1_READ_ADDR:
|
|
242
|
+
case CHn_AL2_READ_ADDR:
|
|
243
|
+
case CHn_AL3_READ_ADDR_TRIG:
|
|
244
|
+
return this.readAddr;
|
|
245
|
+
case CHn_WRITE_ADDR:
|
|
246
|
+
case CHn_AL1_WRITE_ADDR:
|
|
247
|
+
case CHn_AL2_WRITE_ADDR_TRIG:
|
|
248
|
+
case CHn_AL3_WRITE_ADDR:
|
|
249
|
+
return this.writeAddr;
|
|
250
|
+
case CHn_TRANS_COUNT:
|
|
251
|
+
case CHn_AL1_TRANS_COUNT_TRIG:
|
|
252
|
+
case CHn_AL2_TRANS_COUNT:
|
|
253
|
+
case CHn_AL3_TRANS_COUNT:
|
|
254
|
+
return this.transCount;
|
|
255
|
+
case CHn_CTRL_TRIG:
|
|
256
|
+
case CHn_AL1_CTRL:
|
|
257
|
+
case CHn_AL2_CTRL:
|
|
258
|
+
case CHn_AL3_CTRL:
|
|
259
|
+
return this.ctrl;
|
|
260
|
+
case CHn_DBG_CTDREQ:
|
|
261
|
+
return this.dreqCounter;
|
|
262
|
+
case CHn_DBG_TCR:
|
|
263
|
+
return this.transCountReload;
|
|
264
|
+
}
|
|
265
|
+
return 0;
|
|
266
|
+
}
|
|
267
|
+
writeUint32(offset, value) {
|
|
268
|
+
switch (offset) {
|
|
269
|
+
case CHn_READ_ADDR:
|
|
270
|
+
case CHn_AL1_READ_ADDR:
|
|
271
|
+
case CHn_AL2_READ_ADDR:
|
|
272
|
+
case CHn_AL3_READ_ADDR_TRIG:
|
|
273
|
+
this.readAddr = value;
|
|
274
|
+
break;
|
|
275
|
+
case CHn_WRITE_ADDR:
|
|
276
|
+
case CHn_AL1_WRITE_ADDR:
|
|
277
|
+
case CHn_AL2_WRITE_ADDR_TRIG:
|
|
278
|
+
case CHn_AL3_WRITE_ADDR:
|
|
279
|
+
this.writeAddr = value;
|
|
280
|
+
break;
|
|
281
|
+
case CHn_TRANS_COUNT:
|
|
282
|
+
case CHn_AL1_TRANS_COUNT_TRIG:
|
|
283
|
+
case CHn_AL2_TRANS_COUNT:
|
|
284
|
+
case CHn_AL3_TRANS_COUNT:
|
|
285
|
+
this.transCountReload = value;
|
|
286
|
+
break;
|
|
287
|
+
case CHn_CTRL_TRIG:
|
|
288
|
+
case CHn_AL1_CTRL:
|
|
289
|
+
case CHn_AL2_CTRL:
|
|
290
|
+
case CHn_AL3_CTRL: {
|
|
291
|
+
this.ctrl = (this.ctrl & ~CHn_CTRL_TRIG_WRITE_MASK) | (value & CHn_CTRL_TRIG_WRITE_MASK);
|
|
292
|
+
this.ctrl &= ~(value & CHn_CTRL_TRIG_WC_MASK); // Handle write-clear (WC) bits
|
|
293
|
+
this.treqValue = (this.ctrl >> TREQ_SEL_SHIFT) & TREQ_SEL_MASK;
|
|
294
|
+
this.chainTo = (this.ctrl >> CHAIN_TO_SHIFT) & CHAIN_TO_MASK;
|
|
295
|
+
const ringSize = (this.ctrl >> RING_SIZE_SHIFT) & RING_SIZE_MASK;
|
|
296
|
+
this.ringMask = ringSize ? (1 << ringSize) - 1 : 0;
|
|
297
|
+
switch ((this.ctrl >> DATA_SIZE_SHIFT) & DATA_SIZE_MASK) {
|
|
298
|
+
case 1:
|
|
299
|
+
this.dataSize = 2;
|
|
300
|
+
this.transferFn = this.ctrl & BSWAP ? this.transferSwap16 : this.transfer16;
|
|
301
|
+
break;
|
|
302
|
+
case 2:
|
|
303
|
+
this.dataSize = 4;
|
|
304
|
+
this.transferFn = this.ctrl & BSWAP ? this.transferSwap32 : this.transfer32;
|
|
305
|
+
break;
|
|
306
|
+
case 0:
|
|
307
|
+
default:
|
|
308
|
+
this.transferFn = this.transfer8;
|
|
309
|
+
this.dataSize = 1;
|
|
310
|
+
}
|
|
311
|
+
if (this.ctrl & EN && this.ctrl & BUSY) {
|
|
312
|
+
this.scheduleTransfer();
|
|
313
|
+
}
|
|
314
|
+
if (!(this.ctrl & EN) && this.transferTimer) {
|
|
315
|
+
this.rp2040.clock.deleteTimer(this.transferTimer);
|
|
316
|
+
this.transferTimer = null;
|
|
317
|
+
}
|
|
318
|
+
break;
|
|
319
|
+
}
|
|
320
|
+
case CHn_DBG_CTDREQ:
|
|
321
|
+
this.dreqCounter = 0;
|
|
322
|
+
break;
|
|
323
|
+
}
|
|
324
|
+
if (offset === CHn_AL3_READ_ADDR_TRIG ||
|
|
325
|
+
offset === CHn_AL2_WRITE_ADDR_TRIG ||
|
|
326
|
+
offset === CHn_AL1_TRANS_COUNT_TRIG ||
|
|
327
|
+
offset === CHn_CTRL_TRIG) {
|
|
328
|
+
if (value) {
|
|
329
|
+
this.start();
|
|
330
|
+
}
|
|
331
|
+
else if (this.ctrl & IRQ_QUIET) {
|
|
332
|
+
// Null trigger interrupts
|
|
333
|
+
this.dma.intRaw |= 1 << this.index;
|
|
334
|
+
this.dma.checkInterrupts();
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
reset() {
|
|
339
|
+
this.writeUint32(CHn_CTRL_TRIG, this.index << CHAIN_TO_SHIFT);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
exports.RPDMAChannel = RPDMAChannel;
|
|
343
|
+
class RPDMA extends peripheral_js_1.BasePeripheral {
|
|
344
|
+
constructor() {
|
|
345
|
+
super(...arguments);
|
|
346
|
+
this.channels = [
|
|
347
|
+
new RPDMAChannel(this, this.rp2040, 0),
|
|
348
|
+
new RPDMAChannel(this, this.rp2040, 1),
|
|
349
|
+
new RPDMAChannel(this, this.rp2040, 2),
|
|
350
|
+
new RPDMAChannel(this, this.rp2040, 3),
|
|
351
|
+
new RPDMAChannel(this, this.rp2040, 4),
|
|
352
|
+
new RPDMAChannel(this, this.rp2040, 5),
|
|
353
|
+
new RPDMAChannel(this, this.rp2040, 6),
|
|
354
|
+
new RPDMAChannel(this, this.rp2040, 7),
|
|
355
|
+
new RPDMAChannel(this, this.rp2040, 8),
|
|
356
|
+
new RPDMAChannel(this, this.rp2040, 9),
|
|
357
|
+
new RPDMAChannel(this, this.rp2040, 10),
|
|
358
|
+
new RPDMAChannel(this, this.rp2040, 11),
|
|
359
|
+
];
|
|
360
|
+
this.intRaw = 0;
|
|
361
|
+
this.intEnable0 = 0;
|
|
362
|
+
this.intForce0 = 0;
|
|
363
|
+
this.intEnable1 = 0;
|
|
364
|
+
this.intForce1 = 0;
|
|
365
|
+
this.timer0 = 0;
|
|
366
|
+
this.timer1 = 0;
|
|
367
|
+
this.timer2 = 0;
|
|
368
|
+
this.timer3 = 0;
|
|
369
|
+
this.dreq = Array(DREQChannel.DREQ_MAX);
|
|
370
|
+
}
|
|
371
|
+
get intStatus0() {
|
|
372
|
+
return (this.intRaw & this.intEnable0) | this.intForce0;
|
|
373
|
+
}
|
|
374
|
+
get intStatus1() {
|
|
375
|
+
return (this.intRaw & this.intEnable1) | this.intForce1;
|
|
376
|
+
}
|
|
377
|
+
readUint32(offset) {
|
|
378
|
+
if ((offset & 0x7ff) <= CHANNEL_REGISTERS_SIZE) {
|
|
379
|
+
const channelIndex = (offset & 0x7ff) >> 6;
|
|
380
|
+
return this.channels[channelIndex].readUint32(offset & CHANNEL_REGISTERS_MASK);
|
|
381
|
+
}
|
|
382
|
+
switch (offset) {
|
|
383
|
+
case TIMER0:
|
|
384
|
+
return this.timer0;
|
|
385
|
+
case TIMER1:
|
|
386
|
+
return this.timer1;
|
|
387
|
+
case TIMER2:
|
|
388
|
+
return this.timer2;
|
|
389
|
+
case TIMER3:
|
|
390
|
+
return this.timer3;
|
|
391
|
+
case INTR:
|
|
392
|
+
return this.intRaw;
|
|
393
|
+
case INTE0:
|
|
394
|
+
return this.intEnable0;
|
|
395
|
+
case INTF0:
|
|
396
|
+
return this.intForce0;
|
|
397
|
+
case INTS0:
|
|
398
|
+
return this.intStatus0;
|
|
399
|
+
case INTE1:
|
|
400
|
+
return this.intEnable1;
|
|
401
|
+
case INTF1:
|
|
402
|
+
return this.intForce1;
|
|
403
|
+
case INTS1:
|
|
404
|
+
return this.intStatus1;
|
|
405
|
+
case N_CHANNELS:
|
|
406
|
+
return this.channels.length;
|
|
407
|
+
}
|
|
408
|
+
return super.readUint32(offset);
|
|
409
|
+
}
|
|
410
|
+
writeUint32(offset, value) {
|
|
411
|
+
if ((offset & 0x7ff) <= CHANNEL_REGISTERS_SIZE) {
|
|
412
|
+
const channelIndex = (offset & 0x7ff) >> 6;
|
|
413
|
+
this.channels[channelIndex].writeUint32(offset & CHANNEL_REGISTERS_MASK, value);
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
switch (offset) {
|
|
417
|
+
case TIMER0:
|
|
418
|
+
this.timer0 = value;
|
|
419
|
+
return;
|
|
420
|
+
case TIMER1:
|
|
421
|
+
this.timer1 = value;
|
|
422
|
+
return;
|
|
423
|
+
case TIMER2:
|
|
424
|
+
this.timer2 = value;
|
|
425
|
+
return;
|
|
426
|
+
case TIMER3:
|
|
427
|
+
this.timer3 = value;
|
|
428
|
+
return;
|
|
429
|
+
case INTR:
|
|
430
|
+
case INTS0:
|
|
431
|
+
case INTS1:
|
|
432
|
+
this.intRaw &= ~this.rawWriteValue;
|
|
433
|
+
this.checkInterrupts();
|
|
434
|
+
return;
|
|
435
|
+
case INTE0:
|
|
436
|
+
this.intEnable0 = value & 0xffff;
|
|
437
|
+
this.checkInterrupts();
|
|
438
|
+
return;
|
|
439
|
+
case INTF0:
|
|
440
|
+
this.intForce0 = value & 0xffff;
|
|
441
|
+
this.checkInterrupts();
|
|
442
|
+
return;
|
|
443
|
+
case INTE1:
|
|
444
|
+
this.intEnable1 = value & 0xffff;
|
|
445
|
+
this.checkInterrupts();
|
|
446
|
+
return;
|
|
447
|
+
case INTF1:
|
|
448
|
+
this.intForce1 = value & 0xffff;
|
|
449
|
+
this.checkInterrupts();
|
|
450
|
+
return;
|
|
451
|
+
case MULTI_CHAN_TRIGGER:
|
|
452
|
+
for (const chan of this.channels) {
|
|
453
|
+
if (value & (1 << chan.index)) {
|
|
454
|
+
chan.start();
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
return;
|
|
458
|
+
case CHAN_ABORT:
|
|
459
|
+
for (const chan of this.channels) {
|
|
460
|
+
if (value & (1 << chan.index)) {
|
|
461
|
+
chan.abort();
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
return;
|
|
465
|
+
default:
|
|
466
|
+
super.writeUint32(offset, value);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
setDREQ(dreqChannel) {
|
|
470
|
+
const { dreq } = this;
|
|
471
|
+
if (!dreq[dreqChannel]) {
|
|
472
|
+
dreq[dreqChannel] = true;
|
|
473
|
+
for (const channel of this.channels) {
|
|
474
|
+
if (channel.treq === dreqChannel && channel.active) {
|
|
475
|
+
channel.scheduleTransfer();
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
clearDREQ(dreqChannel) {
|
|
481
|
+
this.dreq[dreqChannel] = false;
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Returns the number of microseconds for a cycle of the given DMA timer, or 0 if the timer is disabled.
|
|
485
|
+
*/
|
|
486
|
+
getTimer(treq) {
|
|
487
|
+
let dividend = 0, divisor = 1;
|
|
488
|
+
switch (treq) {
|
|
489
|
+
case TREQ.Permanent:
|
|
490
|
+
dividend = 1;
|
|
491
|
+
divisor = 1;
|
|
492
|
+
break;
|
|
493
|
+
case TREQ.Timer0:
|
|
494
|
+
dividend = this.timer0 >>> 16;
|
|
495
|
+
divisor = this.timer0 & 0xffff;
|
|
496
|
+
break;
|
|
497
|
+
case TREQ.Timer1:
|
|
498
|
+
dividend = this.timer1 >>> 16;
|
|
499
|
+
divisor = this.timer1 & 0xffff;
|
|
500
|
+
break;
|
|
501
|
+
case TREQ.Timer2:
|
|
502
|
+
dividend = this.timer2 >>> 16;
|
|
503
|
+
divisor = this.timer2 & 0xffff;
|
|
504
|
+
break;
|
|
505
|
+
case TREQ.Timer3:
|
|
506
|
+
dividend = this.timer3 >>> 36;
|
|
507
|
+
divisor = this.timer3 & 0xffff;
|
|
508
|
+
break;
|
|
509
|
+
}
|
|
510
|
+
if (divisor === 0) {
|
|
511
|
+
return 0;
|
|
512
|
+
}
|
|
513
|
+
return ((dividend / divisor) * 1e6) / this.rp2040.clkSys;
|
|
514
|
+
}
|
|
515
|
+
checkInterrupts() {
|
|
516
|
+
this.rp2040.setInterrupt(irq_js_1.IRQ.DMA_IRQ0, !!this.intStatus0);
|
|
517
|
+
this.rp2040.setInterrupt(irq_js_1.IRQ.DMA_IRQ1, !!this.intStatus1);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
exports.RPDMA = RPDMA;
|