From 8d4d940d9b4b6e4284ee3dba7c1cdba938a38dac Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Fran=C3=A7ois=20Nguyen?= Date: Wed, 3 Jul 2019 18:31:21 +0200 Subject: [PATCH] Factor out SPI resource definition. --- nmigen_boards/dev/__init__.py | 1 + nmigen_boards/dev/spi.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 nmigen_boards/dev/spi.py diff --git a/nmigen_boards/dev/__init__.py b/nmigen_boards/dev/__init__.py index f89e46a..1af4fe2 100644 --- a/nmigen_boards/dev/__init__.py +++ b/nmigen_boards/dev/__init__.py @@ -1,2 +1,3 @@ from .uart import UARTResource from .flash import SPIFlashResources +from .spi import SPIResource diff --git a/nmigen_boards/dev/spi.py b/nmigen_boards/dev/spi.py new file mode 100644 index 0000000..e8baae0 --- /dev/null +++ b/nmigen_boards/dev/spi.py @@ -0,0 +1,19 @@ +from nmigen.build import * + + +__all__ = ["SPIResource"] + + +def SPIResource(number, *, cs, clk, mosi, miso, int=None, reset=None, attrs=None): + 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 int is not None: + io.append(Subsignal("int", Pins(int, dir="i"))) + if reset is not None: + io.append(Subsignal("reset", Pins(reset, dir="o"))) + if attrs is not None: + io.append(attrs) + return Resource("spi", number, *io) -- 2.30.2