Skip to content

Feature Request: Add W6100 Hardware Ping Command Support #183

@joon8787

Description

@joon8787

Hello Adafruit team,

Suggestion

This is a feature request to add support for the W6100's hardware ICMP PING command in the Adafruit_CircuitPython_Wiznet5k driver.
The W6100 chip includes a built-in mechanism to issue ICMP PING requests directly in hardware using dedicated registers.

Feature Summary

W6100 supports hardware-based PING using the following registers:
SLDIPR [0x418C-0x418F]: Destination IP address (4 bytes)
PINGID [0x4198-0x4199]: ICMP Ping ID (2 bytes)
PINGSEQ [0x419C-0x419D]: ICMP Ping Sequence Number (2 bytes)
SLCR [0x2130]: Command register — issue 0x24 to send PING

To check if the PING command completed, poll the SLCR register until the value becomes 0x01.

6.6.2 PING in W6100 Datasheet

Suggested Implementation

def ping(self, dest_ip, seq=1, ident=0x1234, timeout=1.0):
        """Send an ICMPv4 Ping request using W6100 hardware PING4 command.

        :param dest_ip: Target IP address as a tuple (e.g., (192, 168, 0, 1))
        :param seq: Ping sequence number
        :param ident: Ping ID
        :param timeout: Timeout in seconds (default 1.0s)
        :raises RuntimeError: If not using W6100
        """
        if self.chip != 6100:
            raise RuntimeError("ping() is supported only on W6100")

        # Register addresses for socket-less ICMP ping
        SLDIPR = 0x0030  # Destination IP
        PINGID = 0x0028
        PINGSEQ = 0x002A
        SLCR   = 0x0024  # Command register (write-only)

        self._write_common(SLDIPR, bytes(dest_ip))
        self._write_common(PINGID, ident.to_bytes(2, 'big'))
        self._write_common(PINGSEQ, seq.to_bytes(2, 'big'))
        self._write_common(SLCR, b'\x20')  # 0x20 = PING4 command (bit 5)

        # Wait until SLCR is cleared (i.e., command completed)
        start = time.monotonic()
        while True:
            status = self._read_common(SLCR, 1)
            if status == b'\x00':
                return True  # Success
            if time.monotonic() - start > timeout:
                return False  # Timeout
            time.sleep(0.01)
eth.ping((192, 168, 100, 1))  # Send hardware ICMP ping from W6100

Summary / PR

This PR adds a ping() method to the WIZNET5K class that enables users of the W6100 chip to send ICMPv4 echo requests using the chip’s hardware PING4 command (bit 5 of SLCR). This is useful for fast, low-overhead IP connectivity testing in static IP or embedded environments. — no overhead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions