Commit 81fcdf9f authored by Matthieu Cattin's avatar Matthieu Cattin

Add eeprom data formating, write and verify. Still to be tested.

parent a727b2ed
......@@ -261,9 +261,9 @@ def dump_file_to_eeprom(fmc, filename):
f = open(filename,"r+")
for line in f:
addr,data=line.split()
eeprom_content=(int(data,2)& 0xFF)
eeprom_addr=(int(addr,2))
fmc.sys_i2c_eeprom_write(eeprom_addr,[eeprom_content])
eeprom_content.append(int(data,2))
eeprom_addr.append(int(addr,2))
fmc.sys_i2c_eeprom_write(eeprom_addr[0],eeprom_content)
return 0
......@@ -676,43 +676,58 @@ def main (default_directory = '.'):
############################################################################
# Write correction data tp file
############################################################################
filename = "test19_corr_data.txt"
file = open(filename, 'w')
out_filename = "test19_corr_data.txt"
f_out = open(out_filename, 'w')
# 10V range
print "10V range"
for item in adc_corr_data['10V']['offset']:
print '0x%.4X,yes'%(signed2hex(item))
file.write('0x%.4X,yes\n'%(signed2hex(item)))
f_out.write('0x%.4X,yes\n'%(signed2hex(item)))
for item in adc_corr_data['10V']['gain']:
print '0x%.4X,yes'%(signed2hex(item))
file.write('0x%.4X,yes\n'%(signed2hex(item)))
f_out.write('0x%.4X,yes\n'%(signed2hex(item)))
# 1V range
print "1V range"
for item in adc_corr_data['1V']['offset']:
print '0x%.4X,yes'%(signed2hex(item))
file.write('0x%.4X,yes\n'%(signed2hex(item)))
f_out.write('0x%.4X,yes\n'%(signed2hex(item)))
for item in adc_corr_data['1V']['gain']:
print '0x%.4X,yes'%(signed2hex(item))
file.write('0x%.4X,yes\n'%(signed2hex(item)))
f_out.write('0x%.4X,yes\n'%(signed2hex(item)))
# 100mV range
print "100mV range"
for item in adc_corr_data['100mV']['offset']:
print '0x%.4X,yes'%(signed2hex(item))
file.write('0x%.4X,yes\n'%(signed2hex(item)))
f_out.write('0x%.4X,yes\n'%(signed2hex(item)))
for item in adc_corr_data['100mV']['gain']:
print '0x%.4X,yes'%(signed2hex(item))
file.write('0x%.4X,yes\n'%(signed2hex(item)))
f_out.write('0x%.4X,yes\n'%(signed2hex(item)))
############################################################################
# Format FMC EEPROM data
############################################################################
os.system("python ../../fmceeprom/python/fmc_eeprom_gen.py -i ../../fmceeprom/python/eeprom_input.xml -o test19_formatted_data.txt -r test19_corr_data.txt")
############################################################################
# Write data to FMC EEPROM
############################################################################
in_filename = "test19_formatted_data.txt"
eeprom_content = []
eeprom_addr = []
f_in = open(in_filename,"r+")
for line in f_in:
addr,data=line.split()
eeprom_content.append(int(data,2))
eeprom_addr.append(int(addr,2))
fmc.sys_i2c_eeprom_write(eeprom_addr[0],eeprom_content)
############################################################################
# Verify EEPROM data
############################################################################
eeprom_content_read = fmc.sys_i2c_eeprom_read(eeprom_addr[0],len(eeprom_content))
for i in len(eeprom_content):
if eeprom_content[i] != eeprom_content_read[i]:
print "[ERROR] eeprom data corruption @ addr:%d expect:0x%.2X read:0x%.2X"%(i, eeprom_content[i], eeprom_content_read[i])
# Open all switches, reset offset DAC to mid-scale (0V)
......
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