rp2040js 0.17.10 → 0.17.12
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/busctrl.d.ts +10 -0
- package/dist/cjs/peripherals/busctrl.js +84 -0
- package/dist/cjs/peripherals/ppb.d.ts +8 -4
- package/dist/cjs/peripherals/ppb.js +34 -37
- package/dist/cjs/rp2040.js +3 -2
- package/dist/cjs/utils/timer32.js +1 -1
- package/dist/esm/peripherals/busctrl.d.ts +10 -0
- package/dist/esm/peripherals/busctrl.js +80 -0
- package/dist/esm/peripherals/ppb.d.ts +8 -4
- package/dist/esm/peripherals/ppb.js +34 -37
- package/dist/esm/rp2040.js +3 -2
- package/dist/esm/utils/timer32.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RP2040 } from '../rp2040';
|
|
2
|
+
import { BasePeripheral, Peripheral } from './peripheral';
|
|
3
|
+
export declare class RPBUSCTRL extends BasePeripheral implements Peripheral {
|
|
4
|
+
voltageSelect: number;
|
|
5
|
+
readonly perfCtr: number[];
|
|
6
|
+
readonly perfSel: number[];
|
|
7
|
+
constructor(rp2040: RP2040, name: string);
|
|
8
|
+
readUint32(offset: number): number;
|
|
9
|
+
writeUint32(offset: number, value: number): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RPBUSCTRL = void 0;
|
|
4
|
+
const peripheral_1 = require("./peripheral");
|
|
5
|
+
/** Bus priority acknowledge */
|
|
6
|
+
const BUS_PRIORITY_ACK = 0x004;
|
|
7
|
+
/** Bus fabric performance counter 0 */
|
|
8
|
+
const PERFCTR0 = 0x008;
|
|
9
|
+
/** Bus fabric performance event select for PERFCTR0 */
|
|
10
|
+
const PERFSEL0 = 0x00c;
|
|
11
|
+
/** Bus fabric performance counter 1 */
|
|
12
|
+
const PERFCTR1 = 0x010;
|
|
13
|
+
/** Bus fabric performance event select for PERFCTR1 */
|
|
14
|
+
const PERFSEL1 = 0x014;
|
|
15
|
+
/** Bus fabric performance counter 2 */
|
|
16
|
+
const PERFCTR2 = 0x018;
|
|
17
|
+
/** Bus fabric performance event select for PERFCTR2 */
|
|
18
|
+
const PERFSEL2 = 0x01c;
|
|
19
|
+
/** Bus fabric performance counter 3 */
|
|
20
|
+
const PERFCTR3 = 0x020;
|
|
21
|
+
/** Bus fabric performance event select for PERFCTR3 */
|
|
22
|
+
const PERFSEL3 = 0x024;
|
|
23
|
+
class RPBUSCTRL extends peripheral_1.BasePeripheral {
|
|
24
|
+
constructor(rp2040, name) {
|
|
25
|
+
super(rp2040, name);
|
|
26
|
+
this.voltageSelect = 0;
|
|
27
|
+
this.perfCtr = [0, 0, 0, 0];
|
|
28
|
+
this.perfSel = [0x1f, 0x1f, 0x1f, 0x1f];
|
|
29
|
+
}
|
|
30
|
+
readUint32(offset) {
|
|
31
|
+
switch (offset) {
|
|
32
|
+
case BUS_PRIORITY_ACK:
|
|
33
|
+
return 1;
|
|
34
|
+
case PERFCTR0:
|
|
35
|
+
return this.perfCtr[0];
|
|
36
|
+
case PERFSEL0:
|
|
37
|
+
return this.perfSel[0];
|
|
38
|
+
case PERFCTR1:
|
|
39
|
+
return this.perfCtr[1];
|
|
40
|
+
case PERFSEL1:
|
|
41
|
+
return this.perfSel[1];
|
|
42
|
+
case PERFCTR2:
|
|
43
|
+
return this.perfCtr[2];
|
|
44
|
+
case PERFSEL2:
|
|
45
|
+
return this.perfSel[2];
|
|
46
|
+
case PERFCTR3:
|
|
47
|
+
return this.perfCtr[3];
|
|
48
|
+
case PERFSEL3:
|
|
49
|
+
return this.perfSel[3];
|
|
50
|
+
}
|
|
51
|
+
return super.readUint32(offset);
|
|
52
|
+
}
|
|
53
|
+
writeUint32(offset, value) {
|
|
54
|
+
switch (offset) {
|
|
55
|
+
case PERFCTR0:
|
|
56
|
+
this.perfCtr[0] = 0;
|
|
57
|
+
break;
|
|
58
|
+
case PERFSEL0:
|
|
59
|
+
this.perfSel[0] = value & 0x1f;
|
|
60
|
+
break;
|
|
61
|
+
case PERFCTR1:
|
|
62
|
+
this.perfCtr[1] = 0;
|
|
63
|
+
break;
|
|
64
|
+
case PERFSEL1:
|
|
65
|
+
this.perfSel[1] = value & 0x1f;
|
|
66
|
+
break;
|
|
67
|
+
case PERFCTR2:
|
|
68
|
+
this.perfCtr[2] = 0;
|
|
69
|
+
break;
|
|
70
|
+
case PERFSEL2:
|
|
71
|
+
this.perfSel[2] = value & 0x1f;
|
|
72
|
+
break;
|
|
73
|
+
case PERFCTR3:
|
|
74
|
+
this.perfCtr[3] = 0;
|
|
75
|
+
break;
|
|
76
|
+
case PERFSEL3:
|
|
77
|
+
this.perfSel[3] = value & 0x1f;
|
|
78
|
+
break;
|
|
79
|
+
default:
|
|
80
|
+
super.writeUint32(offset, value);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.RPBUSCTRL = RPBUSCTRL;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RP2040 } from '../rp2040';
|
|
2
|
+
import { Timer32, Timer32PeriodicAlarm } from '../utils/timer32';
|
|
2
3
|
import { BasePeripheral, Peripheral } from './peripheral';
|
|
3
4
|
export declare const CPUID = 3328;
|
|
4
5
|
export declare const ICSR = 3332;
|
|
@@ -12,10 +13,13 @@ export declare const SHPR3 = 3360;
|
|
|
12
13
|
*/
|
|
13
14
|
export declare class RPPPB extends BasePeripheral implements Peripheral {
|
|
14
15
|
systickCountFlag: boolean;
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
systickClkSource: boolean;
|
|
17
|
+
systickIntEnable: boolean;
|
|
17
18
|
systickReload: number;
|
|
18
|
-
systickTimer:
|
|
19
|
+
readonly systickTimer: Timer32;
|
|
20
|
+
readonly systickAlarm: Timer32PeriodicAlarm;
|
|
21
|
+
constructor(rp2040: RP2040, name: string);
|
|
22
|
+
reset(): void;
|
|
19
23
|
readUint32(offset: number): number;
|
|
20
24
|
writeUint32(offset: number, value: number): void;
|
|
21
25
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RPPPB = exports.SHPR3 = exports.SHPR2 = exports.VTOR = exports.ICSR = exports.CPUID = void 0;
|
|
4
4
|
const irq_1 = require("../irq");
|
|
5
|
+
const timer32_1 = require("../utils/timer32");
|
|
5
6
|
const peripheral_1 = require("./peripheral");
|
|
6
7
|
exports.CPUID = 0xd00;
|
|
7
8
|
exports.ICSR = 0xd04;
|
|
@@ -43,14 +44,32 @@ const VECTACTIVE_SHIFT = 0;
|
|
|
43
44
|
* Included peripheral: NVIC, SysTick timer
|
|
44
45
|
*/
|
|
45
46
|
class RPPPB extends peripheral_1.BasePeripheral {
|
|
46
|
-
constructor() {
|
|
47
|
-
super(
|
|
47
|
+
constructor(rp2040, name) {
|
|
48
|
+
super(rp2040, name);
|
|
48
49
|
// Systick
|
|
49
50
|
this.systickCountFlag = false;
|
|
50
|
-
this.
|
|
51
|
-
this.
|
|
51
|
+
this.systickClkSource = false;
|
|
52
|
+
this.systickIntEnable = false;
|
|
52
53
|
this.systickReload = 0;
|
|
53
|
-
this.systickTimer =
|
|
54
|
+
this.systickTimer = new timer32_1.Timer32(this.rp2040.clock, this.rp2040.clkSys);
|
|
55
|
+
this.systickAlarm = new timer32_1.Timer32PeriodicAlarm(this.systickTimer, () => {
|
|
56
|
+
this.systickCountFlag = true;
|
|
57
|
+
if (this.systickIntEnable) {
|
|
58
|
+
this.rp2040.core.pendingSystick = true;
|
|
59
|
+
this.rp2040.core.interruptsUpdated = true;
|
|
60
|
+
}
|
|
61
|
+
this.systickTimer.set(this.systickReload);
|
|
62
|
+
});
|
|
63
|
+
this.systickTimer.top = 0xffffff;
|
|
64
|
+
this.systickTimer.mode = timer32_1.TimerMode.Decrement;
|
|
65
|
+
this.systickAlarm.target = 0;
|
|
66
|
+
this.systickAlarm.enable = true;
|
|
67
|
+
this.reset();
|
|
68
|
+
}
|
|
69
|
+
reset() {
|
|
70
|
+
this.writeUint32(SYST_CSR, 0);
|
|
71
|
+
this.writeUint32(SYST_RVR, 0xffffff);
|
|
72
|
+
this.systickTimer.set(0xffffff);
|
|
54
73
|
}
|
|
55
74
|
readUint32(offset) {
|
|
56
75
|
const { rp2040 } = this;
|
|
@@ -106,16 +125,14 @@ class RPPPB extends peripheral_1.BasePeripheral {
|
|
|
106
125
|
/* SysTick */
|
|
107
126
|
case SYST_CSR: {
|
|
108
127
|
const countFlagValue = this.systickCountFlag ? 1 << 16 : 0;
|
|
128
|
+
const clkSourceValue = this.systickClkSource ? 1 << 2 : 0;
|
|
129
|
+
const tickIntValue = this.systickIntEnable ? 1 << 1 : 0;
|
|
130
|
+
const enableFlagValue = this.systickTimer.enable ? 1 << 0 : 0;
|
|
109
131
|
this.systickCountFlag = false;
|
|
110
|
-
return countFlagValue |
|
|
111
|
-
}
|
|
112
|
-
case SYST_CVR: {
|
|
113
|
-
const delta = (rp2040.core.cycles - this.systickLastZero) % (this.systickReload + 1);
|
|
114
|
-
if (!delta) {
|
|
115
|
-
return 0;
|
|
116
|
-
}
|
|
117
|
-
return this.systickReload - (delta - 1);
|
|
132
|
+
return countFlagValue | clkSourceValue | tickIntValue | enableFlagValue;
|
|
118
133
|
}
|
|
134
|
+
case SYST_CVR:
|
|
135
|
+
return this.systickTimer.counter;
|
|
119
136
|
case SYST_RVR:
|
|
120
137
|
return this.systickReload;
|
|
121
138
|
case SYST_CALIB:
|
|
@@ -194,32 +211,12 @@ class RPPPB extends peripheral_1.BasePeripheral {
|
|
|
194
211
|
return;
|
|
195
212
|
// SysTick
|
|
196
213
|
case SYST_CSR:
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
if (interrupt && !prevInterrupt) {
|
|
201
|
-
// TODO: adjust the timer based on the current systick value
|
|
202
|
-
const systickCallback = () => {
|
|
203
|
-
core.pendingSystick = true;
|
|
204
|
-
core.interruptsUpdated = true;
|
|
205
|
-
if (core.waiting && core.checkForInterrupts()) {
|
|
206
|
-
core.waiting = false;
|
|
207
|
-
}
|
|
208
|
-
this.systickTimer = rp2040.clock.createTimer(this.systickReload + 1, systickCallback);
|
|
209
|
-
};
|
|
210
|
-
this.systickTimer = rp2040.clock.createTimer(this.systickReload + 1, systickCallback);
|
|
211
|
-
}
|
|
212
|
-
if (prevInterrupt && interrupt) {
|
|
213
|
-
if (this.systickTimer) {
|
|
214
|
-
rp2040.clock.deleteTimer(this.systickTimer);
|
|
215
|
-
}
|
|
216
|
-
this.systickTimer = null;
|
|
217
|
-
}
|
|
218
|
-
this.systickControl = value & 0x7;
|
|
219
|
-
}
|
|
214
|
+
this.systickClkSource = value & (1 << 2) ? true : false;
|
|
215
|
+
this.systickIntEnable = value & (1 << 1) ? true : false;
|
|
216
|
+
this.systickTimer.enable = value & (1 << 0) ? true : false;
|
|
220
217
|
return;
|
|
221
218
|
case SYST_CVR:
|
|
222
|
-
this.
|
|
219
|
+
this.systickTimer.set(0);
|
|
223
220
|
return;
|
|
224
221
|
case SYST_RVR:
|
|
225
222
|
this.systickReload = value;
|
package/dist/cjs/rp2040.js
CHANGED
|
@@ -6,6 +6,7 @@ const cortex_m0_core_1 = require("./cortex-m0-core");
|
|
|
6
6
|
const gpio_pin_1 = require("./gpio-pin");
|
|
7
7
|
const irq_1 = require("./irq");
|
|
8
8
|
const adc_1 = require("./peripherals/adc");
|
|
9
|
+
const busctrl_1 = require("./peripherals/busctrl");
|
|
9
10
|
const clocks_1 = require("./peripherals/clocks");
|
|
10
11
|
const dma_1 = require("./peripherals/dma");
|
|
11
12
|
const i2c_1 = require("./peripherals/i2c");
|
|
@@ -21,12 +22,12 @@ const spi_1 = require("./peripherals/spi");
|
|
|
21
22
|
const ssi_1 = require("./peripherals/ssi");
|
|
22
23
|
const syscfg_1 = require("./peripherals/syscfg");
|
|
23
24
|
const sysinfo_1 = require("./peripherals/sysinfo");
|
|
25
|
+
const tbman_1 = require("./peripherals/tbman");
|
|
24
26
|
const timer_1 = require("./peripherals/timer");
|
|
25
27
|
const uart_1 = require("./peripherals/uart");
|
|
26
28
|
const usb_1 = require("./peripherals/usb");
|
|
27
29
|
const sio_1 = require("./sio");
|
|
28
30
|
const logging_1 = require("./utils/logging");
|
|
29
|
-
const tbman_1 = require("./peripherals/tbman");
|
|
30
31
|
exports.FLASH_START_ADDRESS = 0x10000000;
|
|
31
32
|
exports.RAM_START_ADDRESS = 0x20000000;
|
|
32
33
|
exports.APB_START_ADDRESS = 0x40000000;
|
|
@@ -121,7 +122,7 @@ class RP2040 {
|
|
|
121
122
|
0x40024: new peripheral_1.UnimplementedPeripheral(this, 'XOSC_BASE'),
|
|
122
123
|
0x40028: new peripheral_1.UnimplementedPeripheral(this, 'PLL_SYS_BASE'),
|
|
123
124
|
0x4002c: new peripheral_1.UnimplementedPeripheral(this, 'PLL_USB_BASE'),
|
|
124
|
-
0x40030: new
|
|
125
|
+
0x40030: new busctrl_1.RPBUSCTRL(this, 'BUSCTRL_BASE'),
|
|
125
126
|
0x40034: this.uart[0],
|
|
126
127
|
0x40038: this.uart[1],
|
|
127
128
|
0x4003c: this.spi[0],
|
|
@@ -192,7 +192,7 @@ class Timer32PeriodicAlarm {
|
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
if (mode === TimerMode.Decrement) {
|
|
195
|
-
cycleDelta = top - cycleDelta;
|
|
195
|
+
cycleDelta = top + 1 - cycleDelta;
|
|
196
196
|
}
|
|
197
197
|
const cyclesToAlarm = cycleDelta >>> 0;
|
|
198
198
|
const microsToAlarm = timer.toMicros(cyclesToAlarm);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RP2040 } from '../rp2040';
|
|
2
|
+
import { BasePeripheral, Peripheral } from './peripheral';
|
|
3
|
+
export declare class RPBUSCTRL extends BasePeripheral implements Peripheral {
|
|
4
|
+
voltageSelect: number;
|
|
5
|
+
readonly perfCtr: number[];
|
|
6
|
+
readonly perfSel: number[];
|
|
7
|
+
constructor(rp2040: RP2040, name: string);
|
|
8
|
+
readUint32(offset: number): number;
|
|
9
|
+
writeUint32(offset: number, value: number): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { BasePeripheral } from './peripheral';
|
|
2
|
+
/** Bus priority acknowledge */
|
|
3
|
+
const BUS_PRIORITY_ACK = 0x004;
|
|
4
|
+
/** Bus fabric performance counter 0 */
|
|
5
|
+
const PERFCTR0 = 0x008;
|
|
6
|
+
/** Bus fabric performance event select for PERFCTR0 */
|
|
7
|
+
const PERFSEL0 = 0x00c;
|
|
8
|
+
/** Bus fabric performance counter 1 */
|
|
9
|
+
const PERFCTR1 = 0x010;
|
|
10
|
+
/** Bus fabric performance event select for PERFCTR1 */
|
|
11
|
+
const PERFSEL1 = 0x014;
|
|
12
|
+
/** Bus fabric performance counter 2 */
|
|
13
|
+
const PERFCTR2 = 0x018;
|
|
14
|
+
/** Bus fabric performance event select for PERFCTR2 */
|
|
15
|
+
const PERFSEL2 = 0x01c;
|
|
16
|
+
/** Bus fabric performance counter 3 */
|
|
17
|
+
const PERFCTR3 = 0x020;
|
|
18
|
+
/** Bus fabric performance event select for PERFCTR3 */
|
|
19
|
+
const PERFSEL3 = 0x024;
|
|
20
|
+
export class RPBUSCTRL extends BasePeripheral {
|
|
21
|
+
constructor(rp2040, name) {
|
|
22
|
+
super(rp2040, name);
|
|
23
|
+
this.voltageSelect = 0;
|
|
24
|
+
this.perfCtr = [0, 0, 0, 0];
|
|
25
|
+
this.perfSel = [0x1f, 0x1f, 0x1f, 0x1f];
|
|
26
|
+
}
|
|
27
|
+
readUint32(offset) {
|
|
28
|
+
switch (offset) {
|
|
29
|
+
case BUS_PRIORITY_ACK:
|
|
30
|
+
return 1;
|
|
31
|
+
case PERFCTR0:
|
|
32
|
+
return this.perfCtr[0];
|
|
33
|
+
case PERFSEL0:
|
|
34
|
+
return this.perfSel[0];
|
|
35
|
+
case PERFCTR1:
|
|
36
|
+
return this.perfCtr[1];
|
|
37
|
+
case PERFSEL1:
|
|
38
|
+
return this.perfSel[1];
|
|
39
|
+
case PERFCTR2:
|
|
40
|
+
return this.perfCtr[2];
|
|
41
|
+
case PERFSEL2:
|
|
42
|
+
return this.perfSel[2];
|
|
43
|
+
case PERFCTR3:
|
|
44
|
+
return this.perfCtr[3];
|
|
45
|
+
case PERFSEL3:
|
|
46
|
+
return this.perfSel[3];
|
|
47
|
+
}
|
|
48
|
+
return super.readUint32(offset);
|
|
49
|
+
}
|
|
50
|
+
writeUint32(offset, value) {
|
|
51
|
+
switch (offset) {
|
|
52
|
+
case PERFCTR0:
|
|
53
|
+
this.perfCtr[0] = 0;
|
|
54
|
+
break;
|
|
55
|
+
case PERFSEL0:
|
|
56
|
+
this.perfSel[0] = value & 0x1f;
|
|
57
|
+
break;
|
|
58
|
+
case PERFCTR1:
|
|
59
|
+
this.perfCtr[1] = 0;
|
|
60
|
+
break;
|
|
61
|
+
case PERFSEL1:
|
|
62
|
+
this.perfSel[1] = value & 0x1f;
|
|
63
|
+
break;
|
|
64
|
+
case PERFCTR2:
|
|
65
|
+
this.perfCtr[2] = 0;
|
|
66
|
+
break;
|
|
67
|
+
case PERFSEL2:
|
|
68
|
+
this.perfSel[2] = value & 0x1f;
|
|
69
|
+
break;
|
|
70
|
+
case PERFCTR3:
|
|
71
|
+
this.perfCtr[3] = 0;
|
|
72
|
+
break;
|
|
73
|
+
case PERFSEL3:
|
|
74
|
+
this.perfSel[3] = value & 0x1f;
|
|
75
|
+
break;
|
|
76
|
+
default:
|
|
77
|
+
super.writeUint32(offset, value);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RP2040 } from '../rp2040';
|
|
2
|
+
import { Timer32, Timer32PeriodicAlarm } from '../utils/timer32';
|
|
2
3
|
import { BasePeripheral, Peripheral } from './peripheral';
|
|
3
4
|
export declare const CPUID = 3328;
|
|
4
5
|
export declare const ICSR = 3332;
|
|
@@ -12,10 +13,13 @@ export declare const SHPR3 = 3360;
|
|
|
12
13
|
*/
|
|
13
14
|
export declare class RPPPB extends BasePeripheral implements Peripheral {
|
|
14
15
|
systickCountFlag: boolean;
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
systickClkSource: boolean;
|
|
17
|
+
systickIntEnable: boolean;
|
|
17
18
|
systickReload: number;
|
|
18
|
-
systickTimer:
|
|
19
|
+
readonly systickTimer: Timer32;
|
|
20
|
+
readonly systickAlarm: Timer32PeriodicAlarm;
|
|
21
|
+
constructor(rp2040: RP2040, name: string);
|
|
22
|
+
reset(): void;
|
|
19
23
|
readUint32(offset: number): number;
|
|
20
24
|
writeUint32(offset: number, value: number): void;
|
|
21
25
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MAX_HARDWARE_IRQ } from '../irq';
|
|
2
|
+
import { Timer32, Timer32PeriodicAlarm, TimerMode } from '../utils/timer32';
|
|
2
3
|
import { BasePeripheral } from './peripheral';
|
|
3
4
|
export const CPUID = 0xd00;
|
|
4
5
|
export const ICSR = 0xd04;
|
|
@@ -40,14 +41,32 @@ const VECTACTIVE_SHIFT = 0;
|
|
|
40
41
|
* Included peripheral: NVIC, SysTick timer
|
|
41
42
|
*/
|
|
42
43
|
export class RPPPB extends BasePeripheral {
|
|
43
|
-
constructor() {
|
|
44
|
-
super(
|
|
44
|
+
constructor(rp2040, name) {
|
|
45
|
+
super(rp2040, name);
|
|
45
46
|
// Systick
|
|
46
47
|
this.systickCountFlag = false;
|
|
47
|
-
this.
|
|
48
|
-
this.
|
|
48
|
+
this.systickClkSource = false;
|
|
49
|
+
this.systickIntEnable = false;
|
|
49
50
|
this.systickReload = 0;
|
|
50
|
-
this.systickTimer =
|
|
51
|
+
this.systickTimer = new Timer32(this.rp2040.clock, this.rp2040.clkSys);
|
|
52
|
+
this.systickAlarm = new Timer32PeriodicAlarm(this.systickTimer, () => {
|
|
53
|
+
this.systickCountFlag = true;
|
|
54
|
+
if (this.systickIntEnable) {
|
|
55
|
+
this.rp2040.core.pendingSystick = true;
|
|
56
|
+
this.rp2040.core.interruptsUpdated = true;
|
|
57
|
+
}
|
|
58
|
+
this.systickTimer.set(this.systickReload);
|
|
59
|
+
});
|
|
60
|
+
this.systickTimer.top = 0xffffff;
|
|
61
|
+
this.systickTimer.mode = TimerMode.Decrement;
|
|
62
|
+
this.systickAlarm.target = 0;
|
|
63
|
+
this.systickAlarm.enable = true;
|
|
64
|
+
this.reset();
|
|
65
|
+
}
|
|
66
|
+
reset() {
|
|
67
|
+
this.writeUint32(SYST_CSR, 0);
|
|
68
|
+
this.writeUint32(SYST_RVR, 0xffffff);
|
|
69
|
+
this.systickTimer.set(0xffffff);
|
|
51
70
|
}
|
|
52
71
|
readUint32(offset) {
|
|
53
72
|
const { rp2040 } = this;
|
|
@@ -103,16 +122,14 @@ export class RPPPB extends BasePeripheral {
|
|
|
103
122
|
/* SysTick */
|
|
104
123
|
case SYST_CSR: {
|
|
105
124
|
const countFlagValue = this.systickCountFlag ? 1 << 16 : 0;
|
|
125
|
+
const clkSourceValue = this.systickClkSource ? 1 << 2 : 0;
|
|
126
|
+
const tickIntValue = this.systickIntEnable ? 1 << 1 : 0;
|
|
127
|
+
const enableFlagValue = this.systickTimer.enable ? 1 << 0 : 0;
|
|
106
128
|
this.systickCountFlag = false;
|
|
107
|
-
return countFlagValue |
|
|
108
|
-
}
|
|
109
|
-
case SYST_CVR: {
|
|
110
|
-
const delta = (rp2040.core.cycles - this.systickLastZero) % (this.systickReload + 1);
|
|
111
|
-
if (!delta) {
|
|
112
|
-
return 0;
|
|
113
|
-
}
|
|
114
|
-
return this.systickReload - (delta - 1);
|
|
129
|
+
return countFlagValue | clkSourceValue | tickIntValue | enableFlagValue;
|
|
115
130
|
}
|
|
131
|
+
case SYST_CVR:
|
|
132
|
+
return this.systickTimer.counter;
|
|
116
133
|
case SYST_RVR:
|
|
117
134
|
return this.systickReload;
|
|
118
135
|
case SYST_CALIB:
|
|
@@ -191,32 +208,12 @@ export class RPPPB extends BasePeripheral {
|
|
|
191
208
|
return;
|
|
192
209
|
// SysTick
|
|
193
210
|
case SYST_CSR:
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
if (interrupt && !prevInterrupt) {
|
|
198
|
-
// TODO: adjust the timer based on the current systick value
|
|
199
|
-
const systickCallback = () => {
|
|
200
|
-
core.pendingSystick = true;
|
|
201
|
-
core.interruptsUpdated = true;
|
|
202
|
-
if (core.waiting && core.checkForInterrupts()) {
|
|
203
|
-
core.waiting = false;
|
|
204
|
-
}
|
|
205
|
-
this.systickTimer = rp2040.clock.createTimer(this.systickReload + 1, systickCallback);
|
|
206
|
-
};
|
|
207
|
-
this.systickTimer = rp2040.clock.createTimer(this.systickReload + 1, systickCallback);
|
|
208
|
-
}
|
|
209
|
-
if (prevInterrupt && interrupt) {
|
|
210
|
-
if (this.systickTimer) {
|
|
211
|
-
rp2040.clock.deleteTimer(this.systickTimer);
|
|
212
|
-
}
|
|
213
|
-
this.systickTimer = null;
|
|
214
|
-
}
|
|
215
|
-
this.systickControl = value & 0x7;
|
|
216
|
-
}
|
|
211
|
+
this.systickClkSource = value & (1 << 2) ? true : false;
|
|
212
|
+
this.systickIntEnable = value & (1 << 1) ? true : false;
|
|
213
|
+
this.systickTimer.enable = value & (1 << 0) ? true : false;
|
|
217
214
|
return;
|
|
218
215
|
case SYST_CVR:
|
|
219
|
-
this.
|
|
216
|
+
this.systickTimer.set(0);
|
|
220
217
|
return;
|
|
221
218
|
case SYST_RVR:
|
|
222
219
|
this.systickReload = value;
|
package/dist/esm/rp2040.js
CHANGED
|
@@ -3,6 +3,7 @@ import { CortexM0Core } from './cortex-m0-core';
|
|
|
3
3
|
import { GPIOPin } from './gpio-pin';
|
|
4
4
|
import { IRQ } from './irq';
|
|
5
5
|
import { RPADC } from './peripherals/adc';
|
|
6
|
+
import { RPBUSCTRL } from './peripherals/busctrl';
|
|
6
7
|
import { RPClocks } from './peripherals/clocks';
|
|
7
8
|
import { RPDMA } from './peripherals/dma';
|
|
8
9
|
import { RPI2C } from './peripherals/i2c';
|
|
@@ -18,12 +19,12 @@ import { RPSPI } from './peripherals/spi';
|
|
|
18
19
|
import { RPSSI } from './peripherals/ssi';
|
|
19
20
|
import { RP2040SysCfg } from './peripherals/syscfg';
|
|
20
21
|
import { RP2040SysInfo } from './peripherals/sysinfo';
|
|
22
|
+
import { RPTBMAN } from './peripherals/tbman';
|
|
21
23
|
import { RPTimer } from './peripherals/timer';
|
|
22
24
|
import { RPUART } from './peripherals/uart';
|
|
23
25
|
import { RPUSBController } from './peripherals/usb';
|
|
24
26
|
import { RPSIO } from './sio';
|
|
25
27
|
import { ConsoleLogger, LogLevel } from './utils/logging';
|
|
26
|
-
import { RPTBMAN } from './peripherals/tbman';
|
|
27
28
|
export const FLASH_START_ADDRESS = 0x10000000;
|
|
28
29
|
export const RAM_START_ADDRESS = 0x20000000;
|
|
29
30
|
export const APB_START_ADDRESS = 0x40000000;
|
|
@@ -118,7 +119,7 @@ export class RP2040 {
|
|
|
118
119
|
0x40024: new UnimplementedPeripheral(this, 'XOSC_BASE'),
|
|
119
120
|
0x40028: new UnimplementedPeripheral(this, 'PLL_SYS_BASE'),
|
|
120
121
|
0x4002c: new UnimplementedPeripheral(this, 'PLL_USB_BASE'),
|
|
121
|
-
0x40030: new
|
|
122
|
+
0x40030: new RPBUSCTRL(this, 'BUSCTRL_BASE'),
|
|
122
123
|
0x40034: this.uart[0],
|
|
123
124
|
0x40038: this.uart[1],
|
|
124
125
|
0x4003c: this.spi[0],
|
|
@@ -188,7 +188,7 @@ export class Timer32PeriodicAlarm {
|
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
if (mode === TimerMode.Decrement) {
|
|
191
|
-
cycleDelta = top - cycleDelta;
|
|
191
|
+
cycleDelta = top + 1 - cycleDelta;
|
|
192
192
|
}
|
|
193
193
|
const cyclesToAlarm = cycleDelta >>> 0;
|
|
194
194
|
const microsToAlarm = timer.toMicros(cyclesToAlarm);
|