Skip to content

Commit

Permalink
mirny: add to manual
Browse files Browse the repository at this point in the history
  • Loading branch information
jordens committed Jan 20, 2020
1 parent 522fa92 commit 6c1a1df
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
4 changes: 2 additions & 2 deletions artiq/coredevice/adf5355.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
""""RTIO driver for the Analog Devices ADF[45]35[56] family of GHz PLLs
on Mirny-style prefixed SPI buses
"""RTIO driver for the Analog Devices ADF[45]35[56] family of GHz PLLs
on Mirny-style prefixed SPI buses.
"""

# https://github.com/analogdevicesinc/linux/blob/master/Documentation/devicetree/bindings/iio/frequency/adf5355.txt
Expand Down
21 changes: 18 additions & 3 deletions artiq/coredevice/mirny.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""RTIO driver for Mirny (4 channel GHz PLLs)
"""

from artiq.language.core import kernel, delay
from artiq.language.units import us

Expand All @@ -17,28 +20,39 @@

SPI_CS = 1

WE = 1 << 24


class Mirny:
WE = 1 << 24
kernel_invariants = {"bus", "core", "WE"}
"""Mirny PLL-based RF generator.
:param spi_device: SPI bus device
:param core_device: Core device name (default: "core")
"""
kernel_invariants = {"bus", "core"}

def __init__(self, dmgr, spi_device, core_device="core"):
self.core = dmgr.get(core_device)
self.bus = dmgr.get(spi_device)

@kernel
def read_reg(self, addr):
"""Read a register"""
self.bus.set_config_mu(SPI_CONFIG | spi.SPI_INPUT | spi.SPI_END, 24,
SPIT_RD, SPI_CS)
self.bus.write((addr << 25))
return self.bus.read() & int32(0xffff)

@kernel
def write_reg(self, addr, data):
"""Write a register"""
self.bus.set_config_mu(SPI_CONFIG | spi.SPI_END, 24, SPIT_WR, SPI_CS)
self.bus.write((addr << 25) | self.WE | ((data & 0xffff) << 8))
self.bus.write((addr << 25) | WE | ((data & 0xffff) << 8))

@kernel
def init(self):
"""Initialize Mirny by reading the status register and verifying
compatible hardware and protocol revisions"""
reg0 = self.read_reg(0)
if reg0 & 0b11 != 0b11:
raise ValueError("Mirny HW_REV mismatch")
Expand All @@ -57,6 +71,7 @@ def set_att_mu(self, channel, att):

@kernel
def write_ext(self, addr, length, data):
"""Perform SPI write to a prefixed address"""
self.bus.set_config_mu(SPI_CONFIG, 8, SPIT_WR, SPI_CS)
self.bus.write(addr << 25)
self.bus.set_config_mu(SPI_CONFIG | spi.SPI_END, length,
Expand Down
12 changes: 12 additions & 0 deletions doc/manual/core_drivers_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,18 @@ RF generation drivers
.. automodule:: artiq.coredevice.ad9914
:members:

:mod:`artiq.coredevice.mirny` module
+++++++++++++++++++++++++++++++++++++

.. automodule:: artiq.coredevice.mirny
:members:

:mod:`artiq.coredevice.adf5355` module
+++++++++++++++++++++++++++++++++++++++

.. automodule:: artiq.coredevice.adf5355
:members:

:mod:`artiq.coredevice.spline` module
+++++++++++++++++++++++++++++++++++++

Expand Down

0 comments on commit 6c1a1df

Please sign in to comment.