rp2040js 0.17.4 → 0.17.6
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/peripherals/clocks.d.ts +3 -0
- package/dist/cjs/peripherals/clocks.js +23 -2
- package/dist/cjs/peripherals/rtc.d.ts +5 -1
- package/dist/cjs/peripherals/rtc.js +45 -3
- package/dist/cjs/peripherals/tbman.d.ts +4 -0
- package/dist/cjs/peripherals/tbman.js +17 -0
- package/dist/cjs/rp2040.d.ts +0 -1
- package/dist/cjs/rp2040.js +9 -7
- package/dist/esm/peripherals/clocks.d.ts +3 -0
- package/dist/esm/peripherals/clocks.js +23 -2
- package/dist/esm/peripherals/rtc.d.ts +5 -1
- package/dist/esm/peripherals/rtc.js +45 -3
- package/dist/esm/peripherals/tbman.d.ts +4 -0
- package/dist/esm/peripherals/tbman.js +13 -0
- package/dist/esm/rp2040.d.ts +0 -1
- package/dist/esm/rp2040.js +8 -6
- package/package.json +1 -1
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { RP2040 } from '../rp2040';
|
|
2
2
|
import { BasePeripheral, Peripheral } from './peripheral';
|
|
3
3
|
export declare class RPClocks extends BasePeripheral implements Peripheral {
|
|
4
|
+
refCtrl: number;
|
|
5
|
+
sysCtrl: number;
|
|
4
6
|
constructor(rp2040: RP2040, name: string);
|
|
5
7
|
readUint32(offset: number): number;
|
|
8
|
+
writeUint32(offset: number, value: number): void;
|
|
6
9
|
}
|
|
@@ -2,20 +2,41 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RPClocks = void 0;
|
|
4
4
|
const peripheral_1 = require("./peripheral");
|
|
5
|
+
const CLK_REF_CTRL = 0x30;
|
|
5
6
|
const CLK_REF_SELECTED = 0x38;
|
|
7
|
+
const CLK_SYS_CTRL = 0x3c;
|
|
6
8
|
const CLK_SYS_SELECTED = 0x44;
|
|
7
9
|
class RPClocks extends peripheral_1.BasePeripheral {
|
|
8
10
|
constructor(rp2040, name) {
|
|
9
11
|
super(rp2040, name);
|
|
12
|
+
this.refCtrl = 0;
|
|
13
|
+
this.sysCtrl = 0;
|
|
10
14
|
}
|
|
11
15
|
readUint32(offset) {
|
|
12
16
|
switch (offset) {
|
|
17
|
+
case CLK_REF_CTRL:
|
|
18
|
+
return this.refCtrl;
|
|
13
19
|
case CLK_REF_SELECTED:
|
|
14
|
-
return 1;
|
|
20
|
+
return 1 << (this.refCtrl & 0x03);
|
|
21
|
+
case CLK_SYS_CTRL:
|
|
22
|
+
return this.sysCtrl;
|
|
15
23
|
case CLK_SYS_SELECTED:
|
|
16
|
-
return 1;
|
|
24
|
+
return 1 << (this.sysCtrl & 0x01);
|
|
17
25
|
}
|
|
18
26
|
return super.readUint32(offset);
|
|
19
27
|
}
|
|
28
|
+
writeUint32(offset, value) {
|
|
29
|
+
switch (offset) {
|
|
30
|
+
case CLK_REF_CTRL:
|
|
31
|
+
this.refCtrl = value;
|
|
32
|
+
break;
|
|
33
|
+
case CLK_SYS_CTRL:
|
|
34
|
+
this.sysCtrl = value;
|
|
35
|
+
break;
|
|
36
|
+
default:
|
|
37
|
+
super.writeUint32(offset, value);
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
20
41
|
}
|
|
21
42
|
exports.RPClocks = RPClocks;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { BasePeripheral, Peripheral } from './peripheral';
|
|
2
2
|
export declare class RP2040RTC extends BasePeripheral implements Peripheral {
|
|
3
|
-
|
|
3
|
+
setup0: number;
|
|
4
|
+
setup1: number;
|
|
5
|
+
rtc1: number;
|
|
6
|
+
rtc0: number;
|
|
7
|
+
ctrl: number;
|
|
4
8
|
readUint32(offset: number): number;
|
|
5
9
|
writeUint32(offset: number, value: number): void;
|
|
6
10
|
}
|
|
@@ -2,27 +2,69 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RP2040RTC = void 0;
|
|
4
4
|
const peripheral_1 = require("./peripheral");
|
|
5
|
+
const RTC_SETUP0 = 0x04;
|
|
6
|
+
const RTC_SETUP1 = 0x08;
|
|
5
7
|
const RTC_CTRL = 0x0c;
|
|
6
8
|
const IRQ_SETUP_0 = 0x10;
|
|
9
|
+
const RTC_RTC1 = 0x18;
|
|
10
|
+
const RTC_RTC0 = 0x1c;
|
|
11
|
+
const RTC_ENABLE_BITS = 0x01;
|
|
7
12
|
const RTC_ACTIVE_BITS = 0x2;
|
|
13
|
+
const RTC_LOAD_BITS = 0x10;
|
|
8
14
|
class RP2040RTC extends peripheral_1.BasePeripheral {
|
|
9
15
|
constructor() {
|
|
10
16
|
super(...arguments);
|
|
11
|
-
this.
|
|
17
|
+
this.setup0 = 0;
|
|
18
|
+
this.setup1 = 0;
|
|
19
|
+
this.rtc1 = 0;
|
|
20
|
+
this.rtc0 = 0;
|
|
21
|
+
this.ctrl = 0;
|
|
12
22
|
}
|
|
13
23
|
readUint32(offset) {
|
|
14
24
|
switch (offset) {
|
|
25
|
+
case RTC_SETUP0:
|
|
26
|
+
return this.setup0;
|
|
27
|
+
case RTC_SETUP1:
|
|
28
|
+
return this.setup1;
|
|
15
29
|
case RTC_CTRL:
|
|
16
|
-
return this.
|
|
30
|
+
return this.ctrl;
|
|
17
31
|
case IRQ_SETUP_0:
|
|
18
32
|
return 0;
|
|
33
|
+
case RTC_RTC1:
|
|
34
|
+
return this.rtc1;
|
|
35
|
+
case RTC_RTC0:
|
|
36
|
+
return this.rtc0;
|
|
19
37
|
}
|
|
20
38
|
return super.readUint32(offset);
|
|
21
39
|
}
|
|
22
40
|
writeUint32(offset, value) {
|
|
23
41
|
switch (offset) {
|
|
42
|
+
case RTC_SETUP0:
|
|
43
|
+
this.setup0 = value;
|
|
44
|
+
break;
|
|
45
|
+
case RTC_SETUP1:
|
|
46
|
+
this.setup1 = value;
|
|
47
|
+
break;
|
|
24
48
|
case RTC_CTRL:
|
|
25
|
-
|
|
49
|
+
// Though RTC_LOAD_BITS is type SC and should be cleared on next cycle, pico-sdk write
|
|
50
|
+
// RTC_LOAD_BITS & RTC_ENABLE_BITS seperatly.
|
|
51
|
+
// https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2_common/hardware_rtc/rtc.c#L76-L80
|
|
52
|
+
if (value & RTC_LOAD_BITS) {
|
|
53
|
+
this.ctrl |= RTC_LOAD_BITS;
|
|
54
|
+
}
|
|
55
|
+
if (value & RTC_ENABLE_BITS) {
|
|
56
|
+
this.ctrl |= RTC_ENABLE_BITS;
|
|
57
|
+
this.ctrl |= RTC_ACTIVE_BITS;
|
|
58
|
+
if (this.ctrl & RTC_LOAD_BITS) {
|
|
59
|
+
this.rtc1 = this.setup0;
|
|
60
|
+
this.rtc0 = this.setup1;
|
|
61
|
+
this.ctrl &= ~RTC_LOAD_BITS;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
this.ctrl &= ~RTC_ENABLE_BITS;
|
|
66
|
+
this.ctrl &= ~RTC_ACTIVE_BITS;
|
|
67
|
+
}
|
|
26
68
|
break;
|
|
27
69
|
default:
|
|
28
70
|
super.writeUint32(offset, value);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RPTBMAN = void 0;
|
|
4
|
+
const peripheral_1 = require("./peripheral");
|
|
5
|
+
const PLATFORM = 0;
|
|
6
|
+
const ASIC = 1;
|
|
7
|
+
class RPTBMAN extends peripheral_1.BasePeripheral {
|
|
8
|
+
readUint32(offset) {
|
|
9
|
+
switch (offset) {
|
|
10
|
+
case PLATFORM:
|
|
11
|
+
return ASIC;
|
|
12
|
+
default:
|
|
13
|
+
return super.readUint32(offset);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.RPTBMAN = RPTBMAN;
|
package/dist/cjs/rp2040.d.ts
CHANGED
|
@@ -14,7 +14,6 @@ import { RPUSBController } from './peripherals/usb';
|
|
|
14
14
|
import { RPSIO } from './sio';
|
|
15
15
|
import { Logger } from './utils/logging';
|
|
16
16
|
export declare const FLASH_START_ADDRESS = 268435456;
|
|
17
|
-
export declare const FLASH_END_ADDRESS = 335544320;
|
|
18
17
|
export declare const RAM_START_ADDRESS = 536870912;
|
|
19
18
|
export declare const DPRAM_START_ADDRESS = 1343225856;
|
|
20
19
|
export declare const SIO_START_ADDRESS = 3489660928;
|
package/dist/cjs/rp2040.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RP2040 = exports.SIO_START_ADDRESS = exports.DPRAM_START_ADDRESS = exports.RAM_START_ADDRESS = exports.
|
|
3
|
+
exports.RP2040 = exports.SIO_START_ADDRESS = exports.DPRAM_START_ADDRESS = exports.RAM_START_ADDRESS = exports.FLASH_START_ADDRESS = void 0;
|
|
4
4
|
const realtime_clock_1 = require("./clock/realtime-clock");
|
|
5
5
|
const cortex_m0_core_1 = require("./cortex-m0-core");
|
|
6
6
|
const gpio_pin_1 = require("./gpio-pin");
|
|
@@ -26,8 +26,8 @@ const uart_1 = require("./peripherals/uart");
|
|
|
26
26
|
const usb_1 = require("./peripherals/usb");
|
|
27
27
|
const sio_1 = require("./sio");
|
|
28
28
|
const logging_1 = require("./utils/logging");
|
|
29
|
+
const tbman_1 = require("./peripherals/tbman");
|
|
29
30
|
exports.FLASH_START_ADDRESS = 0x10000000;
|
|
30
|
-
exports.FLASH_END_ADDRESS = 0x14000000;
|
|
31
31
|
exports.RAM_START_ADDRESS = 0x20000000;
|
|
32
32
|
exports.DPRAM_START_ADDRESS = 0x50100000;
|
|
33
33
|
exports.SIO_START_ADDRESS = 0xd0000000;
|
|
@@ -134,7 +134,7 @@ class RP2040 {
|
|
|
134
134
|
0x4005c: new rtc_1.RP2040RTC(this, 'RTC_BASE'),
|
|
135
135
|
0x40060: new peripheral_1.UnimplementedPeripheral(this, 'ROSC_BASE'),
|
|
136
136
|
0x40064: new peripheral_1.UnimplementedPeripheral(this, 'VREG_AND_CHIP_RESET_BASE'),
|
|
137
|
-
0x4006c: new
|
|
137
|
+
0x4006c: new tbman_1.RPTBMAN(this, 'TBMAN_BASE'),
|
|
138
138
|
0x50000: this.dma,
|
|
139
139
|
0x50110: this.usbCtrl,
|
|
140
140
|
0x50200: this.pio[0],
|
|
@@ -167,7 +167,8 @@ class RP2040 {
|
|
|
167
167
|
if (address < bootrom.length * 4) {
|
|
168
168
|
return bootrom[address / 4];
|
|
169
169
|
}
|
|
170
|
-
else if (address >= exports.FLASH_START_ADDRESS &&
|
|
170
|
+
else if (address >= exports.FLASH_START_ADDRESS &&
|
|
171
|
+
address < exports.FLASH_START_ADDRESS + this.flash.length) {
|
|
171
172
|
return this.flashView.getUint32(address - exports.FLASH_START_ADDRESS, true);
|
|
172
173
|
}
|
|
173
174
|
else if (address >= exports.RAM_START_ADDRESS && address < exports.RAM_START_ADDRESS + this.sram.length) {
|
|
@@ -195,7 +196,7 @@ class RP2040 {
|
|
|
195
196
|
}
|
|
196
197
|
/** We assume the address is 16-bit aligned */
|
|
197
198
|
readUint16(address) {
|
|
198
|
-
if (address >= exports.FLASH_START_ADDRESS && address < exports.
|
|
199
|
+
if (address >= exports.FLASH_START_ADDRESS && address < exports.FLASH_START_ADDRESS + this.flash.length) {
|
|
199
200
|
return this.flashView.getUint16(address - exports.FLASH_START_ADDRESS, true);
|
|
200
201
|
}
|
|
201
202
|
else if (address >= exports.RAM_START_ADDRESS && address < exports.RAM_START_ADDRESS + this.sram.length) {
|
|
@@ -205,7 +206,7 @@ class RP2040 {
|
|
|
205
206
|
return address & 0x2 ? (value & 0xffff0000) >>> 16 : value & 0xffff;
|
|
206
207
|
}
|
|
207
208
|
readUint8(address) {
|
|
208
|
-
if (address >= exports.FLASH_START_ADDRESS && address < exports.
|
|
209
|
+
if (address >= exports.FLASH_START_ADDRESS && address < exports.FLASH_START_ADDRESS + this.flash.length) {
|
|
209
210
|
return this.flash[address - exports.FLASH_START_ADDRESS];
|
|
210
211
|
}
|
|
211
212
|
else if (address >= exports.RAM_START_ADDRESS && address < exports.RAM_START_ADDRESS + this.sram.length) {
|
|
@@ -226,7 +227,8 @@ class RP2040 {
|
|
|
226
227
|
else if (address < bootrom.length * 4) {
|
|
227
228
|
bootrom[address / 4] = value;
|
|
228
229
|
}
|
|
229
|
-
else if (address >= exports.FLASH_START_ADDRESS &&
|
|
230
|
+
else if (address >= exports.FLASH_START_ADDRESS &&
|
|
231
|
+
address < exports.FLASH_START_ADDRESS + this.flash.length) {
|
|
230
232
|
this.flashView.setUint32(address - exports.FLASH_START_ADDRESS, value, true);
|
|
231
233
|
}
|
|
232
234
|
else if (address >= exports.RAM_START_ADDRESS && address < exports.RAM_START_ADDRESS + this.sram.length) {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { RP2040 } from '../rp2040';
|
|
2
2
|
import { BasePeripheral, Peripheral } from './peripheral';
|
|
3
3
|
export declare class RPClocks extends BasePeripheral implements Peripheral {
|
|
4
|
+
refCtrl: number;
|
|
5
|
+
sysCtrl: number;
|
|
4
6
|
constructor(rp2040: RP2040, name: string);
|
|
5
7
|
readUint32(offset: number): number;
|
|
8
|
+
writeUint32(offset: number, value: number): void;
|
|
6
9
|
}
|
|
@@ -1,17 +1,38 @@
|
|
|
1
1
|
import { BasePeripheral } from './peripheral';
|
|
2
|
+
const CLK_REF_CTRL = 0x30;
|
|
2
3
|
const CLK_REF_SELECTED = 0x38;
|
|
4
|
+
const CLK_SYS_CTRL = 0x3c;
|
|
3
5
|
const CLK_SYS_SELECTED = 0x44;
|
|
4
6
|
export class RPClocks extends BasePeripheral {
|
|
5
7
|
constructor(rp2040, name) {
|
|
6
8
|
super(rp2040, name);
|
|
9
|
+
this.refCtrl = 0;
|
|
10
|
+
this.sysCtrl = 0;
|
|
7
11
|
}
|
|
8
12
|
readUint32(offset) {
|
|
9
13
|
switch (offset) {
|
|
14
|
+
case CLK_REF_CTRL:
|
|
15
|
+
return this.refCtrl;
|
|
10
16
|
case CLK_REF_SELECTED:
|
|
11
|
-
return 1;
|
|
17
|
+
return 1 << (this.refCtrl & 0x03);
|
|
18
|
+
case CLK_SYS_CTRL:
|
|
19
|
+
return this.sysCtrl;
|
|
12
20
|
case CLK_SYS_SELECTED:
|
|
13
|
-
return 1;
|
|
21
|
+
return 1 << (this.sysCtrl & 0x01);
|
|
14
22
|
}
|
|
15
23
|
return super.readUint32(offset);
|
|
16
24
|
}
|
|
25
|
+
writeUint32(offset, value) {
|
|
26
|
+
switch (offset) {
|
|
27
|
+
case CLK_REF_CTRL:
|
|
28
|
+
this.refCtrl = value;
|
|
29
|
+
break;
|
|
30
|
+
case CLK_SYS_CTRL:
|
|
31
|
+
this.sysCtrl = value;
|
|
32
|
+
break;
|
|
33
|
+
default:
|
|
34
|
+
super.writeUint32(offset, value);
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
17
38
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { BasePeripheral, Peripheral } from './peripheral';
|
|
2
2
|
export declare class RP2040RTC extends BasePeripheral implements Peripheral {
|
|
3
|
-
|
|
3
|
+
setup0: number;
|
|
4
|
+
setup1: number;
|
|
5
|
+
rtc1: number;
|
|
6
|
+
rtc0: number;
|
|
7
|
+
ctrl: number;
|
|
4
8
|
readUint32(offset: number): number;
|
|
5
9
|
writeUint32(offset: number, value: number): void;
|
|
6
10
|
}
|
|
@@ -1,25 +1,67 @@
|
|
|
1
1
|
import { BasePeripheral } from './peripheral';
|
|
2
|
+
const RTC_SETUP0 = 0x04;
|
|
3
|
+
const RTC_SETUP1 = 0x08;
|
|
2
4
|
const RTC_CTRL = 0x0c;
|
|
3
5
|
const IRQ_SETUP_0 = 0x10;
|
|
6
|
+
const RTC_RTC1 = 0x18;
|
|
7
|
+
const RTC_RTC0 = 0x1c;
|
|
8
|
+
const RTC_ENABLE_BITS = 0x01;
|
|
4
9
|
const RTC_ACTIVE_BITS = 0x2;
|
|
10
|
+
const RTC_LOAD_BITS = 0x10;
|
|
5
11
|
export class RP2040RTC extends BasePeripheral {
|
|
6
12
|
constructor() {
|
|
7
13
|
super(...arguments);
|
|
8
|
-
this.
|
|
14
|
+
this.setup0 = 0;
|
|
15
|
+
this.setup1 = 0;
|
|
16
|
+
this.rtc1 = 0;
|
|
17
|
+
this.rtc0 = 0;
|
|
18
|
+
this.ctrl = 0;
|
|
9
19
|
}
|
|
10
20
|
readUint32(offset) {
|
|
11
21
|
switch (offset) {
|
|
22
|
+
case RTC_SETUP0:
|
|
23
|
+
return this.setup0;
|
|
24
|
+
case RTC_SETUP1:
|
|
25
|
+
return this.setup1;
|
|
12
26
|
case RTC_CTRL:
|
|
13
|
-
return this.
|
|
27
|
+
return this.ctrl;
|
|
14
28
|
case IRQ_SETUP_0:
|
|
15
29
|
return 0;
|
|
30
|
+
case RTC_RTC1:
|
|
31
|
+
return this.rtc1;
|
|
32
|
+
case RTC_RTC0:
|
|
33
|
+
return this.rtc0;
|
|
16
34
|
}
|
|
17
35
|
return super.readUint32(offset);
|
|
18
36
|
}
|
|
19
37
|
writeUint32(offset, value) {
|
|
20
38
|
switch (offset) {
|
|
39
|
+
case RTC_SETUP0:
|
|
40
|
+
this.setup0 = value;
|
|
41
|
+
break;
|
|
42
|
+
case RTC_SETUP1:
|
|
43
|
+
this.setup1 = value;
|
|
44
|
+
break;
|
|
21
45
|
case RTC_CTRL:
|
|
22
|
-
|
|
46
|
+
// Though RTC_LOAD_BITS is type SC and should be cleared on next cycle, pico-sdk write
|
|
47
|
+
// RTC_LOAD_BITS & RTC_ENABLE_BITS seperatly.
|
|
48
|
+
// https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2_common/hardware_rtc/rtc.c#L76-L80
|
|
49
|
+
if (value & RTC_LOAD_BITS) {
|
|
50
|
+
this.ctrl |= RTC_LOAD_BITS;
|
|
51
|
+
}
|
|
52
|
+
if (value & RTC_ENABLE_BITS) {
|
|
53
|
+
this.ctrl |= RTC_ENABLE_BITS;
|
|
54
|
+
this.ctrl |= RTC_ACTIVE_BITS;
|
|
55
|
+
if (this.ctrl & RTC_LOAD_BITS) {
|
|
56
|
+
this.rtc1 = this.setup0;
|
|
57
|
+
this.rtc0 = this.setup1;
|
|
58
|
+
this.ctrl &= ~RTC_LOAD_BITS;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
this.ctrl &= ~RTC_ENABLE_BITS;
|
|
63
|
+
this.ctrl &= ~RTC_ACTIVE_BITS;
|
|
64
|
+
}
|
|
23
65
|
break;
|
|
24
66
|
default:
|
|
25
67
|
super.writeUint32(offset, value);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BasePeripheral } from './peripheral';
|
|
2
|
+
const PLATFORM = 0;
|
|
3
|
+
const ASIC = 1;
|
|
4
|
+
export class RPTBMAN extends BasePeripheral {
|
|
5
|
+
readUint32(offset) {
|
|
6
|
+
switch (offset) {
|
|
7
|
+
case PLATFORM:
|
|
8
|
+
return ASIC;
|
|
9
|
+
default:
|
|
10
|
+
return super.readUint32(offset);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
package/dist/esm/rp2040.d.ts
CHANGED
|
@@ -14,7 +14,6 @@ import { RPUSBController } from './peripherals/usb';
|
|
|
14
14
|
import { RPSIO } from './sio';
|
|
15
15
|
import { Logger } from './utils/logging';
|
|
16
16
|
export declare const FLASH_START_ADDRESS = 268435456;
|
|
17
|
-
export declare const FLASH_END_ADDRESS = 335544320;
|
|
18
17
|
export declare const RAM_START_ADDRESS = 536870912;
|
|
19
18
|
export declare const DPRAM_START_ADDRESS = 1343225856;
|
|
20
19
|
export declare const SIO_START_ADDRESS = 3489660928;
|
package/dist/esm/rp2040.js
CHANGED
|
@@ -23,8 +23,8 @@ import { RPUART } from './peripherals/uart';
|
|
|
23
23
|
import { RPUSBController } from './peripherals/usb';
|
|
24
24
|
import { RPSIO } from './sio';
|
|
25
25
|
import { ConsoleLogger, LogLevel } from './utils/logging';
|
|
26
|
+
import { RPTBMAN } from './peripherals/tbman';
|
|
26
27
|
export const FLASH_START_ADDRESS = 0x10000000;
|
|
27
|
-
export const FLASH_END_ADDRESS = 0x14000000;
|
|
28
28
|
export const RAM_START_ADDRESS = 0x20000000;
|
|
29
29
|
export const DPRAM_START_ADDRESS = 0x50100000;
|
|
30
30
|
export const SIO_START_ADDRESS = 0xd0000000;
|
|
@@ -131,7 +131,7 @@ export class RP2040 {
|
|
|
131
131
|
0x4005c: new RP2040RTC(this, 'RTC_BASE'),
|
|
132
132
|
0x40060: new UnimplementedPeripheral(this, 'ROSC_BASE'),
|
|
133
133
|
0x40064: new UnimplementedPeripheral(this, 'VREG_AND_CHIP_RESET_BASE'),
|
|
134
|
-
0x4006c: new
|
|
134
|
+
0x4006c: new RPTBMAN(this, 'TBMAN_BASE'),
|
|
135
135
|
0x50000: this.dma,
|
|
136
136
|
0x50110: this.usbCtrl,
|
|
137
137
|
0x50200: this.pio[0],
|
|
@@ -164,7 +164,8 @@ export class RP2040 {
|
|
|
164
164
|
if (address < bootrom.length * 4) {
|
|
165
165
|
return bootrom[address / 4];
|
|
166
166
|
}
|
|
167
|
-
else if (address >= FLASH_START_ADDRESS &&
|
|
167
|
+
else if (address >= FLASH_START_ADDRESS &&
|
|
168
|
+
address < FLASH_START_ADDRESS + this.flash.length) {
|
|
168
169
|
return this.flashView.getUint32(address - FLASH_START_ADDRESS, true);
|
|
169
170
|
}
|
|
170
171
|
else if (address >= RAM_START_ADDRESS && address < RAM_START_ADDRESS + this.sram.length) {
|
|
@@ -192,7 +193,7 @@ export class RP2040 {
|
|
|
192
193
|
}
|
|
193
194
|
/** We assume the address is 16-bit aligned */
|
|
194
195
|
readUint16(address) {
|
|
195
|
-
if (address >= FLASH_START_ADDRESS && address <
|
|
196
|
+
if (address >= FLASH_START_ADDRESS && address < FLASH_START_ADDRESS + this.flash.length) {
|
|
196
197
|
return this.flashView.getUint16(address - FLASH_START_ADDRESS, true);
|
|
197
198
|
}
|
|
198
199
|
else if (address >= RAM_START_ADDRESS && address < RAM_START_ADDRESS + this.sram.length) {
|
|
@@ -202,7 +203,7 @@ export class RP2040 {
|
|
|
202
203
|
return address & 0x2 ? (value & 0xffff0000) >>> 16 : value & 0xffff;
|
|
203
204
|
}
|
|
204
205
|
readUint8(address) {
|
|
205
|
-
if (address >= FLASH_START_ADDRESS && address <
|
|
206
|
+
if (address >= FLASH_START_ADDRESS && address < FLASH_START_ADDRESS + this.flash.length) {
|
|
206
207
|
return this.flash[address - FLASH_START_ADDRESS];
|
|
207
208
|
}
|
|
208
209
|
else if (address >= RAM_START_ADDRESS && address < RAM_START_ADDRESS + this.sram.length) {
|
|
@@ -223,7 +224,8 @@ export class RP2040 {
|
|
|
223
224
|
else if (address < bootrom.length * 4) {
|
|
224
225
|
bootrom[address / 4] = value;
|
|
225
226
|
}
|
|
226
|
-
else if (address >= FLASH_START_ADDRESS &&
|
|
227
|
+
else if (address >= FLASH_START_ADDRESS &&
|
|
228
|
+
address < FLASH_START_ADDRESS + this.flash.length) {
|
|
227
229
|
this.flashView.setUint32(address - FLASH_START_ADDRESS, value, true);
|
|
228
230
|
}
|
|
229
231
|
else if (address >= RAM_START_ADDRESS && address < RAM_START_ADDRESS + this.sram.length) {
|