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