From 40ca951750bebd6beea9eafcc3fe0ff93e8df6dd Mon Sep 17 00:00:00 2001 From: mntng Date: Wed, 12 Jul 2017 00:27:44 +0800 Subject: [PATCH] kc705: add SPI bus for memory card This will be useful for SPI unit tests using a SD card as victim. --- artiq/examples/master/device_db.py | 13 ++++++++++--- artiq/gateware/targets/kc705_dds.py | 18 +++++++++++++++++- conda/artiq-dev/meta.yaml | 2 +- doc/manual/core_device.rst | 26 ++++++++++++++------------ 4 files changed, 42 insertions(+), 17 deletions(-) diff --git a/artiq/examples/master/device_db.py b/artiq/examples/master/device_db.py index 73f67f04a..d3b4c102f 100644 --- a/artiq/examples/master/device_db.py +++ b/artiq/examples/master/device_db.py @@ -137,6 +137,13 @@ device_db = { "class": "SPIMaster", "arguments": {"channel": 23} }, + + "spi_mmc": { + "type": "local", + "module": "artiq.coredevice.spi", + "class": "SPIMaster", + "arguments": {"channel": 26} + }, "dac0": { "type": "local", @@ -149,20 +156,20 @@ device_db = { "type": "local", "module": "artiq.coredevice.dds", "class": "DDSChannelAD9914", - "arguments": {"bus_channel": 26, "channel": 0}, + "arguments": {"bus_channel": 27, "channel": 0}, "comment": "Comments work in DDS panel as well" }, "dds1": { "type": "local", "module": "artiq.coredevice.dds", "class": "DDSChannelAD9914", - "arguments": {"bus_channel": 26, "channel": 1} + "arguments": {"bus_channel": 27, "channel": 1} }, "dds2": { "type": "local", "module": "artiq.coredevice.dds", "class": "DDSChannelAD9914", - "arguments": {"bus_channel": 26, "channel": 2} + "arguments": {"bus_channel": 27, "channel": 2} }, "qc_q1_0": { diff --git a/artiq/gateware/targets/kc705_dds.py b/artiq/gateware/targets/kc705_dds.py index 25048f849..e96a02ea4 100755 --- a/artiq/gateware/targets/kc705_dds.py +++ b/artiq/gateware/targets/kc705_dds.py @@ -97,6 +97,16 @@ _ams101_dac = [ ) ] +_sdcard_spi_33 = [ + ("sdcard_spi_33", 0, + Subsignal("miso", Pins("AC20")), + Subsignal("clk", Pins("AB23")), + Subsignal("mosi", Pins("AB22")), + Subsignal("cs_n", Pins("AC21")), + IOStandard("LVCMOS33") + ) +] + class _NIST_Ions(MiniSoC, AMPSoC): mem_map = { @@ -131,6 +141,7 @@ class _NIST_Ions(MiniSoC, AMPSoC): self.platform.add_extension(_sma33_io) self.platform.add_extension(_ams101_dac) + self.platform.add_extension(_sdcard_spi_33) i2c = self.platform.request("i2c") self.submodules.i2c = gpio.GPIOTristate([i2c.scl, i2c.sda]) @@ -220,7 +231,12 @@ class NIST_CLOCK(_NIST_Ions): self.submodules += phy rtio_channels.append(rtio.Channel.from_phy( phy, ofifo_depth=128, ififo_depth=128)) - + + phy = spi.SPIMaster(platform.request("sdcard_spi_33", 0)) + self.submodules += phy + rtio_channels.append(rtio.Channel.from_phy( + phy, ofifo_depth=4, ififo_depth=4)) + phy = dds.AD9914(platform.request("dds"), 11, onehot=True) self.submodules += phy rtio_channels.append(rtio.Channel.from_phy(phy, diff --git a/conda/artiq-dev/meta.yaml b/conda/artiq-dev/meta.yaml index aee26062c..7252c1d50 100644 --- a/conda/artiq-dev/meta.yaml +++ b/conda/artiq-dev/meta.yaml @@ -14,7 +14,7 @@ requirements: run: - python >=3.5.3,<3.6 - setuptools 33.1.1 - - migen 0.5.dev py_112+gitd8b55c7 + - migen 0.5.dev py_117+gite826cb9 - misoc 0.6.dev py_22+gite205c2ea - jesd204b 0.3 - binutils-or1k-linux >=2.27 diff --git a/doc/manual/core_device.rst b/doc/manual/core_device.rst index 5f0f735b6..51937a974 100644 --- a/doc/manual/core_device.rst +++ b/doc/manual/core_device.rst @@ -71,19 +71,21 @@ With the CLOCK hardware, the TTL lines are mapped as follows: The board has RTIO SPI buses mapped as follows: -+--------------+-------------+-------------+-----------+------------+ -| RTIO channel | CS_N | MOSI | MISO | CLK | -+==============+=============+=============+===========+============+ -| 22 | AMS101_CS_N | AMS101_MOSI | | AMS101_CLK | -+--------------+-------------+-------------+-----------+------------+ -| 23 | SPI0_CS_N | SPI0_MOSI | SPI0_MISO | SPI0_CLK | -+--------------+-------------+-------------+-----------+------------+ -| 24 | SPI1_CS_N | SPI1_MOSI | SPI1_MISO | SPI1_CLK | -+--------------+-------------+-------------+-----------+------------+ -| 25 | SPI2_CS_N | SPI2_MOSI | SPI2_MISO | SPI2_CLK | -+--------------+-------------+-------------+-----------+------------+ ++--------------+--------------+--------------+--------------+------------+ +| RTIO channel | CS_N | MOSI | MISO | CLK | ++==============+==============+==============+==============+============+ +| 22 | AMS101_CS_N | AMS101_MOSI | | AMS101_CLK | ++--------------+--------------+--------------+--------------+------------+ +| 23 | SPI0_CS_N | SPI0_MOSI | SPI0_MISO | SPI0_CLK | ++--------------+--------------+--------------+--------------+------------+ +| 24 | SPI1_CS_N | SPI1_MOSI | SPI1_MISO | SPI1_CLK | ++--------------+--------------+--------------+--------------+------------+ +| 25 | SPI2_CS_N | SPI2_MOSI | SPI2_MISO | SPI2_CLK | ++--------------+--------------+--------------+--------------+------------+ +| 26 | MMC_SPI_CS_N | MMC_SPI_MOSI | MMC_SPI_MISO | MMC_SPI_CLK| ++--------------+--------------+--------------+--------------+------------+ -The DDS bus is on channel 26. +The DDS bus is on channel 27. NIST QC2