diff --git a/APSCT_I2C.py b/APSCT_I2C.py index f9625dfdb42c18cb1c00eca1400e5c0f640f4dfb..4e10741eadd811dbd97ea5c2d3668a9104c9c918 100644 --- a/APSCT_I2C.py +++ b/APSCT_I2C.py @@ -63,8 +63,10 @@ EEPROM = 0x50 # # I2C switch addresses # -i2c_switch_addr = [0x70, 0x71, 0x72, 0x73] - +i2c_switch_addr_rcu = [0x70, 0x71, 0x72, 0x73] +i2c_bus_rcu = 1 +i2c_switch_addr_unb = [0x70] +i2c_bus_unb = 3 # # ID Pins diff --git a/apsct_lib.py b/apsct_lib.py index eee2b32dedc42b59b37c926164b6b69d0165af4a..0b2d17d8c39c6c47d7394368017499dc518d631d 100644 --- a/apsct_lib.py +++ b/apsct_lib.py @@ -43,8 +43,10 @@ class ApsctClass: self.sensors = ApsctSensors() self.pps = PpsClass() self.i2cswitch = [] - for addr in APSCT_I2C.i2c_switch_addr: - self.i2cswitch.append(I2cSwitch(address=addr)) + for addr in APSCT_I2C.i2c_switch_addr_rcu: + self.i2cswitch.append(I2cSwitch(address=addr, bus=APSCT_I2C.i2c_bus_rcu)) + for addr in APSCT_I2C.i2c_switch_addr_unb: + self.i2cswitch.append(I2cSwitch(address=addr, bus=APSCT_I2C.i2c_bus_unb)) self.apsct_id = ApsctId() def read_IO_expanderis(self): @@ -206,7 +208,9 @@ class PllClass: print(f"Setup PPL {self.frequency}") self.dev_i2c_pll.write_bytes(0x07, 0x00) if self.frequency == '160MHz': - self.dev_i2c_pll.write_bytes(0x03, 0x08) + i2c_address = APSCT_I2C.PLL_200M + dev_i2c_pll_sel = I2C(i2c_address, BUSNR=I2CBUSNR) + dev_i2c_pll_sel.write_bytes(0x03, 0x08) else: self.dev_i2c_pll.write_bytes(0x03, 0x28) self.Write_byte_PLL(0x03, 0x0C) @@ -261,6 +265,7 @@ class PllClass: stri = f"PLL {self.frequency} Not locked --> PLL Error" if PRINT_ON: print(stri) + return self.lock def read_lol(self): # @@ -504,16 +509,17 @@ class I2cSwitch: # # Class to check a I2C-switch # - def __init__(self, address=0x70): + def __init__(self, address=0x70, bus=1): # # Whats needed to measure the toggle on GPIO24 # self.address = address + self.bus = bus self.dev_i2c_switch = I2C(address) - self.dev_i2c_switch.bus_nr = 1 + self.dev_i2c_switch.bus_nr = bus def check_switch(self, data=0xa5): - print(f"Check I2C switch at 0x{self.address:x}", end=' ') + print(f"Check I2C switch at 0x{self.address:x} bus {self.bus}", end=' ') ret_ack, ret_value = self.dev_i2c_switch.read_bytes(0) if ret_ack < 1: print("I2C-Switch not found") diff --git a/production_apsct.py b/production_apsct.py index 87517130d2248702a22c415f1fa4f650570dcd7b..c45becb4bc006b6dc901ef42d7bd5e3d7501f2c0 100644 --- a/production_apsct.py +++ b/production_apsct.py @@ -34,9 +34,9 @@ for mode in modi: apsct.frequency = mode apsct.set_apsct() if mode == "200MHz": - apsct.pll_200.read_lock() + state = state & apsct.pll_200.read_lock() if mode == "160MHz": - apsct.pll_160.read_lock() + state = state & apsct.pll_160.read_lock() apsct.frequency = "200MHz" apsct.set_apsct() @@ -57,3 +57,5 @@ if state: rw_ok = apsct.eeprom.wr_rd_eeprom(serial, address=0x20) if not rw_ok: print("EEPROM Error") +else: + print("\n >>> Errors during testing <<<\n")