From dc908ccffadc9186ab6a7c4576b5456eab9bd7c9 Mon Sep 17 00:00:00 2001 From: Dan White Date: Tue, 16 Oct 2012 16:05:28 -0500 Subject: [PATCH] WIP fixups to make work --- python-lib/devboard.py | 24 +++++++++++++++++++----- python-lib/usbio.py | 26 +++++++++++++------------- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/python-lib/devboard.py b/python-lib/devboard.py index 3d8a61b..4827f09 100644 --- a/python-lib/devboard.py +++ b/python-lib/devboard.py @@ -1,5 +1,7 @@ #!/usr/bin/env python +from datetime import datetime as dt +from time import sleep import yaml import usbio @@ -141,7 +143,7 @@ def dump_config(): 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 @@ -173,6 +175,12 @@ arb = None 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 @@ -203,11 +211,11 @@ def init_devboard(name='devboard-defaults.yaml'): ############################################################################## # 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') @@ -247,6 +255,12 @@ def load_config(name): """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: @@ -256,8 +270,8 @@ def load_config(name): ########################################################################## # 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']) ########################################################################## diff --git a/python-lib/usbio.py b/python-lib/usbio.py index 6082cfd..a91e821 100644 --- a/python-lib/usbio.py +++ b/python-lib/usbio.py @@ -1249,7 +1249,7 @@ class AD524x(object): """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) @@ -1723,12 +1723,12 @@ class AtoiSPI0(SPI): 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, @@ -1768,12 +1768,12 @@ class AtoiSPI1(SPI): 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, -- 2.25.1