forked from M-Labs/artiq
1
0
Fork 0

devices/dds_core: add on/off methods

This commit is contained in:
Sebastien Bourdeauducq 2014-09-09 22:00:51 +08:00
parent 0ad2b4d09b
commit e6530075d9
1 changed files with 14 additions and 1 deletions

View File

@ -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)