#!/usr/bin/env python
+from datetime import datetime as dt
+from time import sleep
import yaml
import usbio
s['i2c'] = i2c.dump_config()
# current information
- s['date'] = dt.now().strftime('%Y-%m-%d_%H:%M:%S')
+ s['date'] = dt.now().strftime('%Y-%m-%d_%H%M%S')
s['isupply'] = meas_isupply()
return s
amux = None
def init_devboard(name='devboard-defaults.yaml'):
+ global spi0, spi1, i2c
+ global ibias, vatoi, v430
+ global dac, adc
+ global chain, mux
+ global arb, amux
+
try:
load_config(name)
return
##############################################################################
# Power supplies
- vatoi = usbio.DigiReg(i2c, 2, (0.5015, 1.3887), (1.9552, 2.8304))
+ vatoi = usbio.DigiReg(i2c, 2, [0.5015, 1.3887], [1.9552, 2.8304])
vatoi.alias('va', 'vdigi')
vatoi.alias('vb', 'avdd')
- v430 = usbio.DigiReg(i2c, 3, (1.9535, 2.7137), (0.5013, 1.2617))
+ v430 = usbio.DigiReg(i2c, 3, [1.9535, 2.7137], [0.5013, 1.2617])
v430.alias('va', 'dvdd')
v430.alias('vb', 'vdd')
"""Given a dict or a filename containing a yaml dump of settings, load them
and (re-)initialize all components.
"""
+ global spi0, spi1, i2c
+ global ibias, vatoi, v430
+ global dac, adc
+ global chain, mux
+ global arb, amux
+
if isinstance(name, dict):
cfg = name
else:
##########################################################################
# Setup FTDI serial ports
- spi0 = usbio.AtoiSPI0(**cfg['spi0'])
- spi1 = usbio.AtoiSPI1(**cfg['spi1'])
+ spi0 = usbio.SPI(**cfg['spi0'])
+ spi1 = usbio.SPI(**cfg['spi1'])
i2c = usbio.I2C(**cfg['i2c'])
##########################################################################
"""Return a dict of settings which can be passed to constructor to
restore the state."""
s = {}
- s['addr'] = int(self.addr)
+ s['addr'] = int(self.addr - self.ADDR_BASE)
s['posA'] = int(self.posA)
s['posB'] = int(self.posB)
s['gpo1'] = int(self.gpo1)
def __init__(self, freq):
super(AtoiSPI0, self).__init__(
interface=ftdi.INTERFACE_A,
- cs={'_idle': (-1, 0xc8),
- '_mask': (-1, 0x38), #TODO
- 'flash': (3, 0xc0),
- 'dac': (1, 0xd8),
- 'adc': (1, 0xe8),
- 'convst': (1, 0xf8)},
+ cs={'_idle': [-1, 0xc8],
+ '_mask': [-1, 0x38], #TODO
+ 'flash': [3, 0xc0],
+ 'dac': [1, 0xd8],
+ 'adc': [1, 0xe8],
+ 'convst': [1, 0xf8]},
freq=int(freq),
vid=0x0403,
pid=0x6011,
def __init__(self, freq):
super(AtoiSPI1, self).__init__(
interface=ftdi.INTERFACE_B,
- cs={'_idle': (-1, 0xf8),
- '_mask': (-1, 0xf8), #TODO
- 'chain0_conf': (0, 0xf0),
- 'chain0_mux': (0, 0xe8),
- 'chain1_conf': (0, 0xd8),
- 'chain1_mux': (0, 0xb8)},
+ cs={'_idle': [-1, 0xf8],
+ '_mask': [-1, 0xf8], #TODO
+ 'chain0_conf': [0, 0xf0],
+ 'chain0_mux': [0, 0xe8],
+ 'chain1_conf': [0, 0xd8],
+ 'chain1_mux': [0, 0xb8]},
freq=int(freq),
vid=0x0403,
pid=0x6011,