devices/dds_core: use new compiler features to compute tuning word trivially

This commit is contained in:
Sebastien Bourdeauducq 2014-08-18 23:53:10 +08:00
parent 7a90f4f4ec
commit 62b872ad94

View File

@ -13,8 +13,7 @@ class DDS(AutoContext):
def pulse(self, frequency, duration):
if self._previous_frequency != frequency:
syscall("rtio_sync", self.rtio_channel) # wait until output is off
syscall("dds_program", self.reg_channel,
(frequency << 2)//(self.dds_sysclk >> 15) << 15)
syscall("dds_program", self.reg_channel, int(2**32*frequency/self.dds_sysclk))
self._previous_frequency = frequency
syscall("rtio_set", now(), self.rtio_channel, 1)
delay(duration)