Commit 6e97c2da authored by Jan Pospisil's avatar Jan Pospisil

added new CLI command for driver initialization - has to be called once at the beginning

parent da4ee7c9
......@@ -19,8 +19,11 @@ def myFloat(s):
print("FFPG command line interface")
print("")
if len(sys.argv) is not 4 and len(sys.argv) < 7:
if len(sys.argv) is not 3 and len(sys.argv) is not 4 and len(sys.argv) < 7:
print "Usage:"
print " "+sys.argv[0]+" <fmcSlot (LUN)> init"
print " Perform main initialization (resetting, clearing, synchronizing...)"
print " or"
print " "+sys.argv[0]+" <fmcSlot (LUN)> <channel> <polarity> <pulseWidth> <pulseDelay> <triggerLatency> [<bunches>]"
print " Sets and starts selected channel on selected FMC mezzanine"
print " or"
......@@ -40,29 +43,33 @@ if len(sys.argv) is not 4 and len(sys.argv) < 7:
print ""
sys.exit()
command = "configure"
fmcSlot = myInt(sys.argv[1])
channel = myInt(sys.argv[2])
if sys.argv[3] == "stop":
polarity = "stop"
if sys.argv[2] == "init":
command = "init"
else:
polarity = myInt(sys.argv[3])
pulseWidth = myFloat(sys.argv[4])
pulseDelay = myFloat(sys.argv[5])
triggerLatency = myFloat(sys.argv[6])
bunches = []
for i in range(7, len(sys.argv)):
if "-" in sys.argv[i]:
startBunch, stopBunch = sys.argv[i].split("-", 2)
bunches = bunches + range(myInt(startBunch), myInt(stopBunch))
else:
bunches.append(myInt(sys.argv[i]))
channel = myInt(sys.argv[2])
if sys.argv[3] == "stop":
command = "stop"
else:
polarity = myInt(sys.argv[3])
pulseWidth = myFloat(sys.argv[4])
pulseDelay = myFloat(sys.argv[5])
triggerLatency = myFloat(sys.argv[6])
bunches = []
for i in range(7, len(sys.argv)):
if "-" in sys.argv[i]:
startBunch, stopBunch = sys.argv[i].split("-", 2)
bunches = bunches + range(myInt(startBunch), myInt(stopBunch))
else:
bunches.append(myInt(sys.argv[i]))
print("Configuration:")
print(" fmcSlot (LUN) = "+str(fmcSlot))
print(" channel = "+str(channel))
if polarity == "stop":
print(" command = stop")
else:
print(" command = "+command)
if command == "configure" or command == "stop":
print(" channel = "+str(channel))
if command == "configure":
if polarity is 1:
print(" polarity = "+str(polarity)+" (positive pulses)")
else:
......@@ -75,11 +82,12 @@ print("")
if fmcSlot is not 0 and fmcSlot is not 1:
raise Exception("fmcSlot (LUN) can be only 0 or 1!");
if channel is not 1 and channel is not 2:
raise Exception("channel can be only 1 or 2!");
if polarity is not 0 and polarity is not 1 and polarity is not "stop":
raise Exception("polarity can be only 0 or 1!");
if polarity != "stop":
if command == "configure" or command == "stop":
if channel is not 1 and channel is not 2:
raise Exception("channel can be only 1 or 2!");
if command == "configure":
if polarity is not 0 and polarity is not 1:
raise Exception("polarity can be only 0 or 1!");
if pulseWidth <= 0:
raise Exception("pulseWidth has to be > 0 ns!");
if pulseDelay < 0:
......@@ -97,6 +105,8 @@ def PrintFrequency(pg):
else:
print("RF clock frequency: (unstable)")
# import pdb; pdb.set_trace()
# create FFPG driver for FMC slot
pg = Ffpg(fmcSlot)
......@@ -107,7 +117,7 @@ pg = Ffpg(fmcSlot)
# pg.wb.SetDebugSv("wb_trace.svh")
# stop and disable channel
if polarity == "stop":
if command == "stop":
pg.StopChannel(channel)
pg.DisableChannel(channel)
print "Done, channel stopped."
......@@ -115,13 +125,22 @@ if polarity == "stop":
sys.exit();
# initialize the driver
# pg.Reset() # this clears and stops both channel effectively inhibiting possibility of both channels running
if command == "init":
pg.Reset()
pg.SelectClock("external", 400.789)
pg.SetRatio(2)
pg.SetOverflow(17820)
pg.Ad9512Sync()
pg.SetTriggerThreshold(0.5)
pg.SetVcxoFrequency(-0.2105) # 125.0000 MHz
print "Done, driver initialized."
print ""
sys.exit();
pg.SelectClock("external", 400.789)
pg.SetRatio(2)
pg.SetOverflow(17820)
pg.Ad9512Sync()
pg.SetTriggerThreshold(0.5)
pg.SetVcxoFrequency(-0.2105) # 125.0000 MHz
# calibration
print("Calibrating channel "+str(channel)+" on FMC slot "+str(fmcSlot)+" to "+str(triggerLatency)+" ns")
if triggerLatency > -1:
......
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