Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/nmigen-boards
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: a3759b11930f
Choose a base ref
...
head repository: m-labs/nmigen-boards
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 11971f1b13df
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Jul 10, 2019

  1. dev.spi: Update SPIResources to accept a name and direction.

    cr1901 authored and whitequark committed Jul 10, 2019
    Copy the full SHA
    11971f1 View commit details
Showing with 22 additions and 8 deletions.
  1. +22 −8 nmigen_boards/dev/spi.py
30 changes: 22 additions & 8 deletions nmigen_boards/dev/spi.py
Original file line number Diff line number Diff line change
@@ -4,16 +4,30 @@
__all__ = ["SPIResource"]


def SPIResource(number, *, cs, clk, mosi, miso, int=None, reset=None, attrs=None):
def SPIResource(*args, cs, clk, mosi, miso, int=None, reset=None, attrs=None, role="host"):
assert role in ("host", "device")

io = []
io.append(Subsignal("cs", PinsN(cs, dir="o")))
io.append(Subsignal("clk", Pins(clk, dir="o")))
io.append(Subsignal("mosi", Pins(mosi, dir="o")))
io.append(Subsignal("miso", Pins(miso, dir="i")))
if role == "host":
io.append(Subsignal("cs", PinsN(cs, dir="o")))
io.append(Subsignal("clk", Pins(clk, dir="o", assert_width=1)))
io.append(Subsignal("mosi", Pins(mosi, dir="o", assert_width=1)))
io.append(Subsignal("miso", Pins(miso, dir="i", assert_width=1)))
else: # device
io.append(Subsignal("cs", PinsN(cs, dir="i", assert_width=1)))
io.append(Subsignal("clk", Pins(clk, dir="i", assert_width=1)))
io.append(Subsignal("mosi", Pins(mosi, dir="i", assert_width=1)))
io.append(Subsignal("miso", Pins(miso, dir="oe", assert_width=1)))
if int is not None:
io.append(Subsignal("int", Pins(int, dir="i")))
if role == "host":
io.append(Subsignal("int", Pins(int, dir="i")))
else:
io.append(Subsignal("int", Pins(int, dir="oe", assert_width=1)))
if reset is not None:
io.append(Subsignal("reset", Pins(reset, dir="o")))
if role == "host":
io.append(Subsignal("reset", Pins(reset, dir="o")))
else:
io.append(Subsignal("reset", Pins(reset, dir="i", assert_width=1)))
if attrs is not None:
io.append(attrs)
return Resource("spi", number, *io)
return Resource.family(*args, default_name="spi", ios=io)