Skip to content

Commit 5e3e73e

Browse files
committed
cleanup code
1 parent aa9a131 commit 5e3e73e

File tree

1 file changed

+21
-120
lines changed

1 file changed

+21
-120
lines changed

adafruit_wiznet5k/adafruit_wiznet5k.py

Lines changed: 21 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -61,133 +61,43 @@
6161
# *** Wiznet Common Registers ***
6262
_REG_MR = {"w5100s": const(0x0000), "w5500": const(0x0000)}
6363
# Gateway IPv4 Address.
64-
_REG_GAR = {
65-
"w5100s": const(0x0001),
66-
"w5500": const(0x0001),
67-
"w6100": const(0x4130),
68-
"w6300": const(0x4130),
69-
}
64+
_REG_GAR = {"w5100s": const(0x0001), "w5500": const(0x0001), "w6100": const(0x4130), "w6300": const(0x4130)}
7065
# Subnet Mask Address
71-
_REG_SUBR = {
72-
"w5100s": const(0x0005),
73-
"w5500": const(0x0005),
74-
"w6100": const(0x4134),
75-
"w6300": const(0x4134),
76-
}
66+
_REG_SUBR = {"w5100s": const(0x0005), "w5500": const(0x0005), "w6100": const(0x4134), "w6300": const(0x4134)}
7767
# Chip version.
78-
_REG_VERSIONR = {
79-
"w5100s": const(0x0080),
80-
"w5500": const(0x0039),
81-
"w6100": const(0x0000),
82-
"w6300": const(0x0000),
83-
}
68+
_REG_VERSIONR = {"w5100s": const(0x0080), "w5500": const(0x0039), "w6100": const(0x0000), "w6300": const(0x0000)}
8469
# Source Hardware Address
85-
_REG_SHAR = {
86-
"w5100s": const(0x0009),
87-
"w5500": const(0x0009),
88-
"w6100": const(0x4120),
89-
"w6300": const(0x4120),
90-
}
70+
_REG_SHAR = {"w5100s": const(0x0009), "w5500": const(0x0009), "w6100": const(0x4120), "w6300": const(0x4120)}
9171
# Source IP Address
92-
_REG_SIPR = {
93-
"w5100s": const(0x000F),
94-
"w5500": const(0x000F),
95-
"w6100": const(0x4138),
96-
"w6300": const(0x4138),
97-
}
72+
_REG_SIPR = {"w5100s": const(0x000F), "w5500": const(0x000F), "w6100": const(0x4138), "w6300": const(0x4138)}
9873
# Register with link status flag (PHYCFGR for 5xxxx, PHYSR for 6100).
99-
_REG_LINK_FLAG = {
100-
"w5100s": const(0x003C),
101-
"w5500": const(0x002E),
102-
"w6100": const(0x3000),
103-
"w6300": const(0x3000),
104-
}
105-
_REG_RCR = {
106-
"w5100s": const(0x0019),
107-
"w5500": const(0x001B),
108-
"w6100": const(0x4204),
109-
"w6300": const(0x4204),
110-
}
111-
_REG_RTR = {
112-
"w5100s": const(0x0017),
113-
"w5500": const(0x0019),
114-
"w6100": const(0x4200),
115-
"w6300": const(0x4200),
116-
}
74+
_REG_LINK_FLAG = {"w5100s": const(0x003C), "w5500": const(0x002E), "w6100": const(0x3000), "w6300": const(0x3000)}
75+
_REG_RCR = {"w5100s": const(0x0019), "w5500": const(0x001B), "w6100": const(0x4204), "w6300": const(0x4204)}
76+
_REG_RTR = {"w5100s": const(0x0017), "w5500": const(0x0019), "w6100": const(0x4200), "w6300": const(0x4200)}
11777

11878
# *** Wiznet Socket Registers ***
11979
# Socket n Mode.
12080
_REG_SNMR = const(0x0000)
12181
# Socket n Command.
122-
_REG_SNCR = {
123-
"w5100s": const(0x0001),
124-
"w5500": const(0x0001),
125-
"w6100": const(0x0010),
126-
"w6300": const(0x0010),
127-
}
82+
_REG_SNCR = {"w5100s": const(0x0001), "w5500": const(0x0001), "w6100": const(0x0010), "w6300": const(0x0010)}
12883
# Socket n Interrupt.
129-
_REG_SNIR = {
130-
"w5100s": const(0x0002),
131-
"w5500": const(0x0002),
132-
"w6100": const(0x0020),
133-
"w6300": const(0x0020),
134-
}
84+
_REG_SNIR = {"w5100s": const(0x0002), "w5500": const(0x0002), "w6100": const(0x0020), "w6300": const(0x0020)}
13585
# Socket n Status.
136-
_REG_SNSR = {
137-
"w5100s": const(0x0003),
138-
"w5500": const(0x0003),
139-
"w6100": const(0x0030),
140-
"w6300": const(0x0030),
141-
}
86+
_REG_SNSR = {"w5100s": const(0x0003), "w5500": const(0x0003), "w6100": const(0x0030), "w6300": const(0x0030)}
14287
# Socket n Source Port.
143-
_REG_SNPORT = {
144-
"w5100s": const(0x0004),
145-
"w5500": const(0x0004),
146-
"w6100": const(0x0114),
147-
"w6300": const(0x0114),
148-
}
88+
_REG_SNPORT = {"w5100s": const(0x0004), "w5500": const(0x0004), "w6100": const(0x0114), "w6300": const(0x0114)}
14989
# Destination IPv4 Address.
150-
_REG_SNDIPR = {
151-
"w5100s": const(0x000C),
152-
"w5500": const(0x000C),
153-
"w6100": const(0x0120),
154-
"w6300": const(0x0120),
155-
}
90+
_REG_SNDIPR = {"w5100s": const(0x000C), "w5500": const(0x000C), "w6100": const(0x0120), "w6300": const(0x0120)}
15691
# Destination Port.
157-
_REG_SNDPORT = {
158-
"w5100s": const(0x0010),
159-
"w5500": const(0x0010),
160-
"w6100": const(0x0140),
161-
"w6300": const(0x0140),
162-
}
92+
_REG_SNDPORT = {"w5100s": const(0x0010), "w5500": const(0x0010), "w6100": const(0x0140), "w6300": const(0x0140)}
16393
# RX Free Size.
164-
_REG_SNRX_RSR = {
165-
"w5100s": const(0x0026),
166-
"w5500": const(0x0026),
167-
"w6100": const(0x0224),
168-
"w6300": const(0x0224),
169-
}
94+
_REG_SNRX_RSR = {"w5100s": const(0x0026), "w5500": const(0x0026), "w6100": const(0x0224), "w6300": const(0x0224)}
17095
# Read Size Pointer.
171-
_REG_SNRX_RD = {
172-
"w5100s": const(0x0028),
173-
"w5500": const(0x0028),
174-
"w6100": const(0x0228),
175-
"w6300": const(0x0228),
176-
}
96+
_REG_SNRX_RD = {"w5100s": const(0x0028), "w5500": const(0x0028), "w6100": const(0x0228), "w6300": const(0x0228)}
17797
# Socket n TX Free Size.
178-
_REG_SNTX_FSR = {
179-
"w5100s": const(0x0020),
180-
"w5500": const(0x0020),
181-
"w6100": const(0x0204),
182-
"w6300": const(0x0204),
183-
}
98+
_REG_SNTX_FSR = {"w5100s": const(0x0020), "w5500": const(0x0020), "w6100": const(0x0204), "w6300": const(0x0204)}
18499
# TX Write Pointer.
185-
_REG_SNTX_WR = {
186-
"w5100s": const(0x0024),
187-
"w5500": const(0x0024),
188-
"w6100": const(0x020C),
189-
"w6300": const(0x020C),
190-
}
100+
_REG_SNTX_WR = {"w5100s": const(0x0024), "w5500": const(0x0024), "w6100": const(0x020C), "w6300": const(0x020C)}
191101

192102
# SNSR Commands
193103
SNSR_SOCK_CLOSED = const(0x00)
@@ -243,12 +153,7 @@
243153
_DEFAULT_MAC = "DE:AD:BE:EF:FE:ED"
244154

245155
# Maximum number of sockets to support, differs between chip versions.
246-
_MAX_SOCK_NUM = {
247-
"w5100s": const(0x04),
248-
"w5500": const(0x08),
249-
"w6100": const(0x08),
250-
"w6300": const(0x08),
251-
}
156+
_MAX_SOCK_NUM = {"w5100s": const(0x04), "w5500": const(0x08), "w6100": const(0x08), "w6300": const(0x08)}
252157
_SOCKET_INVALID = const(0xFF)
253158

254159

@@ -547,13 +452,9 @@ def link_status(self) -> bool:
547452
"""
548453
if self._chip_type == "w6300":
549454
# w6300 uses PHYCFGR register for link status
550-
return bool(
551-
int.from_bytes(self._read(_REG_LINK_FLAG[self._chip_type], 0x80), "big") & 0x01
552-
)
455+
return bool(int.from_bytes(self._read(_REG_LINK_FLAG[self._chip_type], 0x80), "big") & 0x01)
553456
else:
554-
return bool(
555-
int.from_bytes(self._read(_REG_LINK_FLAG[self._chip_type], 0x00), "big") & 0x01
556-
)
457+
return bool(int.from_bytes(self._read(_REG_LINK_FLAG[self._chip_type], 0x00), "big") & 0x01)
557458

558459
@property
559460
def ifconfig(self) -> Tuple[bytes, bytes, bytes, bytes]:

0 commit comments

Comments
 (0)