'AVdd_atoi': 10e3 }
-
def count2volt(c, warn=True):
"""Properly handle 14-b data from 12b ADC value. Average bits
originate from 12b samples, so max value is 0xfff0 NOT 0xfffc.
"""Return a hierarchical dict of settings appropriate for passing to the
individual constructors.
"""
- s = {}
+ s = _config
# configuration
# chip SPI config
s['chain'] = chain.dump_config()
"""Write current config to a file.
"""
cfg = dump_config()
+ #update global run-time storage
+ _config.update(cfg)
if name is None:
name = 'config.%s.yaml' % cfg['date']
yaml.dump(cfg, open(name, 'wb'))
#
# Module-level names. Define here so they are found in the module scope
#
+# devboard configuration
+_config = {}
+
spi0 = None
spi1 = None
i2c = None
amux = None
def init_devboard(name='devboard-defaults.yaml'):
+ """Initialize devboard <-> usbio with a known configuration. `name` may be
+ a string filename, defaulting to 'devboard-defaults.yaml' or an integer
+ representing the file 'chip%02i.calibration.yaml'.
+ """
global spi0, spi1, i2c
global ibias, vatoi, v430
global dac, adc
global chain, mux
global arb, amux
+ # try loading config for given chip ID
+ if isinstance(name, int):
+ name = 'chip%02i.calibration.yaml' % name
+
try:
load_config(name)
return
else:
cfg = yaml.load(open(name, 'rb'))
+ _config.update(cfg)
##########################################################################
# Setup FTDI serial ports
spi0 = usbio.SPI(**cfg['spi0'])
#arb = usbio.Chain(spi1, 'chain1_conf', length=16)
#amux = usbio.Mux(spi1, 'chain1_mux')
+ #send values to chip
+ for f in (chain, mux, arb, amux):
+ f.write()
+
# define power supply defaults