ad5360: un-factor write_channels

This commit is contained in:
Robert Jördens 2016-03-04 19:01:29 +01:00
parent 725943fee2
commit eb2ec40b3a
1 changed files with 3 additions and 8 deletions

View File

@ -50,8 +50,7 @@ class AD5360:
self.core = dmgr.get("core") self.core = dmgr.get("core")
self.bus = dmgr.get(spi_device) self.bus = dmgr.get(spi_device)
if ldac_device is not None: if ldac_device is not None:
ldac = dmgr.get(ldac_device) self.ldac = dmgr.get(ldac_device)
self.ldac = ldac
self.chip_select = chip_select self.chip_select = chip_select
@kernel @kernel
@ -78,11 +77,6 @@ class AD5360:
value &= 0xffff value &= 0xffff
self.write(op | _AD5360_WRITE_CHANNEL(channel) | value) self.write(op | _AD5360_WRITE_CHANNEL(channel) | value)
@kernel
def write_channels(self, values, op=_AD5360_CMD_DATA):
for i in range(len(values)):
self.write_channel(i, values[i], op)
@kernel @kernel
def read_channel_sync(self, channel=0, op=_AD5360_READ_X1A): def read_channel_sync(self, channel=0, op=_AD5360_READ_X1A):
channel &= 0x3f channel &= 0x3f
@ -110,7 +104,8 @@ class AD5360:
3*self.bus.ref_period_mu - 3*self.bus.ref_period_mu -
seconds_to_mu(1.5*us) - seconds_to_mu(1.5*us) -
seconds_to_mu(3*us)) seconds_to_mu(3*us))
self.write_channels(values, op) for i in range(len(values)):
self.write_channel(i, values[i], op)
delay_mu(3*self.bus.ref_period_mu + # latency alignment ttl to spi delay_mu(3*self.bus.ref_period_mu + # latency alignment ttl to spi
seconds_to_mu(1.5*us)) # t10 max busy low for one channel seconds_to_mu(1.5*us)) # t10 max busy low for one channel
self.load() self.load()