Skip to content

Commit 149c258

Browse files
committed
Include register info for most registers, no additional functionality
1 parent d6f9b41 commit 149c258

File tree

1 file changed

+76
-3
lines changed

1 file changed

+76
-3
lines changed

src/peripherals/ssi.ts

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,79 @@
11
import { BasePeripheral, Peripheral } from './peripheral.js';
22

3+
/* See RP2040 datasheet sect 4.10.13 */
4+
const SSI_CTRLR0 = 0x00000000;
5+
const SSI_CTRLR1 = 0x00000004;
6+
const SSI_SSIENR = 0x00000008;
7+
const SSI_MWCR = 0x0000000c;
8+
const SSI_SER = 0x00000010;
9+
const SSI_BAUDR = 0x00000014;
10+
const SSI_TXFTLR = 0x00000018;
11+
const SSI_RXFTLR = 0x0000001c;
312
const SSI_TXFLR = 0x00000020;
413
const SSI_RXFLR = 0x00000024;
514
const SSI_SR = 0x00000028;
6-
const SSI_DR0 = 0x00000060;
715
const SSI_SR_TFNF_BITS = 0x00000002;
816
const SSI_SR_TFE_BITS = 0x00000004;
917
const SSI_SR_RFNE_BITS = 0x00000008;
18+
const SSI_IMR = 0x0000002c;
19+
const SSI_ISR = 0x00000030;
20+
const SSI_RISR = 0x00000034;
21+
const SSI_TXOICR = 0x00000038;
22+
const SSI_RXOICR = 0x0000003c;
23+
const SSI_RXUICR = 0x00000040;
24+
const SSI_MSTICR = 0x00000044;
25+
const SSI_ICR = 0x00000048;
26+
const SSI_DMACR = 0x0000004c;
27+
const SSI_DMATDLR = 0x00000050;
28+
const SSI_DMARDLR = 0x00000054;
1029
/** Identification register */
1130
const SSI_IDR = 0x00000058;
1231
const SSI_VERSION_ID = 0x0000005c;
32+
const SSI_DR0 = 0x00000060;
33+
const SSI_RX_SAMPLE_DLY = 0x000000f0;
34+
const SSI_SPI_CTRL_R0 = 0x000000f4;
35+
const SSI_TXD_DRIVE_EDGE = 0x000000f8;
1336

1437
const CMD_READ_STATUS = 0x05;
1538

1639
export class RPSSI extends BasePeripheral implements Peripheral {
1740
private dr0 = 0;
41+
private txflr = 0;
42+
private rxflr = 0;
43+
private baudr = 0;
44+
private crtlr0 = 0;
45+
private crtlr1 = 0;
46+
private ssienr = 0;
47+
private spictlr0 = 0;
48+
private rxsampldly = 0;
49+
private txddriveedge = 0;
1850

1951
readUint32(offset: number) {
2052
switch (offset) {
2153
case SSI_TXFLR:
22-
return 0;
54+
return this.txflr;
2355
case SSI_RXFLR:
24-
return 0;
56+
return this.rxflr;
57+
case SSI_CTRLR0:
58+
return this.crtlr0; /* & 0x017FFFFF = b23,b25..31 reserved */
59+
case SSI_CTRLR1:
60+
return this.crtlr1;
61+
case SSI_SSIENR:
62+
return this.ssienr;
63+
case SSI_BAUDR:
64+
return this.baudr;
2565
case SSI_SR:
2666
return SSI_SR_TFE_BITS | SSI_SR_RFNE_BITS | SSI_SR_TFNF_BITS;
2767
case SSI_IDR:
2868
return 0x51535049;
2969
case SSI_VERSION_ID:
3070
return 0x3430312a;
71+
case SSI_RX_SAMPLE_DLY:
72+
return this.rxsampldly;
73+
case SSI_TXD_DRIVE_EDGE:
74+
return this.txddriveedge;
75+
case SSI_SPI_CTRL_R0:
76+
return this.spictlr0; /* b6,7,10,19..23 reserved */
3177
case SSI_DR0:
3278
return this.dr0;
3379
}
@@ -36,6 +82,33 @@ export class RPSSI extends BasePeripheral implements Peripheral {
3682

3783
writeUint32(offset: number, value: number) {
3884
switch (offset) {
85+
case SSI_TXFLR:
86+
this.txflr = value;
87+
return;
88+
case SSI_RXFLR:
89+
this.rxflr = value;
90+
return;
91+
case SSI_CTRLR0:
92+
this.crtlr0 = value; /* & 0x017FFFFF = b23,b25..31 reserved */
93+
return;
94+
case SSI_CTRLR1:
95+
this.crtlr1 = value;
96+
return;
97+
case SSI_SSIENR:
98+
this.ssienr = value;
99+
return;
100+
case SSI_BAUDR:
101+
this.baudr = value;
102+
return;
103+
case SSI_RX_SAMPLE_DLY:
104+
this.rxsampldly = value & 0xff;
105+
return;
106+
case SSI_TXD_DRIVE_EDGE:
107+
this.txddriveedge = value & 0xff;
108+
return;
109+
case SSI_SPI_CTRL_R0:
110+
this.spictlr0 = value;
111+
return;
39112
case SSI_DR0:
40113
if (value === CMD_READ_STATUS) {
41114
this.dr0 = 0; // tell stage2 that we completed a write

0 commit comments

Comments
 (0)