From e6530075d9ff361558c08b77d279d090674c1145 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Tue, 9 Sep 2014 22:00:51 +0800 Subject: [PATCH] devices/dds_core: add on/off methods --- artiq/devices/dds_core.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/artiq/devices/dds_core.py b/artiq/devices/dds_core.py index b331b73e0..fd94a8cea 100644 --- a/artiq/devices/dds_core.py +++ b/artiq/devices/dds_core.py @@ -11,12 +11,25 @@ class DDS(AutoContext): kernel_attr = "_previous_frequency" @kernel - def pulse(self, frequency, duration): + def _set_frequency(self, frequency): if self._previous_frequency != frequency: syscall("rtio_sync", self.rtio_channel) # wait until output is off syscall("dds_program", self.reg_channel, int(2**32*frequency/self.dds_sysclk)) self._previous_frequency = frequency + + @kernel + def pulse(self, frequency, duration): + self._set_frequency(frequency) syscall("rtio_set", now(), self.rtio_channel, 1) delay(duration) syscall("rtio_set", now(), self.rtio_channel, 0) + + @kernel + def on(self, frequency): + self._set_frequency(frequency) + syscall("rtio_set", now(), self.rtio_channel, 1) + + @kernel + def off(self): + syscall("rtio_set", now(), self.rtio_channel, 0)