diff --git a/I2C_serial.py b/I2C_serial.py index b49776a5b7e91586ac182a17d4cbdd075b26756a..d2195df0fc0cf76be24ff616689a5a49f9d4ca9a 100644 --- a/I2C_serial.py +++ b/I2C_serial.py @@ -19,6 +19,7 @@ class I2C: def __init__(self, ADDRESS='040'): self.I2C_Address = ADDRESS + self.BUS_NR = 1 # not used for Laptop but to enable Pi multiple busses. # def chk_ack(self): diff --git a/I2C_serial_pi.py b/I2C_serial_pi.py index d9b98233550ac695493bd17e798cbd1c777f4b26..d928b77db33c00b86e96b3bf84ff1314a6515011 100644 --- a/I2C_serial_pi.py +++ b/I2C_serial_pi.py @@ -23,14 +23,13 @@ import sys from time import * DEBUG=False -BUS_NR = 1 class I2C: def __init__(self, ADDRESS='040'): self.I2C_Address = ADDRESS - - bus = smbus.SMBus(BUS_NR) + self.BUS_NR = 1 + bus = smbus.SMBus(self.BUS_NR) def read_bytes(self, register, bytes_to_read=2): diff --git a/check_adc_lock.py b/check_adc_lock.py index 090d44590d21925815fb495731618a68a34a54b2..7e85a592e23d05104fda019d4c9005c4c499cc83 100644 --- a/check_adc_lock.py +++ b/check_adc_lock.py @@ -20,9 +20,11 @@ sys.path.insert(0,'.') import os if os.name =="posix": from I2C_serial_pi import * + else: from I2C_serial import * +I2CBUSNR=1 sleep_time=0.05 WRITE_DATA = True READ_BYTE = True @@ -40,6 +42,7 @@ def Read_byte_ADC(ADC_reg_address, ADC_bytes=0, ADC_NR = 0, ADDRESS=0x20 ): # Read Byte from the ADC # I2C_device = I2C(ADDRESS) + I2C_device.bus = I2CBUSNR ADC_rw = 0x01 # 0 for write, 1 for read stri = "Read ADC from Address {:8x}".format(ADC_reg_address) diff --git a/set_clk.py b/set_clk.py index cb1d565c74827e77467a403309459b6206fc5266..dff55970d304dec63ce8df13830a1750f35992ef 100644 --- a/set_clk.py +++ b/set_clk.py @@ -23,6 +23,7 @@ if os.name =="posix": else: from I2C_serial import * +I2CBUSNR=1 sleep_time=0.05 PWR_RST = False SET_PLL = True @@ -42,6 +43,7 @@ def Write_byte_PLL(reg_address, wr_data, ADDRESS=0x20): # Write Byte to the ADC # I2C_device = I2C(ADDRESS) + I2C_device.bus = I2CBUSNR PLL_rw = 0x00 # 0 for write, 1 for read stri = "Write : 0x{0:{fill}2x} to Address : 0x{1:{fill}2x}".format(wr_data, reg_address, fill='0') print(stri) @@ -69,6 +71,7 @@ def Read_byte_PLL(reg_address, nof_bytes=1, ADDRESS=0x20 ): # Read Byte from the ADC # I2C_device = I2C(ADDRESS) + I2C_device.bus = I2CBUSNR PLL_rw = 0x01 # 0 for write, 1 for read I2C_device.write_bytes(0x06, 0x2C) @@ -105,6 +108,7 @@ def Read_byte_PLL(reg_address, nof_bytes=1, ADDRESS=0x20 ): def power(state): ADDRESS_IO = 0x20 I2C_IO_device = I2C(ADDRESS_IO) + I2C_device.bus = I2CBUSNR I2C_IO_device.write_bytes(0x06, 0x2C) I2C_IO_device.write_bytes(0x07, 00) if state: