ZHCAFN1 August 2025 DS90UB935-Q1 , DS90UB960-Q1
def CheckRXLinkStatus(rx_port):
select_rx_port(rx_port)
port_status1 = board.ReadI2C(DesAddr,0x4D)
port_status2 = board.ReadI2C(DesAddr,0x4E)
parity_err0 = board.ReadI2C(DesAddr,0x55)
parity_err1 = board.ReadI2C(DesAddr,0x56)
csi_err = board.ReadI2C(DesAddr,0x7A)
csi_err_cnt = board.ReadI2C(DesAddr,0x7B)
port_status1_pass = port_status1== (rx_port << 6) + 3
port_status2_pass = port_status2 == 4
parity_err_pass = ((parity_err0*256) + parity_err1) < 1
csi_err_pass = csi_err == 0 and csi_err_cnt == 0
def clearDesAllErrors(rx_port):
board.ReadI2C(DesAddr,0x4D) # Clear status register of errors.
board.ReadI2C(DesAddr,0x4E) # Clear status register of errors.
board.ReadI2C(DesAddr,0x55) # Clear status register of errors.
board.ReadI2C(DesAddr,0x56) # Clear status register of errors.
board.ReadI2C(DesAddr,0x7A) # Clear status register of errors.
board.ReadI2C(DesAddr,0x7B) # Clear status register of errors.
print "Port", str(rx_port), "Clear status register of errors 0x4D, 0x4E, 0x55, 0x56, 0x7A, and 0x7B"
def recovery_SER(rx_port):
select_rx_port(rx_port)
board.WriteI2C(DesAddr, 0xB1,0x71)
board.WriteI2C(DesAddr, 0xB2,0x20)
board.WriteI2C(DesAddr, 0xB1,0x90)
board.WriteI2C(DesAddr, 0xB2,0x00)
#Hard reset SER
reg_0x58 = board.ReadI2C(DesAddr,0x58)
reg_0x58 = reg_0x58 | 0x60 # Enable I2C Passthrough with auto ACK
board.WriteI2C(DesAddr,0x58,reg_0x58)
board.WriteI2C(serAlias[rx_port],0x01,0x02) # Ser Hard Reset
time.sleep(0.01)#wait 10ms
if SerConfig[rx_port] == "971":
board.WriteI2C(serAlias[rx_port],0x4B,0x02) # disable BC alternate mode auto detect
board.WriteI2C(serAlias[rx_port],0x49,0x06) # decrease link detect timer on 971 BC-RX
print 'writing 0x4B and 0x49 on 971'
board.WriteI2C(serAlias[rx_port],0x0A,0x12)
reg_0x58 = reg_0x58 & 0x5F # Disable auto ACK and I2C passthrough
board.WriteI2C(DesAddr,0x58,reg_0x58)
board.WriteI2C(DesAddr, 0xB1,0x90)
board.WriteI2C(DesAddr, 0xB2,0x40)
board.WriteI2C(DesAddr, 0xB1,0x71)
board.WriteI2C(DesAddr, 0xB2,0x20)
time.sleep(0.0001)#Wait 100us
board.WriteI2C(DesAddr, 0xB2,0x00)
print '\nPort', str(rx_port), 'recovery loop complete, checking status:'
clearDesAllErrors(rx_port)
time.sleep(0.1) #Wait time for error accumulation
CheckRXLinkStatus(rx_port)
Cycle = 1000
print "Hot plug testing - remove camera when ready"
for i in range(0,cycle):
RX_PORT_STS1 = board.ReadI2C(DesAddr, 0x4D)
if (RX_PORT_STS1 != 0x3):
print "Hot plug event detected"
break
elif i == cycle-1:
print "No hot plug event detected"
for i in range(0,cycle):
RX_PORT_STS1 = board.ReadI2C(DesAddr, 0x4D)
if (RX_PORT_STS1 == 0x3):
print "completing hot plug"
recovery_SER(0) #note that need reconfigure SER & Sensor
break
elif i == cycle-1:
print "lock not re-gained within expected timeframe"