@@ -169,7 +169,7 @@ def __init__(
169
169
:param bool debug: Enable debugging output, defaults to False.
170
170
"""
171
171
self ._debug = debug
172
- self .chip_type = None
172
+ self ._chip_type = None
173
173
self ._device = SPIDevice (spi_bus , cs , baudrate = 8000000 , polarity = 0 , phase = 0 )
174
174
# init c.s.
175
175
self ._cs = cs
@@ -282,9 +282,9 @@ def max_sockets(self) -> int:
282
282
283
283
:return int: Maximum supported sockets.
284
284
"""
285
- if self .chip_type == "w5500" :
285
+ if self ._chip_type == "w5500" :
286
286
return W5200_W5500_MAX_SOCK_NUM
287
- if self .chip_type == "w5100s" :
287
+ if self ._chip_type == "w5100s" :
288
288
return W5100_MAX_SOCK_NUM
289
289
return - 1
290
290
@@ -295,7 +295,7 @@ def chip(self) -> str:
295
295
296
296
:return str: The chip type.
297
297
"""
298
- return self .chip_type
298
+ return self ._chip_type
299
299
300
300
@property
301
301
def ip_address (self ) -> bytearray :
@@ -393,10 +393,10 @@ def link_status(self) -> int:
393
393
394
394
:return int: 1 if the link is up, 0 if the link is down.
395
395
"""
396
- if self .chip_type == "w5500" :
396
+ if self ._chip_type == "w5500" :
397
397
data = self .read (REG_PHYCFGR , 0x00 )
398
398
return data [0 ] & 0x01
399
- if self .chip_type == "w5100s" :
399
+ if self ._chip_type == "w5100s" :
400
400
data = self .read (REG_PHYCFGR_W5100S , 0x00 )
401
401
return data [0 ] & 0x01
402
402
return 0
@@ -463,7 +463,7 @@ def _detect_and_reset_w5500() -> bool:
463
463
464
464
:return bool: True if a W5500 chip is detected, False if not.
465
465
"""
466
- self .chip_type = "w5500"
466
+ self ._chip_type = "w5500"
467
467
# assert self.sw_reset() == 0, "Chip not reset properly!"
468
468
self ._write_mr (0x08 )
469
469
# assert self._read_mr()[0] == 0x08, "Expected 0x08."
@@ -493,7 +493,7 @@ def _detect_and_reset_w5100s() -> bool:
493
493
494
494
:return bool: True if a W5100 chip is detected, False if not.
495
495
"""
496
- self .chip_type = "w5100s"
496
+ self ._chip_type = "w5100s"
497
497
# sw reset
498
498
assert self .sw_reset () == 0 , "Chip not reset properly!"
499
499
if self .read (REG_VERSIONR_W5100S , 0x00 )[0 ] != 0x51 :
@@ -564,7 +564,7 @@ def read(
564
564
:return Union[WriteableBuffer, bytearray]: Data read from the chip.
565
565
"""
566
566
with self ._device as bus_device :
567
- if self .chip_type == "w5500" :
567
+ if self ._chip_type == "w5500" :
568
568
bus_device .write (bytes ([addr >> 8 ])) # pylint: disable=no-member
569
569
bus_device .write (bytes ([addr & 0xFF ])) # pylint: disable=no-member
570
570
bus_device .write (bytes ([callback ])) # pylint: disable=no-member
@@ -592,7 +592,7 @@ def write(
592
592
:param Union[int, Sequence[Union[int, bytes]]] data: Data to write to the register address.
593
593
"""
594
594
with self ._device as bus_device :
595
- if self .chip_type == "w5500" :
595
+ if self ._chip_type == "w5500" :
596
596
bus_device .write (bytes ([addr >> 8 ])) # pylint: disable=no-member
597
597
bus_device .write (bytes ([addr & 0xFF ])) # pylint: disable=no-member
598
598
bus_device .write (bytes ([callback ])) # pylint: disable=no-member
@@ -910,7 +910,7 @@ def socket_read(
910
910
# Read the starting save address of the received data
911
911
ptr = self ._read_snrx_rd (socket_num )
912
912
913
- if self .chip_type == "w5500" :
913
+ if self ._chip_type == "w5500" :
914
914
# Read data from the starting address of snrx_rd
915
915
ctrl_byte = 0x18 + (socket_num << 5 )
916
916
@@ -1001,7 +1001,7 @@ def socket_write(
1001
1001
# Read the starting address for saving the transmitting data.
1002
1002
ptr = self ._read_sntx_wr (socket_num )
1003
1003
offset = ptr & SOCK_MASK
1004
- if self .chip_type == "w5500" :
1004
+ if self ._chip_type == "w5500" :
1005
1005
dst_addr = offset + (socket_num * SOCK_SIZE + 0x8000 )
1006
1006
1007
1007
txbuf = buffer [:ret ]
@@ -1136,10 +1136,10 @@ def _read_snmr(self, sock: int) -> Optional[bytearray]:
1136
1136
1137
1137
def _write_socket (self , sock : int , address : int , data : int ) -> None :
1138
1138
"""Write to a W5k socket register."""
1139
- if self .chip_type == "w5500" :
1139
+ if self ._chip_type == "w5500" :
1140
1140
cntl_byte = (sock << 5 ) + 0x0C
1141
1141
return self .write (address , cntl_byte , data )
1142
- if self .chip_type == "w5100s" :
1142
+ if self ._chip_type == "w5100s" :
1143
1143
cntl_byte = 0
1144
1144
return self .write (
1145
1145
self ._ch_base_msb + sock * CH_SIZE + address , cntl_byte , data
@@ -1148,10 +1148,10 @@ def _write_socket(self, sock: int, address: int, data: int) -> None:
1148
1148
1149
1149
def _read_socket (self , sock : int , address : int ) -> Optional [bytearray ]:
1150
1150
"""Read a W5k socket register."""
1151
- if self .chip_type == "w5500" :
1151
+ if self ._chip_type == "w5500" :
1152
1152
cntl_byte = (sock << 5 ) + 0x08
1153
1153
return self .read (address , cntl_byte )
1154
- if self .chip_type == "w5100s" :
1154
+ if self ._chip_type == "w5100s" :
1155
1155
cntl_byte = 0
1156
1156
return self .read (self ._ch_base_msb + sock * CH_SIZE + address , cntl_byte )
1157
1157
return None
0 commit comments