forked from M-Labs/artiq
devices/dds_core: add on/off methods
This commit is contained in:
parent
0ad2b4d09b
commit
e6530075d9
|
@ -11,12 +11,25 @@ class DDS(AutoContext):
|
||||||
kernel_attr = "_previous_frequency"
|
kernel_attr = "_previous_frequency"
|
||||||
|
|
||||||
@kernel
|
@kernel
|
||||||
def pulse(self, frequency, duration):
|
def _set_frequency(self, frequency):
|
||||||
if self._previous_frequency != frequency:
|
if self._previous_frequency != frequency:
|
||||||
syscall("rtio_sync", self.rtio_channel) # wait until output is off
|
syscall("rtio_sync", self.rtio_channel) # wait until output is off
|
||||||
syscall("dds_program", self.reg_channel,
|
syscall("dds_program", self.reg_channel,
|
||||||
int(2**32*frequency/self.dds_sysclk))
|
int(2**32*frequency/self.dds_sysclk))
|
||||||
self._previous_frequency = frequency
|
self._previous_frequency = frequency
|
||||||
|
|
||||||
|
@kernel
|
||||||
|
def pulse(self, frequency, duration):
|
||||||
|
self._set_frequency(frequency)
|
||||||
syscall("rtio_set", now(), self.rtio_channel, 1)
|
syscall("rtio_set", now(), self.rtio_channel, 1)
|
||||||
delay(duration)
|
delay(duration)
|
||||||
syscall("rtio_set", now(), self.rtio_channel, 0)
|
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)
|
||||||
|
|
Loading…
Reference in New Issue