Skip to content

Commit 2d20a69

Browse files
authored
cal/drivers: fix startup delay / default cal / touch mapping for R3.5 HW (#65)
* cal/drivers: fix startup delay / default cal / touch mapping for R3.5 HW * readme/ci: update * cal/r3.5: update cal constants
1 parent 7dbaf54 commit 2d20a69

File tree

7 files changed

+199
-14
lines changed

7 files changed

+199
-14
lines changed

.github/workflows/main.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,32 @@ jobs:
5555
name: ubuntu-build-icebreaker-r33-touch.bin
5656
path: gateware/build/icebreaker/top.bin
5757

58+
ubuntu-build-icebreaker-r35:
59+
runs-on: ubuntu-latest
60+
steps:
61+
- uses: actions/checkout@v4
62+
- uses: YosysHQ/setup-oss-cad-suite@v3
63+
- run: git submodule update --init gateware/external/no2misc
64+
- run: yosys --version
65+
- run: make HW_REV=HW_R35 BOARD=icebreaker CORE=mirror -C gateware
66+
- uses: actions/upload-artifact@v4
67+
with:
68+
name: ubuntu-build-icebreaker-r35.bin
69+
path: gateware/build/icebreaker/top.bin
70+
71+
ubuntu-build-icebreaker-r35-touch:
72+
runs-on: ubuntu-latest
73+
steps:
74+
- uses: actions/checkout@v4
75+
- uses: YosysHQ/setup-oss-cad-suite@v3
76+
- run: git submodule update --init gateware/external/no2misc
77+
- run: yosys --version
78+
- run: make HW_REV=HW_R35 BOARD=icebreaker CORE=touch_cv TOUCH=TOUCH_SENSE_ENABLED -C gateware
79+
- uses: actions/upload-artifact@v4
80+
with:
81+
name: ubuntu-build-icebreaker-r35-touch.bin
82+
path: gateware/build/icebreaker/top.bin
83+
5884
windows-build-icebreaker:
5985
runs-on: windows-latest
6086
defaults:

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Some minor improvements over R3.3, with the following changes:
3030
- Improved noise performance and DC tracking by adding an additional onboard 3.3V regulator for the analog domain.
3131
- Touch IC switched from 8-channel to 16-channel version, so that the XRESET pin is not shared with one of the touch jacks.
3232

33-
*Note: At this time, this Verilog repo is a bit out of date and refers to R3.3 everywhere, although I am shipping R3.5. The hardware is fully backward compatible besides the touch sensor mapping, so if you compile bitstreams for R3.3, they will work on R3.5. [See here for more details](https://apfaudio.github.io/tiliqua/quickstart/tlq_expander.html).*
33+
*Note: At this time, this Verilog repo is a bit out of date and refers to R3.3 in a few places, although I am shipping R3.5. I have tested this repository also on R3.5, just make sure to compile with `HW_R35`. [See here for more details](https://apfaudio.github.io/tiliqua/quickstart/tlq_expander.html).*
3434

3535
# R3.3 hardware details
3636

@@ -119,7 +119,7 @@ The project is split into 2 directories, [`hardware`](hardware) for the PCB/pane
119119

120120
# R3.1 Hardware (no longer manufactured)
121121

122-
The above README focuses on R3.3, which is currently being manufactured.
122+
The above README focuses on R3.3/R3.5, which is currently being manufactured.
123123

124124
Revision R3.1 was sold out in 2023. It's no longer manufactured, however this repository still supports it if you use the `HW_REV=HW_R31` flag when building. I left some of the old photos here in case they are useful.
125125

gateware/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ALL_BOARDS = $(shell ls boards)
22
ALL_CORES = $(shell basename --suffix=.sv -- cores/*.sv)
3-
ALL_HW_REV = "HW_R31 HW_R33"
3+
ALL_HW_REV = "HW_R31 HW_R33 HW_R35"
44
ALL_TOUCH = "TOUCH_SENSE_DISABLED TOUCH_SENSE_ENABLED"
55

66
CORE ?= mirror

gateware/cal/cal.sv

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818

1919
module cal #(
2020
parameter W = 16, // sample width
21-
`ifdef HW_R33
21+
`ifdef HW_R35
22+
parameter CAL_MEM_FILE = "cal/cal_mem_default_r35.hex"
23+
`elsif HW_R33
2224
parameter CAL_MEM_FILE = "cal/cal_mem_default_r33.hex"
2325
`else
2426
parameter CAL_MEM_FILE = "cal/cal_mem_default_r31.hex"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Input calibration constants
2+
@00000000 380 500 380 500 380 500 380 500
3+
// Output calibration constants
4+
@00000008 80 398 80 398 80 398 80 398
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
6e
2+
00
3+
a0
4+
3f
5+
00
6+
00
7+
00
8+
00
9+
00
10+
00
11+
ff
12+
ff
13+
00
14+
00
15+
80
16+
80
17+
80
18+
80
19+
80
20+
80
21+
80
22+
80
23+
00
24+
00
25+
00
26+
00
27+
00
28+
00
29+
00
30+
00
31+
04
32+
9f
33+
00
34+
b2
35+
94
36+
94
37+
00
38+
00
39+
00
40+
00
41+
00
42+
80
43+
05
44+
00
45+
00
46+
02
47+
00
48+
02
49+
00
50+
00
51+
00
52+
00
53+
00
54+
00
55+
00
56+
1e
57+
1e
58+
00
59+
00
60+
1e
61+
1e
62+
00
63+
00
64+
00
65+
01
66+
01
67+
00
68+
ff
69+
ff
70+
ff
71+
ff
72+
00
73+
00
74+
00
75+
00
76+
00
77+
00
78+
00
79+
10
80+
03
81+
00
82+
20
83+
00
84+
37
85+
01
86+
0f
87+
00
88+
0a
89+
00
90+
00
91+
00
92+
00
93+
00
94+
00
95+
00
96+
00
97+
00
98+
00
99+
00
100+
00
101+
00
102+
00
103+
00
104+
00
105+
00
106+
00
107+
00
108+
00
109+
00
110+
00
111+
00
112+
00
113+
00
114+
00
115+
00
116+
00
117+
00
118+
00
119+
00
120+
00
121+
00
122+
00
123+
00
124+
00
125+
00
126+
00
127+
00
128+
00
129+
cd
130+
92

gateware/drivers/pmod_i2c_master.sv

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ module pmod_i2c_master #(
2020
, parameter LED_CFG = "drivers/pca9635-cfg.hex"
2121
, parameter LED_CFG_BYTES = 16'd26
2222
`ifdef TOUCH_SENSE_ENABLED
23+
`ifdef HW_R35
24+
, parameter TOUCH_CFG = "drivers/cy8cmbr3108-cfg-r35.hex"
25+
`else
2326
, parameter TOUCH_CFG = "drivers/cy8cmbr3108-cfg.hex"
27+
`endif
2428
, parameter TOUCH_CFG_BYTES = 16'd130 // 0x80 + 2
2529
`endif
2630
)(
@@ -89,8 +93,13 @@ localparam I2C_DELAY1 = 0,
8993
`ifdef COCOTB_SIM
9094
localparam STARTUP_DELAY_BIT = 4;
9195
`else
96+
`ifdef HW_R35
97+
// HW R3.5 requires longer startup delay (~1.5s due to reset supervisor chip)
98+
localparam STARTUP_DELAY_BIT = 24;
99+
`else
92100
localparam STARTUP_DELAY_BIT = 17;
93101
`endif
102+
`endif
94103

95104
logic [3:0] i2c_state = I2C_DELAY1;
96105

@@ -135,7 +144,7 @@ logic err_out;
135144
logic ready;
136145

137146
// Used for startup delay.
138-
logic [23:0] delay_cnt;
147+
logic [24:0] delay_cnt;
139148

140149
// **Used for indicating POR failure of touch IC.**
141150
// Mitigation for `issues/59`: if CS2 of touch sense IC is shorted to ground
@@ -210,6 +219,8 @@ always_ff @(posedge clk) begin
210219
cmd <= I2CMASTER_STOP;
211220
`ifdef HW_R33
212221
i2c_state <= I2C_INIT_TOUCH1;
222+
`elsif HW_R35
223+
i2c_state <= I2C_INIT_TOUCH1;
213224
`else
214225
// For R31, don't try initializing touch sense
215226
i2c_state <= I2C_INIT_CODEC1;
@@ -554,16 +565,29 @@ always_ff @(posedge clk) begin
554565
i2c_state <= I2C_LED1;
555566
cmd <= I2CMASTER_STOP;
556567
end else begin
568+
`ifdef HW_R35
569+
case (nsensor)
570+
0: data_in <= 8'hC4;
571+
1: data_in <= 8'hC8;
572+
2: data_in <= 8'hCA;
573+
3: data_in <= 8'hCC;
574+
4: data_in <= 8'hCE;
575+
5: data_in <= 8'hD0;
576+
6: data_in <= 8'hD2;
577+
7: data_in <= 8'hD4;
578+
endcase
579+
`else
557580
case (nsensor)
558581
0: data_in <= 8'hBA;
559582
1: data_in <= 8'hBC;
560583
2: data_in <= 8'hBE;
561584
3: data_in <= 8'hC0;
562-
4: data_in <= 8'hC2;
563-
5: data_in <= 8'hC4;
564-
6: data_in <= 8'hC6;
565-
7: data_in <= 8'hC8;
585+
4: data_in <= 8'hC8;
586+
5: data_in <= 8'hC6;
587+
6: data_in <= 8'hC4;
588+
7: data_in <= 8'hC2;
566589
endcase
590+
`endif
567591
end
568592
end
569593
3: cmd <= I2CMASTER_STOP;
@@ -589,11 +613,10 @@ always_ff @(posedge clk) begin
589613
1: touch1 <= data_out;
590614
2: touch2 <= data_out;
591615
3: touch3 <= data_out;
592-
// R3.3 hw swaps last four vs R3.2 to improve PCB routing
593-
4: touch7 <= data_out;
594-
5: touch6 <= data_out;
595-
6: touch5 <= data_out;
596-
7: touch4 <= data_out;
616+
4: touch4 <= data_out;
617+
5: touch5 <= data_out;
618+
6: touch6 <= data_out;
619+
7: touch7 <= data_out;
597620
endcase
598621
cmd <= I2CMASTER_STOP;
599622
i2c_state <= I2C_LED1;

0 commit comments

Comments
 (0)