Skip to content

Commit

Permalink
Undid the rename because there is a property for that (which is a bet…
Browse files Browse the repository at this point in the history
…ter way anyhow).
  • Loading branch information
BiffoBear committed Dec 16, 2022
1 parent 5df2376 commit a485697
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions adafruit_wiznet5k/adafruit_wiznet5k.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def __init__(
:param bool debug: Enable debugging output, defaults to False.
"""
self._debug = debug
self.chip_type = None
self._chip_type = None
self._device = SPIDevice(spi_bus, cs, baudrate=8000000, polarity=0, phase=0)
# init c.s.
self._cs = cs
Expand Down Expand Up @@ -282,9 +282,9 @@ def max_sockets(self) -> int:
:return int: Maximum supported sockets.
"""
if self.chip_type == "w5500":
if self._chip_type == "w5500":
return W5200_W5500_MAX_SOCK_NUM
if self.chip_type == "w5100s":
if self._chip_type == "w5100s":
return W5100_MAX_SOCK_NUM
return -1

Expand All @@ -295,7 +295,7 @@ def chip(self) -> str:
:return str: The chip type.
"""
return self.chip_type
return self._chip_type

@property
def ip_address(self) -> bytearray:
Expand Down Expand Up @@ -393,10 +393,10 @@ def link_status(self) -> int:
:return int: 1 if the link is up, 0 if the link is down.
"""
if self.chip_type == "w5500":
if self._chip_type == "w5500":
data = self.read(REG_PHYCFGR, 0x00)
return data[0] & 0x01
if self.chip_type == "w5100s":
if self._chip_type == "w5100s":
data = self.read(REG_PHYCFGR_W5100S, 0x00)
return data[0] & 0x01
return 0
Expand Down Expand Up @@ -463,7 +463,7 @@ def _detect_and_reset_w5500() -> bool:
:return bool: True if a W5500 chip is detected, False if not.
"""
self.chip_type = "w5500"
self._chip_type = "w5500"
# assert self.sw_reset() == 0, "Chip not reset properly!"
self._write_mr(0x08)
# assert self._read_mr()[0] == 0x08, "Expected 0x08."
Expand Down Expand Up @@ -493,7 +493,7 @@ def _detect_and_reset_w5100s() -> bool:
:return bool: True if a W5100 chip is detected, False if not.
"""
self.chip_type = "w5100s"
self._chip_type = "w5100s"
# sw reset
assert self.sw_reset() == 0, "Chip not reset properly!"
if self.read(REG_VERSIONR_W5100S, 0x00)[0] != 0x51:
Expand Down Expand Up @@ -564,7 +564,7 @@ def read(
:return Union[WriteableBuffer, bytearray]: Data read from the chip.
"""
with self._device as bus_device:
if self.chip_type == "w5500":
if self._chip_type == "w5500":
bus_device.write(bytes([addr >> 8])) # pylint: disable=no-member
bus_device.write(bytes([addr & 0xFF])) # pylint: disable=no-member
bus_device.write(bytes([callback])) # pylint: disable=no-member
Expand Down Expand Up @@ -592,7 +592,7 @@ def write(
:param Union[int, Sequence[Union[int, bytes]]] data: Data to write to the register address.
"""
with self._device as bus_device:
if self.chip_type == "w5500":
if self._chip_type == "w5500":
bus_device.write(bytes([addr >> 8])) # pylint: disable=no-member
bus_device.write(bytes([addr & 0xFF])) # pylint: disable=no-member
bus_device.write(bytes([callback])) # pylint: disable=no-member
Expand Down Expand Up @@ -910,7 +910,7 @@ def socket_read(
# Read the starting save address of the received data
ptr = self._read_snrx_rd(socket_num)

if self.chip_type == "w5500":
if self._chip_type == "w5500":
# Read data from the starting address of snrx_rd
ctrl_byte = 0x18 + (socket_num << 5)

Expand Down Expand Up @@ -1001,7 +1001,7 @@ def socket_write(
# Read the starting address for saving the transmitting data.
ptr = self._read_sntx_wr(socket_num)
offset = ptr & SOCK_MASK
if self.chip_type == "w5500":
if self._chip_type == "w5500":
dst_addr = offset + (socket_num * SOCK_SIZE + 0x8000)

txbuf = buffer[:ret]
Expand Down Expand Up @@ -1136,10 +1136,10 @@ def _read_snmr(self, sock: int) -> Optional[bytearray]:

def _write_socket(self, sock: int, address: int, data: int) -> None:
"""Write to a W5k socket register."""
if self.chip_type == "w5500":
if self._chip_type == "w5500":
cntl_byte = (sock << 5) + 0x0C
return self.write(address, cntl_byte, data)
if self.chip_type == "w5100s":
if self._chip_type == "w5100s":
cntl_byte = 0
return self.write(
self._ch_base_msb + sock * CH_SIZE + address, cntl_byte, data
Expand All @@ -1148,10 +1148,10 @@ def _write_socket(self, sock: int, address: int, data: int) -> None:

def _read_socket(self, sock: int, address: int) -> Optional[bytearray]:
"""Read a W5k socket register."""
if self.chip_type == "w5500":
if self._chip_type == "w5500":
cntl_byte = (sock << 5) + 0x08
return self.read(address, cntl_byte)
if self.chip_type == "w5100s":
if self._chip_type == "w5100s":
cntl_byte = 0
return self.read(self._ch_base_msb + sock * CH_SIZE + address, cntl_byte)
return None

0 comments on commit a485697

Please sign in to comment.