Skip to content

Commit fa35c22

Browse files
committed
cal/drivers: fix startup delay / default cal / touch mapping for R3.5 HW
1 parent 7dbaf54 commit fa35c22

File tree

5 files changed

+171
-12
lines changed

5 files changed

+171
-12
lines changed

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 (R3.5 defaults)
2+
@00000000 60 4fd 60 4fd 60 4fd 60 4fd
3+
// Output calibration constants (R3.5 defaults)
4+
@00000008 0 399 0 399 0 399 0 399
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)