rp2040js 0.17.11 → 0.17.13

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.
@@ -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;
@@ -79,10 +79,16 @@ class RPIO extends peripheral_1.BasePeripheral {
79
79
  pin.updateIRQValue(pinRawWriteValue);
80
80
  break;
81
81
  case PROC0_INTE0:
82
- pin.irqEnableMask = pinValue;
82
+ if (pin.irqEnableMask !== pinValue) {
83
+ pin.irqEnableMask = pinValue;
84
+ this.rp2040.updateIOInterrupt();
85
+ }
83
86
  break;
84
87
  case PROC0_INTF0:
85
- pin.irqForceMask = pinValue;
88
+ if (pin.irqForceMask !== pinValue) {
89
+ pin.irqForceMask = pinValue;
90
+ this.rp2040.updateIOInterrupt();
91
+ }
86
92
  break;
87
93
  }
88
94
  }
@@ -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 peripheral_1.UnimplementedPeripheral(this, 'BUSCTRL_BASE'),
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],
@@ -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
+ }
@@ -76,10 +76,16 @@ export class RPIO extends BasePeripheral {
76
76
  pin.updateIRQValue(pinRawWriteValue);
77
77
  break;
78
78
  case PROC0_INTE0:
79
- pin.irqEnableMask = pinValue;
79
+ if (pin.irqEnableMask !== pinValue) {
80
+ pin.irqEnableMask = pinValue;
81
+ this.rp2040.updateIOInterrupt();
82
+ }
80
83
  break;
81
84
  case PROC0_INTF0:
82
- pin.irqForceMask = pinValue;
85
+ if (pin.irqForceMask !== pinValue) {
86
+ pin.irqForceMask = pinValue;
87
+ this.rp2040.updateIOInterrupt();
88
+ }
83
89
  break;
84
90
  }
85
91
  }
@@ -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 UnimplementedPeripheral(this, 'BUSCTRL_BASE'),
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],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rp2040js",
3
- "version": "0.17.11",
3
+ "version": "0.17.13",
4
4
  "description": "Raspberry Pi Pico (RP2040) Emulator",
5
5
  "repository": "https://github.com/wokwi/rp2040js",
6
6
  "keywords": [