Skip to content

Commit

Permalink
spi2: allow optional CS pin in SPIInterface
Browse files Browse the repository at this point in the history
Matches capability in differential versions
  • Loading branch information
drewrisinger committed Jun 22, 2021
1 parent dad351a commit fe23a9a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions misoc/cores/spi2.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def __init__(self, data_width=32, div_width=8):
class SPIInterface(Module):
"""Drive one or more SPI buses with a single interface."""
def __init__(self, *pads):
self.cs = Signal(sum(len(p.cs_n) for p in pads))
self.cs = Signal(sum(len(getattr(p, "cs_n", [0])) for p in pads))
self.cs_polarity = Signal.like(self.cs)
self.clk_next = Signal()
self.clk_polarity = Signal()
Expand All @@ -236,18 +236,17 @@ def __init__(self, *pads):

i = 0
for p in pads:
n = len(p.cs_n)
n = len(getattr(p, "cs_n", [0]))
cs = TSTriple(n)
cs.o.reset = C((1 << n) - 1)
clk = TSTriple()
mosi = TSTriple()
miso = TSTriple()
miso_reg = Signal(reset_less=True)
mosi_reg = Signal(reset_less=True)
self.specials += [
cs.get_tristate(p.cs_n),
clk.get_tristate(p.clk),
]
self.specials += clk.get_tristate(p.clk)
if hasattr(p, "cs_n"):
self.specials += cs.get_tristate(p.cs_n)
if hasattr(p, "mosi"):
self.specials += mosi.get_tristate(p.mosi)
if hasattr(p, "miso"):
Expand Down

0 comments on commit fe23a9a

Please sign in to comment.