Skip to content

Commit fe23a9a

Browse files
committed
spi2: allow optional CS pin in SPIInterface
Matches capability in differential versions
1 parent dad351a commit fe23a9a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

misoc/cores/spi2.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def __init__(self, data_width=32, div_width=8):
222222
class SPIInterface(Module):
223223
"""Drive one or more SPI buses with a single interface."""
224224
def __init__(self, *pads):
225-
self.cs = Signal(sum(len(p.cs_n) for p in pads))
225+
self.cs = Signal(sum(len(getattr(p, "cs_n", [0])) for p in pads))
226226
self.cs_polarity = Signal.like(self.cs)
227227
self.clk_next = Signal()
228228
self.clk_polarity = Signal()
@@ -236,18 +236,17 @@ def __init__(self, *pads):
236236

237237
i = 0
238238
for p in pads:
239-
n = len(p.cs_n)
239+
n = len(getattr(p, "cs_n", [0]))
240240
cs = TSTriple(n)
241241
cs.o.reset = C((1 << n) - 1)
242242
clk = TSTriple()
243243
mosi = TSTriple()
244244
miso = TSTriple()
245245
miso_reg = Signal(reset_less=True)
246246
mosi_reg = Signal(reset_less=True)
247-
self.specials += [
248-
cs.get_tristate(p.cs_n),
249-
clk.get_tristate(p.clk),
250-
]
247+
self.specials += clk.get_tristate(p.clk)
248+
if hasattr(p, "cs_n"):
249+
self.specials += cs.get_tristate(p.cs_n)
251250
if hasattr(p, "mosi"):
252251
self.specials += mosi.get_tristate(p.mosi)
253252
if hasattr(p, "miso"):

0 commit comments

Comments
 (0)