mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-19 00:16:29 +08:00
moninj: fix ad9914 behavior, comment cleanup
This commit is contained in:
parent
5581ae15ca
commit
72b92f559d
@ -554,9 +554,6 @@ class _DeviceManager:
|
|||||||
|
|
||||||
# initialize CPLD (if applicable)
|
# initialize CPLD (if applicable)
|
||||||
if dds_model.is_urukul:
|
if dds_model.is_urukul:
|
||||||
# TODO: reimplement cache (simple "was init")
|
|
||||||
#
|
|
||||||
|
|
||||||
# urukuls need CPLD init and switch to on
|
# urukuls need CPLD init and switch to on
|
||||||
cpld_dev = """self.setattr_device("core_cache")
|
cpld_dev = """self.setattr_device("core_cache")
|
||||||
self.setattr_device("{}")""".format(dds_model.cpld)
|
self.setattr_device("{}")""".format(dds_model.cpld)
|
||||||
@ -564,8 +561,7 @@ class _DeviceManager:
|
|||||||
# `sta`/`rf_sw`` variables are guaranteed for urukuls
|
# `sta`/`rf_sw`` variables are guaranteed for urukuls
|
||||||
# so {action} can use it
|
# so {action} can use it
|
||||||
# if there's no RF enabled, CPLD may have not been initialized
|
# if there's no RF enabled, CPLD may have not been initialized
|
||||||
#
|
# but if there is, it has been initialised - no need to do again
|
||||||
# but if there is, it has
|
|
||||||
cpld_init = """delay(15*ms)
|
cpld_init = """delay(15*ms)
|
||||||
was_init = self.core_cache.get("_{cpld}_init")
|
was_init = self.core_cache.get("_{cpld}_init")
|
||||||
sta = self.{cpld}.sta_read()
|
sta = self.{cpld}.sta_read()
|
||||||
@ -583,16 +579,15 @@ class _DeviceManager:
|
|||||||
if dds_model.dds_type == "AD9912":
|
if dds_model.dds_type == "AD9912":
|
||||||
# 0xFF before init, 0x99 after
|
# 0xFF before init, 0x99 after
|
||||||
channel_init = """
|
channel_init = """
|
||||||
delay(10*ms)
|
|
||||||
if self.{dds_channel}.read({cfgreg}, length=1) == 0xFF:
|
if self.{dds_channel}.read({cfgreg}, length=1) == 0xFF:
|
||||||
delay(10*ms)
|
delay(10*ms)
|
||||||
self.{dds_channel}.init()
|
self.{dds_channel}.init()
|
||||||
""".format(dds_channel=dds_channel, cfgreg=AD9912_SER_CONF)
|
""".format(dds_channel=dds_channel, cfgreg=AD9912_SER_CONF)
|
||||||
elif dds_model.dds_type == "AD9910":
|
elif dds_model.dds_type == "AD9910":
|
||||||
# TODO: verify AD9910 behavior (when we have hardware)
|
# TODO: verify AD9910 behavior (when we have hardware)
|
||||||
channel_init = "self.{dds_channel}.init()".format(dds_channel)
|
channel_init = "self.{dds_channel}.init()".format(dds_channel=dds_channel)
|
||||||
else:
|
else:
|
||||||
channel_init = "self.{dds_channel}.init()".format(dds_channel)
|
channel_init = "self.{dds_channel}.init()".format(dds_channel=dds_channel)
|
||||||
|
|
||||||
dds_exp = textwrap.dedent("""
|
dds_exp = textwrap.dedent("""
|
||||||
from artiq.experiment import *
|
from artiq.experiment import *
|
||||||
@ -608,6 +603,7 @@ class _DeviceManager:
|
|||||||
def run(self):
|
def run(self):
|
||||||
self.core.break_realtime()
|
self.core.break_realtime()
|
||||||
{cpld_init}
|
{cpld_init}
|
||||||
|
delay(10*ms)
|
||||||
{channel_init}
|
{channel_init}
|
||||||
delay(15*ms)
|
delay(15*ms)
|
||||||
{action}
|
{action}
|
||||||
@ -622,16 +618,13 @@ class _DeviceManager:
|
|||||||
log_msg))
|
log_msg))
|
||||||
|
|
||||||
def dds_set_frequency(self, dds_channel, dds_model, freq):
|
def dds_set_frequency(self, dds_channel, dds_model, freq):
|
||||||
|
action = "self.{ch}.set({freq})".format(
|
||||||
|
freq=freq, ch=dds_channel)
|
||||||
if dds_model.is_urukul:
|
if dds_model.is_urukul:
|
||||||
ch_no = "ch_no = self.{ch}.chip_select - 4"
|
action += """
|
||||||
else:
|
ch_no = self.{ch}.chip_select - 4
|
||||||
ch_no = "ch_no = self.{ch}.channel"
|
|
||||||
action = """
|
|
||||||
{ch_no}
|
|
||||||
self.{ch}.set({freq})
|
|
||||||
self.{cpld}.cfg_switches(rf_sw | 1 << ch_no)
|
self.{cpld}.cfg_switches(rf_sw | 1 << ch_no)
|
||||||
""".format(freq=freq, cpld=dds_model.cpld,
|
""".format(ch=dds_channel, cpld=dds_model.cpld)
|
||||||
ch=dds_channel, ch_no=ch_no.format(ch=dds_channel))
|
|
||||||
self._dds_faux_injection(
|
self._dds_faux_injection(
|
||||||
dds_channel,
|
dds_channel,
|
||||||
dds_model,
|
dds_model,
|
||||||
|
Loading…
Reference in New Issue
Block a user