forked from M-Labs/artiq
drtio: add remote converter SPI example (#740)
This commit is contained in:
parent
74cf074538
commit
64ce85445c
|
@ -146,4 +146,28 @@ device_db = {
|
||||||
"class": "TTLInOut",
|
"class": "TTLInOut",
|
||||||
"arguments": {"channel": 0x010009}
|
"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}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue