Skip to content
Snippets Groups Projects

Modified the scripts to run on Raspberry Pi.

1 file
+ 64
9
Compare changes
  • Side-by-side
  • Inline
+ 64
9
@@ -137,9 +137,53 @@ def read_link_status(ports=4):
@@ -137,9 +137,53 @@ def read_link_status(ports=4):
stri += "link down "
stri += "link down "
print(stri)
print(stri)
# Read phy registister status
# Read phy registister status
# read_switch(0x80+cnt,0x1e)
for cnt in range(4):
ret = read_switch(0x80+cnt,0x02, pr_stri = False)
stri = " Phy status ch {} ".format(cnt)
 
if ret[1] & 0x20 :
 
stri += "AN_complete "
 
if ret[1] & 0x04:
 
stri += "link up "
 
if ret[1] & 0x10:
 
stri += "remote fault "
 
# print(stri)
 
ret = read_switch(0x80+cnt,0x14, pr_stri = False)
 
stri += " 1000BASE-T status ch{} ".format(cnt)
 
if ret[2] & 0x10:
 
stri += "remote status is good "
 
if ret[2] & 0x20:
 
stri += "local status is good "
 
if ret[2] & 0x40:
 
stri += "local master"
 
else:
 
stri += "local slave"
 
else:
 
stri += " No link "
 
print(stri)
 
write_switch_bytes(0x80+cnt, 0x3c, [0x35, 0x08])
 
ret = read_switch(0x80+cnt,0x3e)
 
if 0:
 
print("Drop packet count register")
 
for cnt in range(16):
 
# read_switch(0x41,0x80+2*cnt)
 
read_switch(0x0,0x0 + cnt)
 
print("Port State Override")
 
for cnt in range(16):
 
# read_switch(0x41,0x80+2*cnt)
 
read_switch(0x0,0x60 + cnt)
 
read_switch(0x0,0x10)
 
read_switch(0x0,0x20)
 
if 1:
 
print("Receive count register")
 
if 1:
 
print("Receive count register")
 
for cnt in range(16):
 
write_switch_bytes(0x10+cnt, 0x20, [0xD0, 0x09])
 
time.sleep(0.5)
 
for cnt in range(16):
 
# read_switch(0x41,0x80+2*cnt)
 
read_switch(0x10+cnt,0x2e)
 
# Open a connection to a specific bus and device (chip select pin)
# Open a connection to a specific bus and device (chip select pin)
spi.open(bus, device)
spi.open(bus, device)
@@ -172,12 +216,23 @@ elif sys.argv[1] == "set":
@@ -172,12 +216,23 @@ elif sys.argv[1] == "set":
read_switch(0x40,0x01)
read_switch(0x40,0x01)
print("strap resistors")
print("strap resistors")
read_switch(0x01,0x70)
read_switch(0x01,0x70)
print("write and read SGMII register CH0")
if 1:
write_switch_bytes(0x10, 0x24, [0x44, 0x00])
print("write and read SGMII register CH0")
read_switch(0x10,0x24)
write_switch_bytes(0x10, 0x24, [0x44, 0x00])
print("write and read SGMII register CH3")
read_switch(0x10,0x24)
write_switch_bytes(0x13, 0x24, [0x44, 0x00])
print("write and read SGMII register CH3")
read_switch(0x13,0x24)
write_switch_bytes(0x13, 0x24, [0x44, 0x00])
 
read_switch(0x13,0x24)
 
write_switch_bytes(0x0, 0x20, [0x06])
 
for cnt in range(16):
 
write_switch_bytes(0x0, 0x0+cnt, [0x00])
 
for cnt in range(4):
 
write_switch_bytes(0x80+cnt, 0x00, [0x00, 0x01])
 
ret = read_switch(0x80+cnt,0x00)
 
for cnt in range(16):
 
write_switch_bytes(0x10+cnt, 0x00, [0x40, 0x11])
 
write_switch_bytes(0x10+cnt, 0x20, [0xD0, 0x09])
 
else:
else:
print("spi_switch_Unb2c stat for status")
print("spi_switch_Unb2c stat for status")
print("spi_switch_Unb2c set to set registers")
print("spi_switch_Unb2c set to set registers")
Loading