forked from M-Labs/artiq
1
0
Fork 0

drtio: add remote converter SPI example (#740)

This commit is contained in:
Sebastien Bourdeauducq 2017-06-21 17:08:12 +08:00
parent 74cf074538
commit 64ce85445c
2 changed files with 48 additions and 0 deletions

View File

@ -146,4 +146,28 @@ device_db = {
"class": "TTLInOut",
"arguments": {"channel": 0x010009}
},
"converter_spi": {
"type": "local",
"module": "artiq.coredevice.spi",
"class": "NRTSPIMaster",
},
"ad9154_spi": {
"type": "local",
"module": "artiq.coredevice.ad9154_spi",
"class": "AD9154",
"arguments": {"spi_device": "converter_spi", "chip_select": 1}
},
"rconverter_spi": {
"type": "local",
"module": "artiq.coredevice.spi",
"class": "NRTSPIMaster",
"arguments": {"busno": 0x010000}
},
"rad9154_spi": {
"type": "local",
"module": "artiq.coredevice.ad9154_spi",
"class": "AD9154",
"arguments": {"spi_device": "rconverter_spi", "chip_select": 1}
},
}

View File

@ -0,0 +1,24 @@
from artiq.coredevice.ad9154_reg import *
from artiq.experiment import *
class Test(EnvExperiment):
def build(self):
self.setattr_device("core")
self.setattr_device("ad9154_spi")
self.setattr_device("rad9154_spi")
@kernel
def run(self):
self.ad9154_spi.setup_bus()
self.rad9154_spi.setup_bus()
for i in range(5):
self.p("local PRODID: 0x%04x", (self.ad9154_spi.read(AD9154_PRODIDH) << 8) |
self.ad9154_spi.read(AD9154_PRODIDL))
self.p("remote PRODID: 0x%04x", (self.rad9154_spi.read(AD9154_PRODIDH) << 8) |
self.rad9154_spi.read(AD9154_PRODIDL))
def p(self, f, *a):
print(f % a)