Commit 2a62fe92 authored by Paolo Baesso's avatar Paolo Baesso

Merge branch 'PythonScripts'

parents 500a9478 53f48b50
...@@ -95,11 +95,13 @@ res= zeClock.getDeviceVersion() ...@@ -95,11 +95,13 @@ res= zeClock.getDeviceVersion()
zeClock.checkDesignID() zeClock.checkDesignID()
#zeClock.setPage(0, True) #zeClock.setPage(0, True)
#zeClock.getPage(True) #zeClock.getPage(True)
clkRegList= zeClock.parse_clk("./../../bitFiles/TLU_CLK_Config_v1e.txt") doClock= False
zeClock.writeConfiguration(clkRegList)###### if (doClock):
zeClock.writeRegister(0x0536, [0x0A]) #Configures manual switch of inputs clkRegList= zeClock.parse_clk("./../../bitFiles/TLU_CLK_Config_v1e.txt")
zeClock.writeRegister(0x0949, [0x0F]) #Enable all inputs zeClock.writeConfiguration(clkRegList)######
zeClock.writeRegister(0x052A, [0x05]) #Configures source of input zeClock.writeRegister(0x0536, [0x0A]) #Configures manual switch of inputs
zeClock.writeRegister(0x0949, [0x0F]) #Enable all inputs
zeClock.writeRegister(0x052A, [0x05]) #Configures source of input
iopower= zeClock.readRegister(0x0949, 1) iopower= zeClock.readRegister(0x0949, 1)
print " Clock IO power: 0x%X" % iopower[0] print " Clock IO power: 0x%X" % iopower[0]
lol= zeClock.readRegister(0x000E, 1) lol= zeClock.readRegister(0x000E, 1)
...@@ -132,32 +134,32 @@ IC6=PCA9539PW(master_I2C, 0x74) ...@@ -132,32 +134,32 @@ IC6=PCA9539PW(master_I2C, 0x74)
#BANK 0 #BANK 0
IC6.setInvertReg(0, 0x00)# 0= normal IC6.setInvertReg(0, 0x00)# 0= normal
IC6.setIOReg(0, 0x00)# 0= output <<<<<<<<<<<<<<<<<<< IC6.setIOReg(0, 0x00)# 0= output <<<<<<<<<<<<<<<<<<<
IC6.setOutputs(0, 0x77) IC6.setOutputs(0, 0x77)#77
res= IC6.getInputs(0) res= IC6.getInputs(0)
print "IC6 read back bank 0: 0x%X" % res[0] print "\tIC6 read back bank 0: 0x%X" % res[0]
# #
#BANK 1 #BANK 1
IC6.setInvertReg(1, 0x00)# 0= normal IC6.setInvertReg(1, 0x00)# 0= normal
IC6.setIOReg(1, 0x00)# 0= output <<<<<<<<<<<<<<<<<<< IC6.setIOReg(1, 0x00)# 0= output <<<<<<<<<<<<<<<<<<<
IC6.setOutputs(1, 0x77) IC6.setOutputs(1, 0x77)#77
res= IC6.getInputs(1) res= IC6.getInputs(1)
print "IC6 read back bank 1: 0x%X" % res[0] print "\tIC6 read back bank 1: 0x%X" % res[0]
# # # # # #
IC7=PCA9539PW(master_I2C, 0x75) IC7=PCA9539PW(master_I2C, 0x75)
#BANK 0 #BANK 0
IC7.setInvertReg(0, 0x00)# 0= normal IC7.setInvertReg(0, 0x00)# 0= normal
IC7.setIOReg(0, 0x00)# 0= output <<<<<<<<<<<<<<<<<<< IC7.setIOReg(0, 0x00)# 0= output <<<<<<<<<<<<<<<<<<<
IC7.setOutputs(0, 0x00) IC7.setOutputs(0, 0xF0)
res= IC7.getInputs(0) res= IC7.getInputs(0)
print "IC7 read back bank 0: 0x%X" % res[0] print "\tIC7 read back bank 0: 0x%X" % res[0]
# #
#BANK 1 #BANK 1
IC7.setInvertReg(1, 0x00)# 0= normal IC7.setInvertReg(1, 0x00)# 0= normal
IC7.setIOReg(1, 0x00)# 0= output <<<<<<<<<<<<<<<<<<< IC7.setIOReg(1, 0x00)# 0= output <<<<<<<<<<<<<<<<<<<
IC7.setOutputs(1, 0xB0) IC7.setOutputs(1, 0xB0)
res= IC7.getInputs(1) res= IC7.getInputs(1)
print "IC7 read back bank 1: 0x%X" % res[0] print "\tIC7 read back bank 1: 0x%X" % res[0]
# #I2C EXPANDER CONFIGURATION END # #I2C EXPANDER CONFIGURATION END
......
...@@ -20,6 +20,7 @@ class TLU: ...@@ -20,6 +20,7 @@ class TLU:
"""docstring for TLU""" """docstring for TLU"""
def __init__(self, dev_name, man_file, parsed_cfg): def __init__(self, dev_name, man_file, parsed_cfg):
uhal.setLogLevelTo(uhal.LogLevel.NOTICE) ## Get rid of initial flood of IPBUS messages
self.isRunning= False self.isRunning= False
section_name= "Producer.fmctlu" section_name= "Producer.fmctlu"
...@@ -137,11 +138,16 @@ class TLU: ...@@ -137,11 +138,16 @@ class TLU:
#self.pwdled.setIndicatorRGB(11, [0, 0, 1]) #self.pwdled.setIndicatorRGB(11, [0, 0, 1])
self.pwdled.allGreen() self.pwdled.allGreen()
time.sleep(0.1)
self.pwdled.allBlue() self.pwdled.allBlue()
time.sleep(0.1)
self.pwdled.allBlack() self.pwdled.allBlack()
time.sleep(0.1)
#self.pwdled.kitt() #self.pwdled.kitt()
self.pwdled.allBlack() time.sleep(0.1)
self.pwdled.allRed() #self.pwdled.allBlack()
#self.pwdled.allRed()
#time.sleep(0.1)
self.pwdled.allWhite() self.pwdled.allWhite()
......
...@@ -51,7 +51,7 @@ DACThreshold4 = -0.12 ...@@ -51,7 +51,7 @@ DACThreshold4 = -0.12
DACThreshold5 = -0.12 DACThreshold5 = -0.12
# Define which DUTs are ON # Define which DUTs are ON
DUTMask = 1 DUTMask = 0x1
# Define mode of DUT (00 EUDET, 11 AIDA) # Define mode of DUT (00 EUDET, 11 AIDA)
DUTMaskMode= 0xFC DUTMaskMode= 0xFC
......
...@@ -3,6 +3,7 @@ import uhal ...@@ -3,6 +3,7 @@ import uhal
from I2CuHal import I2CCore from I2CuHal import I2CCore
import StringIO import StringIO
class PCA9548ADW: class PCA9548ADW:
#Class to configure the I2C multiplexer #Class to configure the I2C multiplexer
......
# -*- coding: utf-8 -*-
import uhal
from I2CuHal import I2CCore
import StringIO
class SFPI2C:
#Class to configure the EEPROM
def __init__(self, i2c, slaveaddr=0x50):
self.i2c = i2c
self.slaveaddr = slaveaddr
"""def readEEPROM(self, startadd, nBytes):
#Read EEPROM memory locations
mystop= False
myaddr= [startadd]#0xfa
self.i2c.write( self.slaveaddr, [startadd], mystop)
res= self.i2c.read( self.slaveaddr, nBytes)
return res"""
def _listToString(self, mylist):
mystring= ""
for iChar in mylist:
mystring= mystring + str(unichr(iChar))
return mystring
def writeReg(self, regN, regContent, verbose=False):
#Basic functionality to write to register.
if (regN < 0) | (regN > 7):
print "PCA9539PW - ERROR: register number should be in range [0:7]"
return
regContent= regContent & 0xFF
mystop=True
cmd= [regN, regContent]
self.i2c.write( self.slaveaddr, cmd, mystop)
def readReg(self, regN, nwords, verbose=False):
#Basic functionality to read from register.
mystop=False
self.i2c.write( self.slaveaddr, [regN], mystop)
res= self.i2c.read( self.slaveaddr, nwords)
return res
def getConnector(self):
"""Code for connector type (table 3.4)"""
conntype= self.readReg(2, 1, False)[0]
print "Connector type:", hex(conntype)
return conntype
def getDiagnosticsType(self):
"""Types of diagnostics available (table 3.9)"""
diaType= self.readReg(92, 1, False)[0]
print "Available Diagnostics:", hex(diaType)
return diaType
def getEncoding(self):
encoding= self.readReg(11, 1, False)[0]
print "Encoding", encoding
return encoding
def getEnhancedOpt(self):
enOpt= self.readReg(93, 1, False)[0]
print "Enhanced Options:", enOpt
return enOpt
def getTransceiver(self):
res= self.readReg(3, 8, False)
return res
def getVendorId(self):
""" Returns the OUI vendor id"""
vendID= self.readReg(37, 3, False)
return vendID
def getVendorName(self):
res= self.readReg( 20 , 16, False)
mystring= self._listToString(res)
return mystring
def getVendorPN(self):
""" Returns the part number defined by the vendor"""
pn=[]
mystring= ""
res= self.readReg( 40 , 16, False)
mystring= self._listToString(res)
return mystring
def scanI2C(self):
mystop=True
for iAddr in range (0, 128):
self.i2c.write( iAddr, [], mystop)
...@@ -89,7 +89,7 @@ class PWRLED: ...@@ -89,7 +89,7 @@ class PWRLED:
for iComp in range(0,3): for iComp in range(0,3):
indexComp= self.indicatorXYZ[indicator-1][iComp] indexComp= self.indicatorXYZ[indicator-1][iComp]
valueComp= not bool(RGB[iComp]) valueComp= not bool(RGB[iComp])
nextWrd= self._set_bit(nextWrd, indexComp, int(valueComp)) nextWrd= self._set_bit(nextWrd, indexComp, int(valueComp), False)
if verbose: if verbose:
print "n=", iComp, "INDEX=", indexComp, "VALUE=", int(valueComp), "NEXTWORD=", bin(nextWrd) print "n=", iComp, "INDEX=", indexComp, "VALUE=", int(valueComp), "NEXTWORD=", bin(nextWrd)
if verbose: if verbose:
...@@ -110,10 +110,11 @@ class PWRLED: ...@@ -110,10 +110,11 @@ class PWRLED:
return return
def _set_bit(self, v, index, x): def _set_bit(self, v, index, x, verbose= False):
"""Set the index:th bit of v to 1 if x is truthy, else to 0, and return the new value.""" """Set the index:th bit of v to 1 if x is truthy, else to 0, and return the new value."""
if (index == -1): if (index == -1):
print " SETBIT: Index= -1 will be ignored" if (verbose):
print " SETBIT: Index= -1 will be ignored"
else: else:
mask = 1 << index # Compute mask, an integer with just bit 'index' set. mask = 1 << index # Compute mask, an integer with just bit 'index' set.
v &= ~mask # Clear the bit indicated by the mask (if x is False) v &= ~mask # Clear the bit indicated by the mask (if x is False)
...@@ -164,6 +165,7 @@ class PWRLED: ...@@ -164,6 +165,7 @@ class PWRLED:
def kitt(self): def kitt(self):
#self.allBlack() #self.allBlack()
print "\tWait while LEDs are tested..."
self.setIndicatorRGB(1, [1, 0, 0]) self.setIndicatorRGB(1, [1, 0, 0])
self.setIndicatorRGB(2, [0, 0, 0]) self.setIndicatorRGB(2, [0, 0, 0])
self.setIndicatorRGB(3, [0, 0, 0]) self.setIndicatorRGB(3, [0, 0, 0])
...@@ -476,3 +478,4 @@ class PWRLED: ...@@ -476,3 +478,4 @@ class PWRLED:
self.setIndicatorRGB(9, [0, 0, 0]) self.setIndicatorRGB(9, [0, 0, 0])
self.setIndicatorRGB(10, [0, 0, 0]) self.setIndicatorRGB(10, [0, 0, 0])
self.setIndicatorRGB(11, [0, 0, 0]) self.setIndicatorRGB(11, [0, 0, 0])
print "\tLED test completed"
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment