import ftdi_mpsse #Import the module import time import sys #if len(sys.argv) > 1: # select_config = int(sys.argv[1]) #else: # select_config = 0 i2c = ftdi_mpsse.i2c(serial_number='A') #Connect to the FTDI chip ## Device address 0xD0 1101 0000 => 7-bit 0x68 ## Device address 0xD4 1101 0100 => 7-bit 0x6A VC6E ## Device address 0xA0 1010 0000 => 7-bit 0x50 ## Device address 0xAA 1010 1010 => 7-bit 0x55 ProXO ## Device address 0xB6 1011 0110 => 7-bit 0x5B ClockMatrix i2c.ReadAtOffset(0x6A, 0x00, 2, offset_size=1, disable_restart=0) # Dummy read, else first read starts incorrectly, cause unknown print(' 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F') print('0x00 :' + ''.join([' 0x{:02X}'.format(ord(x)) for x in i2c.ReadAtOffset(0x6A, 0x00, 16, offset_size=1, disable_restart=0)])) print('0x10 :' + ''.join([' 0x{:02X}'.format(ord(x)) for x in i2c.ReadAtOffset(0x6A, 0x10, 16, offset_size=1, disable_restart=0)])) print('0x20 :' + ''.join([' 0x{:02X}'.format(ord(x)) for x in i2c.ReadAtOffset(0x6A, 0x20, 16, offset_size=1, disable_restart=0)])) print('0x30 :' + ''.join([' 0x{:02X}'.format(ord(x)) for x in i2c.ReadAtOffset(0x6A, 0x30, 16, offset_size=1, disable_restart=0)])) print('0x40 :' + ''.join([' 0x{:02X}'.format(ord(x)) for x in i2c.ReadAtOffset(0x6A, 0x40, 16, offset_size=1, disable_restart=0)])) print('0x50 :' + ''.join([' 0x{:02X}'.format(ord(x)) for x in i2c.ReadAtOffset(0x6A, 0x50, 16, offset_size=1, disable_restart=0)])) print('0x60 :' + ''.join([' 0x{:02X}'.format(ord(x)) for x in i2c.ReadAtOffset(0x6A, 0x60, 16, offset_size=1, disable_restart=0)])) print('0x70 :' + ''.join([' 0x{:02X}'.format(ord(x)) for x in i2c.ReadAtOffset(0x6A, 0x70, 16, offset_size=1, disable_restart=0)])) print('0x80 :' + ''.join([' 0x{:02X}'.format(ord(x)) for x in i2c.ReadAtOffset(0x6A, 0x80, 16, offset_size=1, disable_restart=0)])) print('0x90 :' + ''.join([' 0x{:02X}'.format(ord(x)) for x in i2c.ReadAtOffset(0x6A, 0x90, 16, offset_size=1, disable_restart=0)])) print('Read starting Calibration results register 0x99') reg99 = ord(i2c.ReadAtOffset(0x6A, 0x99, 1, offset_size=1, disable_restart=0)) print('reg99 was 0x{:02X}'.format(reg99) ) print('Set register 0x6F[1] (PLL_Lock_Bypass) to 1') reg6F = ord(i2c.ReadAtOffset(0x6A, 0x6F, 1, offset_size=1, disable_restart=0)) print('reg6F was 0x{:02X}'.format(reg6F) ) reg6F = reg6F | 0x01 print('reg6F set 0x{:02X}'.format(reg6F) ) i2c.WriteAtOffset(0x6A, offset=0x6F , data=chr(reg6F), offset_size=1) reg6F = ord(i2c.ReadAtOffset(0x6A, 0x6F, 1, offset_size=1, disable_restart=0)) print('reg6F now 0x{:02X}'.format(reg6F) ) print('Toggle register 0x1C[7] (Calibration_Start)') reg1C = ord(i2c.ReadAtOffset(0x6A, 0x1C, 1, offset_size=1, disable_restart=0)) print('reg1C was 0x{:02X}'.format(reg1C) ) reg1C = reg1C & 0x7F print('reg1C set 0x{:02X}'.format(reg1C) ) i2c.WriteAtOffset(0x6A, offset=0x1C , data=chr(reg1C), offset_size=1) reg1C = ord(i2c.ReadAtOffset(0x6A, 0x1C, 1, offset_size=1, disable_restart=0)) print('reg1C now 0x{:02X}'.format(reg1C) ) reg1C = reg1C | 0x80 print('reg1C set 0x{:02X}'.format(reg1C) ) i2c.WriteAtOffset(0x6A, offset=0x1C , data=chr(reg1C), offset_size=1) reg1C = ord(i2c.ReadAtOffset(0x6A, 0x1C, 1, offset_size=1, disable_restart=0)) print('reg1C now 0x{:02X}'.format(reg1C) ) print('Read register 0x99[2] (Calibration_Done) status bit') reg99 = ord(i2c.ReadAtOffset(0x6A, 0x99, 1, offset_size=1, disable_restart=0)) cal_status = (reg99 & 0x04) >> 2 while (cal_status == 0): print('.') time.sleep(0.01) reg99 = ord(i2c.ReadAtOffset(0x6A, 0x99, 1, offset_size=1, disable_restart=0)) cal_status = (reg99 & 0x04) >> 2 reg99 = ord(i2c.ReadAtOffset(0x6A, 0x99, 1, offset_size=1, disable_restart=0)) print('reg99 is now 0x{:02X}'.format(reg99) ) print('Calibration_Done = {}'.format(cal_status)) print('Read register 0x9D[7] (PLL_Lock) status bit') reg9D = ord(i2c.ReadAtOffset(0x6A, 0x9D, 1, offset_size=1, disable_restart=0)) lock_status = (reg9D & 0x80) >> 7 while (lock_status == 0): print('.') time.sleep(0.01) reg9D = ord(i2c.ReadAtOffset(0x6A, 0x9D, 1, offset_size=1, disable_restart=0)) lock_status = (reg9D & 0x80) >> 7 reg9D = ord(i2c.ReadAtOffset(0x6A, 0x9D, 1, offset_size=1, disable_restart=0)) print('reg9D is now 0x{:02X}'.format(reg9D) ) print('PLL_Lock = {}'.format(lock_status)) print('Reset register 0x6F[1] (PLL_Lock_Bypass) to 0') reg6F = ord(i2c.ReadAtOffset(0x6A, 0x6F, 1, offset_size=1, disable_restart=0)) print('reg6F was 0x{:02X}'.format(reg6F) ) reg6F = reg6F & 0xFE print('reg6F set 0x{:02X}'.format(reg6F) ) i2c.WriteAtOffset(0x6A, offset=0x6F , data=chr(reg6F), offset_size=1) reg6F = ord(i2c.ReadAtOffset(0x6A, 0x6F, 1, offset_size=1, disable_restart=0)) print('reg6F now 0x{:02X}'.format(reg6F) ) time.sleep(0.1) #print('Config %d' % select_config) print(' 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F') print('0x00 :' + ''.join([' 0x{:02X}'.format(ord(x)) for x in i2c.ReadAtOffset(0x6A, 0x00, 16, offset_size=1, disable_restart=0)])) print('0x10 :' + ''.join([' 0x{:02X}'.format(ord(x)) for x in i2c.ReadAtOffset(0x6A, 0x10, 16, offset_size=1, disable_restart=0)])) print('0x20 :' + ''.join([' 0x{:02X}'.format(ord(x)) for x in i2c.ReadAtOffset(0x6A, 0x20, 16, offset_size=1, disable_restart=0)])) print('0x30 :' + ''.join([' 0x{:02X}'.format(ord(x)) for x in i2c.ReadAtOffset(0x6A, 0x30, 16, offset_size=1, disable_restart=0)])) print('0x40 :' + ''.join([' 0x{:02X}'.format(ord(x)) for x in i2c.ReadAtOffset(0x6A, 0x40, 16, offset_size=1, disable_restart=0)])) print('0x50 :' + ''.join([' 0x{:02X}'.format(ord(x)) for x in i2c.ReadAtOffset(0x6A, 0x50, 16, offset_size=1, disable_restart=0)])) print('0x60 :' + ''.join([' 0x{:02X}'.format(ord(x)) for x in i2c.ReadAtOffset(0x6A, 0x60, 16, offset_size=1, disable_restart=0)])) print('0x70 :' + ''.join([' 0x{:02X}'.format(ord(x)) for x in i2c.ReadAtOffset(0x6A, 0x70, 16, offset_size=1, disable_restart=0)])) print('0x80 :' + ''.join([' 0x{:02X}'.format(ord(x)) for x in i2c.ReadAtOffset(0x6A, 0x80, 16, offset_size=1, disable_restart=0)])) print('0x90 :' + ''.join([' 0x{:02X}'.format(ord(x)) for x in i2c.ReadAtOffset(0x6A, 0x90, 16, offset_size=1, disable_restart=0)]))