Commit 4511dc39 authored by Matthieu Cattin's avatar Matthieu Cattin

add i2c scan check in test02 and test04, add serdes sync check in test05

parent f1d55d46
......@@ -199,12 +199,12 @@ class CFmcAdc100Ms:
# scan FMC i2c bus
def i2c_scan(self):
print '\nScan I2C bus'
self.fmc_i2c.scan()
return self.fmc_i2c.scan()
# scan FMC system i2c bus
def sys_i2c_scan(self):
print '\nScan system I2C bus'
self.fmc_sys_i2c.scan()
return self.fmc_sys_i2c.scan()
# Set input range
def set_input_range(self, channel, range):
......
......@@ -91,6 +91,7 @@ class COpenCoresI2C:
return self.rd_reg(self.R_RXR)
def scan(self):
periph_addr = []
for i in range(0,128):
addr = i << 1
addr |= 1
......@@ -99,11 +100,14 @@ class COpenCoresI2C:
self.wait_busy()
if(not(self.rd_reg(self.R_SR) & self.SR_RXACK)):
print("Device found at address: %.2X") % i
periph_addr.append(i)
print("Device found at address: 0x%.2X") % i
self.wr_reg(self.R_TXR, 0)
self.wr_reg(self.R_CR, self.CR_STO | self.CR_WR)
self.wait_busy()
return periph_addr
##########################################
# Usage example
......
......@@ -23,6 +23,8 @@ test02: Test EEPROM and write information data as specified in FMC standard
Note: Requires test00.py to run first to load the firmware!
"""
EEPROM_ADDR = 0x50
def main (default_directory='.'):
"""
......@@ -42,8 +44,18 @@ def main (default_directory='.'):
fmc = fmc_adc.CFmcAdc100Ms(spec)
# Scan FMC system i2c bus
fmc.sys_i2c_scan()
periph_addr = fmc.sys_i2c_scan()
# Check that the EEPROM is detected on the I2C bus
if(0 == len(periph_addr)):
raise PtsError('No peripheral detected on system management I2C bus')
else:
if(1 != len(periph_addr)):
raise PtsError('Signal integrity problem detected on system management I2C bus, %d devices detected instead of 1'%(len(periph_addr)))
else:
if(EEPROM_ADDR != periph_addr[0]):
raise PtsError('Wrong device mounted on system management I2C bus, address is:0x%.2X expected:0x%.2X'%(periph_addr[0],EEPROM_ADDR))
if __name__ == '__main__' :
main();
main()
......@@ -21,6 +21,7 @@ test04: Test Si570 programmable oscillator
Note: Requires test00.py to run first to load the firmware!
"""
SI570_ADDR = 0x55
SI570_RFREQ = 42
SI570_N1 = 7
SI570_HS_DIV = 2
......@@ -44,7 +45,17 @@ def main (default_directory='.'):
fmc = fmc_adc.CFmcAdc100Ms(spec)
# Scan i2c bus
fmc.i2c_scan()
periph_addr = fmc.i2c_scan()
# Check that the EEPROM is detected on the I2C bus
if(0 == len(periph_addr)):
raise PtsError('No peripheral detected on I2C bus')
else:
if(1 != len(periph_addr)):
raise PtsError('Signal integrity problem detected on I2C bus, %d devices detected instead of 1'%(len(periph_addr)))
else:
if(SI570_ADDR != periph_addr[0]):
raise PtsError('Wrong device mounted on I2C bus, address is:0x%.2X expected:0x%.2X'%(periph_addr[0],SI570_ADDR))
# Get Si570 configuration
si570_config = fmc.get_si570_config()
......
......@@ -47,11 +47,15 @@ def main (default_directory='.'):
# Read and check test pattern
pattern = fmc.get_testpat()
if(TEST_PATTERN != pattern):
raise PtsError('Cannot access LTC2174 ADC through I2C')
raise PtsError('Cannot access LTC2174 ADC through SPI')
# Print LTC2174 configuration
fmc.print_adc_regs()
# Check that SerDes are synchronised
if(0 == fmc.get_serdes_sync_stat()):
raise PtsError('SerDes are not synchronised')
# Read channels current data register
for i in range(1,NB_CHANNELS+1):
adc_value = fmc.get_current_adc_value(i)
......
......@@ -13,6 +13,7 @@ import os
from ptsexcept import *
import gn4124
import fmc_adc
from PAGE.Agilent33250A import *
from PAGE.SineWaveform import *
......
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