closed, the kernel will suspend the device. This makes the SUSPEND pin go
low on the usbio board and allows a circuit to cut power to the devboard.
"""
- print 'closing usb ports, waiting for kernel to suspend port'
- for c in (spi0.context, spi1.context, i2c.context):
- usbio.ftdi.usb_close(c)
+ print 'Closing usb ports, waiting for kernel to suspend port'
+ for port in (spi0, spi1, i2c):
+ try:
+ port.close()
+ except usbio.FTDI_Error:
+ #already closed, ignore
+ pass
+ global is_initialized
+ is_initialized = False
sleep(delay)
mux = None
arb = None
amux = None
- is_initialized = False
-
# try loading config for given chip ID
if isinstance(name, int):
name = 'chip%02i-calibration.yaml' % name
try:
- load_config(name)
+ load_config(name, delay=1)
is_initialized = True
return
except IOError:
-def load_config(name):
+def load_config(name, delay=0):
"""Given a dict or a filename containing a yaml dump of settings, load them
and (re-)initialize all components.
"""
spi0 = usbio.SPI(**cfg['spi0'])
spi1 = usbio.SPI(**cfg['spi1'])
i2c = usbio.I2C(**cfg['i2c'])
+ sleep(delay)
##########################################################################
# Analog bias