WIP fixups to make work
authorDan White <dan@whiteaudio.com>
Tue, 16 Oct 2012 21:05:28 +0000 (16:05 -0500)
committerDan White <dan@whiteaudio.com>
Tue, 16 Oct 2012 21:05:28 +0000 (16:05 -0500)
python-lib/devboard.py
python-lib/usbio.py

index 3d8a61b6c704abf940fdad025becaf83d4e69712..4827f097c053993808e9b1aa3bea420aa034203b 100644 (file)
@@ -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'])
 
     ##########################################################################
index 6082cfdc5652aeab9d3ed5fa8a62f7bbec6176a9..a91e8217f187c56fa41399b401d5d4ab0f9a8919 100644 (file)
@@ -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,