no-OS
Loading...
Searching...
No Matches
w5500.h File Reference

Header file W5500 Driver. More...

#include "no_os_spi.h"
#include "no_os_gpio.h"
#include "no_os_util.h"
Include dependency graph for w5500.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  w5500_socket_address
 
struct  w5500_socket
 
struct  w5500_dev
 
struct  w5500_init_param
 

Macros

#define W5500_CHIP_VERSION   0x04
 
#define W5500_BYTE_HIGH(value)
 
#define W5500_BYTE_LOW(value)
 
#define W5500_BSB_MASK   NO_OS_GENMASK(7, 3) /* Block Select Bits */
 
#define W5500_RWB_MASK   NO_OS_BIT(2) /* Read/Write Bit */
 
#define W5500_OM_MASK   NO_OS_GENMASK(1, 0) /* Operation Mode Bits */
 
#define W5500_BSB(block)
 
#define W5500_RWB_READ   0x00
 
#define W5500_RWB_WRITE   NO_OS_BIT(2)
 
#define W5500_OM_VDM   0x00 /* Variable Data Length Mode */
 
#define W5500_OM_FDM_1   0x01 /* Fixed Data Length Mode 1 byte */
 
#define W5500_OM_FDM_2   0x02 /* Fixed Data Length Mode 2 bytes */
 
#define W5500_OM_FDM_4   0x03 /* Fixed Data Length Mode 4 bytes */
 
#define W5500_COMMON_REG   0x00 /* Common Register Block */
 
#define W5500_SOCKET_REG_BLOCK(n)
 
#define W5500_SOCKET_TX_BUF_BLOCK(n)
 
#define W5500_SOCKET_RX_BUF_BLOCK(n)
 
#define W5500_MR   0x0000 /* Mode Register */
 
#define W5500_GAR   0x0001 /* Gateway Address Register (4 bytes) */
 
#define W5500_SUBR   0x0005 /* Subnet Mask Register (4 bytes) */
 
#define W5500_SHAR   0x0009 /* Source Hardware Address Register (6 bytes) */
 
#define W5500_SIPR   0x000F /* Source IP Address Register (4 bytes) */
 
#define W5500_INTLEVEL   0x0013 /* Interrupt Low Level Timer Register (2 bytes) */
 
#define W5500_IR   0x0015 /* Interrupt Register */
 
#define W5500_IMR   0x0016 /* Interrupt Mask Register */
 
#define W5500_SIR   0x0017 /* Socket Interrupt Register */
 
#define W5500_SIMR   0x0018 /* Socket Interrupt Mask Register */
 
#define W5500_RTR   0x0019 /* Retry Time Register (2 bytes) */
 
#define W5500_RCR   0x001B /* Retry Count Register */
 
#define W5500_PTIMER   0x001C /* PPP LCP Request Timer Register */
 
#define W5500_PMAGIC   0x001D /* PPP LCP Magic Number Register */
 
#define W5500_PHAR   0x001E /* PPP Destination MAC Register (6 bytes) */
 
#define W5500_PSID   0x0024 /* PPP Session ID Register (2 bytes) */
 
#define W5500_PMRU   0x0026 /* PPP Maximum Segment Size (2 bytes) */
 
#define W5500_UIPR   0x0028 /* Unreachable IP Address Register (4 bytes) */
 
#define W5500_UPORTR   0x002C /* Unreachable Port Register (2 bytes) */
 
#define W5500_PHYCFGR   0x002E /* PHY Configuration Register */
 
#define W5500_VERSIONR   0x0039 /* Chip Version Register */
 
#define W5500_MR_RST   NO_OS_BIT(7) /* Reset */
 
#define W5500_MR_WOL   NO_OS_BIT(5) /* Wake on LAN */
 
#define W5500_MR_PB   NO_OS_BIT(4) /* Ping Block */
 
#define W5500_MR_PPPOE   NO_OS_BIT(3) /* PPPoE Mode */
 
#define W5500_MR_FARP   NO_OS_BIT(1) /* Force ARP */
 
#define W5500_Sn_MR   0x0000 /* Socket n Mode Register */
 
#define W5500_Sn_CR   0x0001 /* Socket n Command Register */
 
#define W5500_Sn_IR   0x0002 /* Socket n Interrupt Register */
 
#define W5500_Sn_SR   0x0003 /* Socket n Status Register */
 
#define W5500_Sn_PORT   0x0004 /* Socket n Source Port Register (2 bytes) */
 
#define W5500_Sn_DHAR   0x0006 /* Socket n Destination Hardware Address Register (6 bytes) */
 
#define W5500_Sn_DIPR   0x000C /* Socket n Destination IP Address Register (4 bytes) */
 
#define W5500_Sn_DPORT   0x0010 /* Socket n Destination Port Register (2 bytes) */
 
#define W5500_Sn_MSSR   0x0012 /* Socket n Maximum Segment Size Register (2 bytes) */
 
#define W5500_Sn_TOS   0x0015 /* Socket n Type of Service Register */
 
#define W5500_Sn_TTL   0x0016 /* Socket n Time to Live Register */
 
#define W5500_Sn_RXBUF_SIZE   0x001E /* Socket n RX Buffer Size Register */
 
#define W5500_Sn_TXBUF_SIZE   0x001F /* Socket n TX Buffer Size Register */
 
#define W5500_Sn_TX_FSR   0x0020 /* Socket n TX Free Size Register (2 bytes) */
 
#define W5500_Sn_TX_RD   0x0022 /* Socket n TX Read Pointer Register (2 bytes) */
 
#define W5500_Sn_TX_WR   0x0024 /* Socket n TX Write Pointer Register (2 bytes) */
 
#define W5500_Sn_RX_RSR   0x0026 /* Socket n RX Received Size Register (2 bytes) */
 
#define W5500_Sn_RX_RD   0x0028 /* Socket n RX Read Pointer Register (2 bytes) */
 
#define W5500_Sn_RX_WR   0x002A /* Socket n RX Write Pointer Register (2 bytes) */
 
#define W5500_Sn_IMR   0x002C /* Socket n Interrupt Mask Register */
 
#define W5500_Sn_FRAG   0x002D /* Socket n Fragment Offset in IP Header (2 bytes) */
 
#define W5500_Sn_KPALVTR   0x002F /* Socket n Keep Alive Timer Register */
 
#define W5500_Sn_MR_CLOSE   0x00 /* Closed */
 
#define W5500_Sn_MR_TCP   0x01 /* TCP */
 
#define W5500_Sn_MR_UDP   0x02 /* UDP */
 
#define W5500_Sn_MR_MACRAW   0x04 /* MAC Raw mode */
 
#define W5500_Sn_MR_NDMC   NO_OS_BIT(5) /* No Delayed ACK */
 
#define W5500_Sn_MR_MULTI   NO_OS_BIT(7) /* Multicasting */
 
#define W5500_Sn_MR_BCASTB   NO_OS_BIT(6) /* Broadcast Blocking */
 
#define W5500_Sn_MR_UCASTB   NO_OS_BIT(4) /* Unicast Blocking (UDP mode) */
 
#define W5500_Sn_MR_MIP6B   NO_OS_BIT(4) /* IPv6 Blocking (MACRAW mode) */
 
#define W5500_Sn_CR_OPEN   0x01 /* Initialize and open socket */
 
#define W5500_Sn_CR_LISTEN   0x02 /* Wait connection request in TCP mode (Server mode) */
 
#define W5500_Sn_CR_CONNECT   0x04 /* Send connection request in TCP mode (Client mode) */
 
#define W5500_Sn_CR_DISCON   0x08 /* Send closing request in TCP mode */
 
#define W5500_Sn_CR_CLOSE   0x10 /* Close socket */
 
#define W5500_Sn_CR_SEND   0x20 /* Send data */
 
#define W5500_Sn_CR_SEND_MAC   0x21 /* Send data with MAC address (UDP mode) */
 
#define W5500_Sn_CR_SEND_KEEP   0x22 /* Send keep-alive packet (TCP mode) */
 
#define W5500_Sn_CR_RECV   0x40 /* Receive data */
 
#define W5500_Sn_SR_CLOSED   0x00 /* Socket is closed */
 
#define W5500_Sn_SR_INIT   0x13 /* Socket is initialized */
 
#define W5500_Sn_SR_LISTEN   0x14 /* Socket is in listen state */
 
#define W5500_Sn_SR_ESTABLISHED   0x17 /* Connection is established */
 
#define W5500_Sn_SR_CLOSE_WAIT   0x1C /* Closing state */
 
#define W5500_Sn_SR_UDP   0x22 /* Socket is in UDP mode */
 
#define W5500_Sn_SR_MACRAW   0x42 /* Socket is in MACRAW mode */
 
#define W5500_Sn_SR_SYNSENT   0x15 /* SYN packet sent (TCP client) */
 
#define W5500_Sn_SR_SYNRECV   0x16 /* SYN packet received (TCP server) */
 
#define W5500_Sn_SR_FIN_WAIT   0x18 /* Socket closing (FIN sent) */
 
#define W5500_Sn_SR_CLOSING   0x1A /* Socket closing (FIN exchanged) */
 
#define W5500_Sn_SR_TIME_WAIT   0x1B /* Socket closing (2MSL timer active) */
 
#define W5500_Sn_SR_LAST_ACK   0x1D /* Socket closing (Last ACK) */
 
#define W5500_Sn_IR_SEND_OK   NO_OS_BIT(4) /* Send operation completed */
 
#define W5500_Sn_IR_TIMEOUT   NO_OS_BIT(3) /* Timeout occurred */
 
#define W5500_Sn_IR_RECV   NO_OS_BIT(2) /* Data received */
 
#define W5500_Sn_IR_DISCON   NO_OS_BIT(1) /* Connection termination requested/completed */
 
#define W5500_Sn_IR_CON   NO_OS_BIT(0) /* Connection established */
 
#define W5500_IR_CONFLICT   NO_OS_BIT(7) /* IP address conflict */
 
#define W5500_IR_UNREACH   NO_OS_BIT(6) /* Destination unreachable */
 
#define W5500_IR_PPPOE   NO_OS_BIT(5) /* PPPoE connection closed */
 
#define W5500_IR_MP   NO_OS_BIT(4) /* Magic packet received */
 
#define W5500_PHYCFGR_RST   NO_OS_BIT(7) /* PHY Reset */
 
#define W5500_PHYCFGR_OPMD   NO_OS_BIT(6) /* Operation Mode Select */
 
#define W5500_PHYCFGR_OPMDC   NO_OS_GENMASK(5, 3) /* Operation Mode Configuration */
 
#define W5500_PHYCFGR_DPX   NO_OS_BIT(2) /* Duplex Status (1=Full, 0=Half) */
 
#define W5500_PHYCFGR_SPD   NO_OS_BIT(1) /* Speed Status (1=100Mbps, 0=10Mbps) */
 
#define W5500_PHYCFGR_LNK   NO_OS_BIT(0) /* Link Status (1=Up, 0=Down) */
 
#define W5500_PHYCFGR_OPMDC_10BT_HD   no_os_field_prep(W5500_PHYCFGR_OPMDC, 0)
 
#define W5500_PHYCFGR_OPMDC_10BT_FD   no_os_field_prep(W5500_PHYCFGR_OPMDC, 1)
 
#define W5500_PHYCFGR_OPMDC_100BT_HD   no_os_field_prep(W5500_PHYCFGR_OPMDC, 2)
 
#define W5500_PHYCFGR_OPMDC_100BT_FD   no_os_field_prep(W5500_PHYCFGR_OPMDC, 3)
 
#define W5500_PHYCFGR_OPMDC_100BT_HD_AN   no_os_field_prep(W5500_PHYCFGR_OPMDC, 4)
 
#define W5500_PHYCFGR_OPMDC_POWER_DOWN   no_os_field_prep(W5500_PHYCFGR_OPMDC, 6)
 
#define W5500_PHYCFGR_OPMDC_ALL_AN   no_os_field_prep(W5500_PHYCFGR_OPMDC, 7)
 
#define W5500_SOCK_BUF_SIZE_0K   0x00 /* 0KB buffer size */
 
#define W5500_SOCK_BUF_SIZE_1K   0x01 /* 1KB buffer size */
 
#define W5500_SOCK_BUF_SIZE_2K   0x02 /* 2KB buffer size (default) */
 
#define W5500_SOCK_BUF_SIZE_4K   0x04 /* 4KB buffer size */
 
#define W5500_SOCK_BUF_SIZE_8K   0x08 /* 8KB buffer size */
 
#define W5500_SOCK_BUF_SIZE_16K   0x10 /* 16KB buffer size */
 
#define W5500_MAX_SOCK_NUMBER   7 /* 8 sockets (0-7) */
 

Functions

int w5500_reg_write (struct w5500_dev *dev, uint8_t block, uint16_t addr, const uint8_t *data, uint16_t len)
 Write data to a W5500 register.
 
int w5500_reg_read (struct w5500_dev *dev, uint8_t block, uint16_t addr, uint8_t *data, uint16_t len)
 Read data from a W5500 register.
 
int w5500_read_16bit_reg (struct w5500_dev *dev, uint8_t block, uint16_t addr, uint16_t *value)
 Read a 16-bit register reliably by reading until consecutive values match.
 
int w5500_set_mac (struct w5500_dev *dev, const uint8_t mac[6])
 Set MAC address.
 
int w5500_set_ip (struct w5500_dev *dev, const uint8_t ip[4])
 Set IP address.
 
int w5500_set_subnet (struct w5500_dev *dev, const uint8_t subnet[4])
 Set subnet mask.
 
int w5500_set_gateway (struct w5500_dev *dev, const uint8_t gateway[4])
 Set gateway address.
 
int w5500_get_mac (struct w5500_dev *dev, uint8_t mac[6])
 Get MAC address.
 
int w5500_get_ip (struct w5500_dev *dev, uint8_t ip[4])
 Get IP address.
 
int w5500_get_subnet (struct w5500_dev *dev, uint8_t subnet[4])
 Get subnet mask.
 
int w5500_get_gateway (struct w5500_dev *dev, uint8_t gateway[4])
 Get gateway address.
 
int w5500_check_link_status (struct w5500_dev *dev)
 Check the Ethernet link status.
 
int w5500_tcp_config (struct w5500_dev *dev, uint16_t retry_time, uint8_t retry_count)
 Configure W5500 TCP parameters (RTR and RCR)
 
int w5500_socket_read_status (struct w5500_dev *dev, uint8_t sock_id, uint8_t *status)
 Read status of a socket.
 
int w5500_socket_command_write (struct w5500_dev *dev, uint8_t sock_id, uint8_t val)
 Write a command to a socket's command register.
 
int w5500_socket_clear_interrupt (struct w5500_dev *dev, uint8_t sock_id, uint8_t flags)
 Clear specific socket interrupt flags.
 
int w5500_socket_init (struct w5500_dev *dev, uint8_t sock_id)
 Initialize a socket.
 
int w5500_socket_open (struct w5500_dev *dev, uint8_t sock_id, uint8_t protocol, uint8_t buff_size)
 Open a socket with specified protocol.
 
int w5500_socket_close (struct w5500_dev *dev, uint8_t sock_id)
 Close a socket.
 
int w5500_socket_connect (struct w5500_dev *dev, uint8_t sock_id, struct w5500_socket_address *addr)
 Connect to a remote host (TCP client mode)
 
int w5500_socket_disconnect (struct w5500_dev *dev, uint8_t sock_id)
 Disconnect a TCP connection.
 
int w5500_socket_send (struct w5500_dev *dev, uint8_t sock_id, const void *buf, uint16_t len)
 Send data through a socket.
 
int w5500_socket_recv (struct w5500_dev *dev, uint8_t sock_id, void *buf, uint16_t len)
 Receive data from a socket.
 
int w5500_socket_sendto (struct w5500_dev *dev, uint8_t sock_id, const void *buf, uint16_t len, struct w5500_socket_address *to)
 Send data to a specific destination (UDP)
 
int w5500_socket_recvfrom (struct w5500_dev *dev, uint8_t sock_id, void *buf, uint16_t len, struct w5500_socket_address *from)
 Receive data from a socket with source address information (UDP)
 
int w5500_socket_bind (struct w5500_dev *dev, uint8_t sock_id, uint16_t port)
 Bind a socket to a specific port (server mode)
 
int w5500_socket_listen (struct w5500_dev *dev, uint8_t sock_id)
 Set socket to listen mode (TCP server)
 
int w5500_reset (struct w5500_dev *dev)
 Reset the W5500 chip using hardware or software method.
 
int w5500_setup (struct w5500_dev *dev)
 Setup the W5500 chip with basic configuration.
 
int w5500_init (struct w5500_dev **device, struct w5500_init_param *init_param)
 Initialize the device.
 
int w5500_remove (struct w5500_dev *dev)
 Free a device descriptor and release resources.
 

Detailed Description

Header file W5500 Driver.

Author
Alisa-Dariana Roman (alisa.nosp@m..rom.nosp@m.an@an.nosp@m.alog.nosp@m..com)

Copyright 2025(c) Analog Devices, Inc.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Macro Definition Documentation

◆ W5500_BSB

#define W5500_BSB ( block)
Value:
uint32_t no_os_field_prep(uint32_t mask, uint32_t val)
#define W5500_BSB_MASK
Definition w5500.h:48

◆ W5500_BSB_MASK

#define W5500_BSB_MASK   NO_OS_GENMASK(7, 3) /* Block Select Bits */

◆ W5500_BYTE_HIGH

#define W5500_BYTE_HIGH ( value)
Value:
(((value) >> 8) & 0xFF)

◆ W5500_BYTE_LOW

#define W5500_BYTE_LOW ( value)
Value:
((value) & 0xFF)

◆ W5500_CHIP_VERSION

#define W5500_CHIP_VERSION   0x04

◆ W5500_COMMON_REG

#define W5500_COMMON_REG   0x00 /* Common Register Block */

◆ W5500_GAR

#define W5500_GAR   0x0001 /* Gateway Address Register (4 bytes) */

◆ W5500_IMR

#define W5500_IMR   0x0016 /* Interrupt Mask Register */

◆ W5500_INTLEVEL

#define W5500_INTLEVEL   0x0013 /* Interrupt Low Level Timer Register (2 bytes) */

◆ W5500_IR

#define W5500_IR   0x0015 /* Interrupt Register */

◆ W5500_IR_CONFLICT

#define W5500_IR_CONFLICT   NO_OS_BIT(7) /* IP address conflict */

◆ W5500_IR_MP

#define W5500_IR_MP   NO_OS_BIT(4) /* Magic packet received */

◆ W5500_IR_PPPOE

#define W5500_IR_PPPOE   NO_OS_BIT(5) /* PPPoE connection closed */

◆ W5500_IR_UNREACH

#define W5500_IR_UNREACH   NO_OS_BIT(6) /* Destination unreachable */

◆ W5500_MAX_SOCK_NUMBER

#define W5500_MAX_SOCK_NUMBER   7 /* 8 sockets (0-7) */

◆ W5500_MR

#define W5500_MR   0x0000 /* Mode Register */

◆ W5500_MR_FARP

#define W5500_MR_FARP   NO_OS_BIT(1) /* Force ARP */

◆ W5500_MR_PB

#define W5500_MR_PB   NO_OS_BIT(4) /* Ping Block */

◆ W5500_MR_PPPOE

#define W5500_MR_PPPOE   NO_OS_BIT(3) /* PPPoE Mode */

◆ W5500_MR_RST

#define W5500_MR_RST   NO_OS_BIT(7) /* Reset */

◆ W5500_MR_WOL

#define W5500_MR_WOL   NO_OS_BIT(5) /* Wake on LAN */

◆ W5500_OM_FDM_1

#define W5500_OM_FDM_1   0x01 /* Fixed Data Length Mode 1 byte */

◆ W5500_OM_FDM_2

#define W5500_OM_FDM_2   0x02 /* Fixed Data Length Mode 2 bytes */

◆ W5500_OM_FDM_4

#define W5500_OM_FDM_4   0x03 /* Fixed Data Length Mode 4 bytes */

◆ W5500_OM_MASK

#define W5500_OM_MASK   NO_OS_GENMASK(1, 0) /* Operation Mode Bits */

◆ W5500_OM_VDM

#define W5500_OM_VDM   0x00 /* Variable Data Length Mode */

◆ W5500_PHAR

#define W5500_PHAR   0x001E /* PPP Destination MAC Register (6 bytes) */

◆ W5500_PHYCFGR

#define W5500_PHYCFGR   0x002E /* PHY Configuration Register */

◆ W5500_PHYCFGR_DPX

#define W5500_PHYCFGR_DPX   NO_OS_BIT(2) /* Duplex Status (1=Full, 0=Half) */

◆ W5500_PHYCFGR_LNK

#define W5500_PHYCFGR_LNK   NO_OS_BIT(0) /* Link Status (1=Up, 0=Down) */

◆ W5500_PHYCFGR_OPMD

#define W5500_PHYCFGR_OPMD   NO_OS_BIT(6) /* Operation Mode Select */

◆ W5500_PHYCFGR_OPMDC

#define W5500_PHYCFGR_OPMDC   NO_OS_GENMASK(5, 3) /* Operation Mode Configuration */

◆ W5500_PHYCFGR_OPMDC_100BT_FD

#define W5500_PHYCFGR_OPMDC_100BT_FD   no_os_field_prep(W5500_PHYCFGR_OPMDC, 3)

◆ W5500_PHYCFGR_OPMDC_100BT_HD

#define W5500_PHYCFGR_OPMDC_100BT_HD   no_os_field_prep(W5500_PHYCFGR_OPMDC, 2)

◆ W5500_PHYCFGR_OPMDC_100BT_HD_AN

#define W5500_PHYCFGR_OPMDC_100BT_HD_AN   no_os_field_prep(W5500_PHYCFGR_OPMDC, 4)

◆ W5500_PHYCFGR_OPMDC_10BT_FD

#define W5500_PHYCFGR_OPMDC_10BT_FD   no_os_field_prep(W5500_PHYCFGR_OPMDC, 1)

◆ W5500_PHYCFGR_OPMDC_10BT_HD

#define W5500_PHYCFGR_OPMDC_10BT_HD   no_os_field_prep(W5500_PHYCFGR_OPMDC, 0)

◆ W5500_PHYCFGR_OPMDC_ALL_AN

#define W5500_PHYCFGR_OPMDC_ALL_AN   no_os_field_prep(W5500_PHYCFGR_OPMDC, 7)

◆ W5500_PHYCFGR_OPMDC_POWER_DOWN

#define W5500_PHYCFGR_OPMDC_POWER_DOWN   no_os_field_prep(W5500_PHYCFGR_OPMDC, 6)

◆ W5500_PHYCFGR_RST

#define W5500_PHYCFGR_RST   NO_OS_BIT(7) /* PHY Reset */

◆ W5500_PHYCFGR_SPD

#define W5500_PHYCFGR_SPD   NO_OS_BIT(1) /* Speed Status (1=100Mbps, 0=10Mbps) */

◆ W5500_PMAGIC

#define W5500_PMAGIC   0x001D /* PPP LCP Magic Number Register */

◆ W5500_PMRU

#define W5500_PMRU   0x0026 /* PPP Maximum Segment Size (2 bytes) */

◆ W5500_PSID

#define W5500_PSID   0x0024 /* PPP Session ID Register (2 bytes) */

◆ W5500_PTIMER

#define W5500_PTIMER   0x001C /* PPP LCP Request Timer Register */

◆ W5500_RCR

#define W5500_RCR   0x001B /* Retry Count Register */

◆ W5500_RTR

#define W5500_RTR   0x0019 /* Retry Time Register (2 bytes) */

◆ W5500_RWB_MASK

#define W5500_RWB_MASK   NO_OS_BIT(2) /* Read/Write Bit */

◆ W5500_RWB_READ

#define W5500_RWB_READ   0x00

◆ W5500_RWB_WRITE

#define W5500_RWB_WRITE   NO_OS_BIT(2)

◆ W5500_SHAR

#define W5500_SHAR   0x0009 /* Source Hardware Address Register (6 bytes) */

◆ W5500_SIMR

#define W5500_SIMR   0x0018 /* Socket Interrupt Mask Register */

◆ W5500_SIPR

#define W5500_SIPR   0x000F /* Source IP Address Register (4 bytes) */

◆ W5500_SIR

#define W5500_SIR   0x0017 /* Socket Interrupt Register */

◆ W5500_Sn_CR

#define W5500_Sn_CR   0x0001 /* Socket n Command Register */

◆ W5500_Sn_CR_CLOSE

#define W5500_Sn_CR_CLOSE   0x10 /* Close socket */

◆ W5500_Sn_CR_CONNECT

#define W5500_Sn_CR_CONNECT   0x04 /* Send connection request in TCP mode (Client mode) */

◆ W5500_Sn_CR_DISCON

#define W5500_Sn_CR_DISCON   0x08 /* Send closing request in TCP mode */

◆ W5500_Sn_CR_LISTEN

#define W5500_Sn_CR_LISTEN   0x02 /* Wait connection request in TCP mode (Server mode) */

◆ W5500_Sn_CR_OPEN

#define W5500_Sn_CR_OPEN   0x01 /* Initialize and open socket */

◆ W5500_Sn_CR_RECV

#define W5500_Sn_CR_RECV   0x40 /* Receive data */

◆ W5500_Sn_CR_SEND

#define W5500_Sn_CR_SEND   0x20 /* Send data */

◆ W5500_Sn_CR_SEND_KEEP

#define W5500_Sn_CR_SEND_KEEP   0x22 /* Send keep-alive packet (TCP mode) */

◆ W5500_Sn_CR_SEND_MAC

#define W5500_Sn_CR_SEND_MAC   0x21 /* Send data with MAC address (UDP mode) */

◆ W5500_Sn_DHAR

#define W5500_Sn_DHAR   0x0006 /* Socket n Destination Hardware Address Register (6 bytes) */

◆ W5500_Sn_DIPR

#define W5500_Sn_DIPR   0x000C /* Socket n Destination IP Address Register (4 bytes) */

◆ W5500_Sn_DPORT

#define W5500_Sn_DPORT   0x0010 /* Socket n Destination Port Register (2 bytes) */

◆ W5500_Sn_FRAG

#define W5500_Sn_FRAG   0x002D /* Socket n Fragment Offset in IP Header (2 bytes) */

◆ W5500_Sn_IMR

#define W5500_Sn_IMR   0x002C /* Socket n Interrupt Mask Register */

◆ W5500_Sn_IR

#define W5500_Sn_IR   0x0002 /* Socket n Interrupt Register */

◆ W5500_Sn_IR_CON

#define W5500_Sn_IR_CON   NO_OS_BIT(0) /* Connection established */

◆ W5500_Sn_IR_DISCON

#define W5500_Sn_IR_DISCON   NO_OS_BIT(1) /* Connection termination requested/completed */

◆ W5500_Sn_IR_RECV

#define W5500_Sn_IR_RECV   NO_OS_BIT(2) /* Data received */

◆ W5500_Sn_IR_SEND_OK

#define W5500_Sn_IR_SEND_OK   NO_OS_BIT(4) /* Send operation completed */

◆ W5500_Sn_IR_TIMEOUT

#define W5500_Sn_IR_TIMEOUT   NO_OS_BIT(3) /* Timeout occurred */

◆ W5500_Sn_KPALVTR

#define W5500_Sn_KPALVTR   0x002F /* Socket n Keep Alive Timer Register */

◆ W5500_Sn_MR

#define W5500_Sn_MR   0x0000 /* Socket n Mode Register */

◆ W5500_Sn_MR_BCASTB

#define W5500_Sn_MR_BCASTB   NO_OS_BIT(6) /* Broadcast Blocking */

◆ W5500_Sn_MR_CLOSE

#define W5500_Sn_MR_CLOSE   0x00 /* Closed */

◆ W5500_Sn_MR_MACRAW

#define W5500_Sn_MR_MACRAW   0x04 /* MAC Raw mode */

◆ W5500_Sn_MR_MIP6B

#define W5500_Sn_MR_MIP6B   NO_OS_BIT(4) /* IPv6 Blocking (MACRAW mode) */

◆ W5500_Sn_MR_MULTI

#define W5500_Sn_MR_MULTI   NO_OS_BIT(7) /* Multicasting */

◆ W5500_Sn_MR_NDMC

#define W5500_Sn_MR_NDMC   NO_OS_BIT(5) /* No Delayed ACK */

◆ W5500_Sn_MR_TCP

#define W5500_Sn_MR_TCP   0x01 /* TCP */

◆ W5500_Sn_MR_UCASTB

#define W5500_Sn_MR_UCASTB   NO_OS_BIT(4) /* Unicast Blocking (UDP mode) */

◆ W5500_Sn_MR_UDP

#define W5500_Sn_MR_UDP   0x02 /* UDP */

◆ W5500_Sn_MSSR

#define W5500_Sn_MSSR   0x0012 /* Socket n Maximum Segment Size Register (2 bytes) */

◆ W5500_Sn_PORT

#define W5500_Sn_PORT   0x0004 /* Socket n Source Port Register (2 bytes) */

◆ W5500_Sn_RX_RD

#define W5500_Sn_RX_RD   0x0028 /* Socket n RX Read Pointer Register (2 bytes) */

◆ W5500_Sn_RX_RSR

#define W5500_Sn_RX_RSR   0x0026 /* Socket n RX Received Size Register (2 bytes) */

◆ W5500_Sn_RX_WR

#define W5500_Sn_RX_WR   0x002A /* Socket n RX Write Pointer Register (2 bytes) */

◆ W5500_Sn_RXBUF_SIZE

#define W5500_Sn_RXBUF_SIZE   0x001E /* Socket n RX Buffer Size Register */

◆ W5500_Sn_SR

#define W5500_Sn_SR   0x0003 /* Socket n Status Register */

◆ W5500_Sn_SR_CLOSE_WAIT

#define W5500_Sn_SR_CLOSE_WAIT   0x1C /* Closing state */

◆ W5500_Sn_SR_CLOSED

#define W5500_Sn_SR_CLOSED   0x00 /* Socket is closed */

◆ W5500_Sn_SR_CLOSING

#define W5500_Sn_SR_CLOSING   0x1A /* Socket closing (FIN exchanged) */

◆ W5500_Sn_SR_ESTABLISHED

#define W5500_Sn_SR_ESTABLISHED   0x17 /* Connection is established */

◆ W5500_Sn_SR_FIN_WAIT

#define W5500_Sn_SR_FIN_WAIT   0x18 /* Socket closing (FIN sent) */

◆ W5500_Sn_SR_INIT

#define W5500_Sn_SR_INIT   0x13 /* Socket is initialized */

◆ W5500_Sn_SR_LAST_ACK

#define W5500_Sn_SR_LAST_ACK   0x1D /* Socket closing (Last ACK) */

◆ W5500_Sn_SR_LISTEN

#define W5500_Sn_SR_LISTEN   0x14 /* Socket is in listen state */

◆ W5500_Sn_SR_MACRAW

#define W5500_Sn_SR_MACRAW   0x42 /* Socket is in MACRAW mode */

◆ W5500_Sn_SR_SYNRECV

#define W5500_Sn_SR_SYNRECV   0x16 /* SYN packet received (TCP server) */

◆ W5500_Sn_SR_SYNSENT

#define W5500_Sn_SR_SYNSENT   0x15 /* SYN packet sent (TCP client) */

◆ W5500_Sn_SR_TIME_WAIT

#define W5500_Sn_SR_TIME_WAIT   0x1B /* Socket closing (2MSL timer active) */

◆ W5500_Sn_SR_UDP

#define W5500_Sn_SR_UDP   0x22 /* Socket is in UDP mode */

◆ W5500_Sn_TOS

#define W5500_Sn_TOS   0x0015 /* Socket n Type of Service Register */

◆ W5500_Sn_TTL

#define W5500_Sn_TTL   0x0016 /* Socket n Time to Live Register */

◆ W5500_Sn_TX_FSR

#define W5500_Sn_TX_FSR   0x0020 /* Socket n TX Free Size Register (2 bytes) */

◆ W5500_Sn_TX_RD

#define W5500_Sn_TX_RD   0x0022 /* Socket n TX Read Pointer Register (2 bytes) */

◆ W5500_Sn_TX_WR

#define W5500_Sn_TX_WR   0x0024 /* Socket n TX Write Pointer Register (2 bytes) */

◆ W5500_Sn_TXBUF_SIZE

#define W5500_Sn_TXBUF_SIZE   0x001F /* Socket n TX Buffer Size Register */

◆ W5500_SOCK_BUF_SIZE_0K

#define W5500_SOCK_BUF_SIZE_0K   0x00 /* 0KB buffer size */

◆ W5500_SOCK_BUF_SIZE_16K

#define W5500_SOCK_BUF_SIZE_16K   0x10 /* 16KB buffer size */

◆ W5500_SOCK_BUF_SIZE_1K

#define W5500_SOCK_BUF_SIZE_1K   0x01 /* 1KB buffer size */

◆ W5500_SOCK_BUF_SIZE_2K

#define W5500_SOCK_BUF_SIZE_2K   0x02 /* 2KB buffer size (default) */

◆ W5500_SOCK_BUF_SIZE_4K

#define W5500_SOCK_BUF_SIZE_4K   0x04 /* 4KB buffer size */

◆ W5500_SOCK_BUF_SIZE_8K

#define W5500_SOCK_BUF_SIZE_8K   0x08 /* 8KB buffer size */

◆ W5500_SOCKET_REG_BLOCK

#define W5500_SOCKET_REG_BLOCK ( n)
Value:
(0x01 + (n) * 4) /* Socket n Register Block */

◆ W5500_SOCKET_RX_BUF_BLOCK

#define W5500_SOCKET_RX_BUF_BLOCK ( n)
Value:
(0x03 + (n) * 4) /* Socket n RX Buffer Block */

◆ W5500_SOCKET_TX_BUF_BLOCK

#define W5500_SOCKET_TX_BUF_BLOCK ( n)
Value:
(0x02 + (n) * 4) /* Socket n TX Buffer Block */

◆ W5500_SUBR

#define W5500_SUBR   0x0005 /* Subnet Mask Register (4 bytes) */

◆ W5500_UIPR

#define W5500_UIPR   0x0028 /* Unreachable IP Address Register (4 bytes) */

◆ W5500_UPORTR

#define W5500_UPORTR   0x002C /* Unreachable Port Register (2 bytes) */

◆ W5500_VERSIONR

#define W5500_VERSIONR   0x0039 /* Chip Version Register */

Function Documentation

◆ w5500_check_link_status()

int w5500_check_link_status ( struct w5500_dev * dev)

Check the Ethernet link status.

Check the Ethernet link status

Parameters
dev- The device descriptor
Returns
0 if link is up, -ENETDOWN if link is down, other negative codes on error
Here is the caller graph for this function:

◆ w5500_get_gateway()

int w5500_get_gateway ( struct w5500_dev * dev,
uint8_t gateway[4] )

Get gateway address.

Get gateway address

Parameters
dev- The device descriptor
gateway- Buffer to store the 4-byte gateway address
Returns
0 in case of success, negative error code otherwise

◆ w5500_get_ip()

int w5500_get_ip ( struct w5500_dev * dev,
uint8_t ip[4] )

Get IP address.

Get IP address

Parameters
dev- The device descriptor
ip- Buffer to store the 4-byte IP address
Returns
0 in case of success, negative error code otherwise

◆ w5500_get_mac()

int w5500_get_mac ( struct w5500_dev * dev,
uint8_t mac[6] )

Get MAC address.

Get MAC address

Parameters
dev- The device descriptor
mac- Buffer to store the 6-byte MAC address
Returns
0 in case of success, negative error code otherwise

◆ w5500_get_subnet()

int w5500_get_subnet ( struct w5500_dev * dev,
uint8_t subnet[4] )

Get subnet mask.

Get subnet mask

Parameters
dev- The device descriptor
subnet- Buffer to store the 4-byte subnet mask
Returns
0 in case of success, negative error code otherwise

◆ w5500_init()

int w5500_init ( struct w5500_dev ** device,
struct w5500_init_param * init_param )

Initialize the device.

Initialize the device

Parameters
device- Pointer to the device descriptor to be initialized
init_param- The device's initialization parameters
Returns
0 in case of success, negative error code otherwise

◆ w5500_read_16bit_reg()

int w5500_read_16bit_reg ( struct w5500_dev * dev,
uint8_t block,
uint16_t addr,
uint16_t * value )

Read a 16-bit register reliably by reading until consecutive values match.

Read a 16-bit register reliably by reading until consecutive values match

Parameters
dev- The device descriptor
block- The block select bits (common registers, socket registers, etc.)
addr- The register address
value- Pointer to store the 16-bit value
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ w5500_reg_read()

int w5500_reg_read ( struct w5500_dev * dev,
uint8_t block,
uint16_t addr,
uint8_t * data,
uint16_t len )

Read data from a W5500 register.

Read data from a W5500 register

Parameters
dev- The device descriptor
block- The block select bits (common registers, socket registers, etc.)
addr- The register address
data- The buffer to store read data
len- The data length to read
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ w5500_reg_write()

int w5500_reg_write ( struct w5500_dev * dev,
uint8_t block,
uint16_t addr,
const uint8_t * data,
uint16_t len )

Write data to a W5500 register.

Write data to a W5500 register

Parameters
dev- The device descriptor
block- The block select bits (common registers, socket registers, etc.)
addr- The register address
data- The data buffer to write
len- The data length
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ w5500_remove()

int w5500_remove ( struct w5500_dev * dev)

Free a device descriptor and release resources.

Free a device descriptor and release resources

Parameters
dev- The device descriptor to be removed
Returns
0 in case of success, negative error code otherwise

◆ w5500_reset()

int w5500_reset ( struct w5500_dev * dev)

Reset the W5500 chip using hardware or software method.

Reset the W5500 chip using hardware or software method

Parameters
dev- The device descriptor
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ w5500_set_gateway()

int w5500_set_gateway ( struct w5500_dev * dev,
const uint8_t gateway[4] )

Set gateway address.

Set gateway address

Parameters
dev- The device descriptor
gateway- 4-byte gateway address array
Returns
0 in case of success, negative error code otherwise

◆ w5500_set_ip()

int w5500_set_ip ( struct w5500_dev * dev,
const uint8_t ip[4] )

Set IP address.

Set IP address

Parameters
dev- The device descriptor
ip- 4-byte IP address array
Returns
0 in case of success, negative error code otherwise

◆ w5500_set_mac()

int w5500_set_mac ( struct w5500_dev * dev,
const uint8_t mac[6] )

Set MAC address.

Set MAC address

Parameters
dev- The device descriptor
mac- 6-byte MAC address array
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ w5500_set_subnet()

int w5500_set_subnet ( struct w5500_dev * dev,
const uint8_t subnet[4] )

Set subnet mask.

Set subnet mask

Parameters
dev- The device descriptor
subnet- 4-byte subnet mask array
Returns
0 in case of success, negative error code otherwise

◆ w5500_setup()

int w5500_setup ( struct w5500_dev * dev)

Setup the W5500 chip with basic configuration.

Setup the W5500 chip with basic configuration

Parameters
dev- The device descriptor
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ w5500_socket_bind()

int w5500_socket_bind ( struct w5500_dev * dev,
uint8_t sock_id,
uint16_t port )

Bind a socket to a specific port (server mode)

Bind a socket to a specific port (server mode)

Parameters
dev- Device descriptor
sock_id- Socket number (0-7)
port- Local port number
Returns
0 on success, negative error code otherwise

◆ w5500_socket_clear_interrupt()

int w5500_socket_clear_interrupt ( struct w5500_dev * dev,
uint8_t sock_id,
uint8_t flags )

Clear specific socket interrupt flags.

Clear specific socket interrupt flags

Parameters
dev- Device descriptor
sock_id- Socket number (0-7)
flags- Interrupt flags to clear
Returns
0 on success, negative error code otherwise
Here is the caller graph for this function:

◆ w5500_socket_close()

int w5500_socket_close ( struct w5500_dev * dev,
uint8_t sock_id )

Close a socket.

Close a socket

Parameters
dev- Device descriptor
sock_id- Socket number (0-7)
Returns
0 on success, negative error code otherwise

◆ w5500_socket_command_write()

int w5500_socket_command_write ( struct w5500_dev * dev,
uint8_t sock_id,
uint8_t val )

Write a command to a socket's command register.

Write a command to a socket's command register

Parameters
dev- The device descriptor
sock_id- Socket number (0-7)
val- Command value to write
Returns
0 on success, negative error code otherwise
Here is the caller graph for this function:

◆ w5500_socket_connect()

int w5500_socket_connect ( struct w5500_dev * dev,
uint8_t sock_id,
struct w5500_socket_address * addr )

Connect to a remote host (TCP client mode)

Connect to a remote host (TCP client mode)

Parameters
dev- Device descriptor
sock_id- Socket number (0-7)
addr- Socket address structure containing remote IP and port
Returns
0 on success, negative error code otherwise

◆ w5500_socket_disconnect()

int w5500_socket_disconnect ( struct w5500_dev * dev,
uint8_t sock_id )

Disconnect a TCP connection.

Disconnect a TCP connection

Parameters
dev- Device descriptor
sock_id- Socket number (0-7)
Returns
0 on success, -ENOTCONN if not connected, other negative error codes

◆ w5500_socket_init()

int w5500_socket_init ( struct w5500_dev * dev,
uint8_t sock_id )

Initialize a socket.

Initialize a socket

Parameters
dev- Device descriptor
sock_id- Socket number (0-7)
Returns
0 on success, negative error code otherwise
Here is the caller graph for this function:

◆ w5500_socket_listen()

int w5500_socket_listen ( struct w5500_dev * dev,
uint8_t sock_id )

Set socket to listen mode (TCP server)

Set socket to listen mode (TCP server)

Parameters
dev- Device descriptor
sock_id- Socket number (0-7)
Returns
0 on success, negative error code otherwise

◆ w5500_socket_open()

int w5500_socket_open ( struct w5500_dev * dev,
uint8_t sock_id,
uint8_t protocol,
uint8_t buff_size )

Open a socket with specified protocol.

Open a socket with specified protocol

Parameters
dev- The device descriptor
sock_id- Socket ID to use (0-7)
protocol- W5500 mode register protocol
buff_size- Buffer size (1, 2, 4, 8, 16 KB)
Returns
0 on success, negative error code otherwise

◆ w5500_socket_read_status()

int w5500_socket_read_status ( struct w5500_dev * dev,
uint8_t sock_id,
uint8_t * status )

Read status of a socket.

Read status of a socket

Parameters
dev- The device descriptor
sock_id- Socket number (0-7)
status- Variable to store status
Returns
0 on success, negative error code otherwise

◆ w5500_socket_recv()

int w5500_socket_recv ( struct w5500_dev * dev,
uint8_t sock_id,
void * buf,
uint16_t len )

Receive data from a socket.

Receive data from a socket

Parameters
dev- Device descriptor
sock_id- Socket number (0-7)
buf- Buffer to store received data
len- Maximum length to receive
Returns
Number of bytes received on success, negative error code otherwise

◆ w5500_socket_recvfrom()

int w5500_socket_recvfrom ( struct w5500_dev * dev,
uint8_t sock_id,
void * buf,
uint16_t len,
struct w5500_socket_address * from )

Receive data from a socket with source address information (UDP)

Receive data from a socket with source address information (UDP)

Parameters
dev- Device descriptor
sock_id- Socket number (0-7)
buf- Buffer to store received data
len- Maximum length to receive
from- Structure to store source address information
Returns
Number of bytes received on success, negative error code otherwise

◆ w5500_socket_send()

int w5500_socket_send ( struct w5500_dev * dev,
uint8_t sock_id,
const void * buf,
uint16_t len )

Send data through a socket.

Send data through a socket

Parameters
dev- Device descriptor
sock_id- Socket number (0-7)
buf- Data buffer to send
len- Data length
Returns
Number of bytes sent on success, negative error code otherwise

◆ w5500_socket_sendto()

int w5500_socket_sendto ( struct w5500_dev * dev,
uint8_t sock_id,
const void * buf,
uint16_t len,
struct w5500_socket_address * to )

Send data to a specific destination (UDP)

Send data to a specific destination (UDP)

Parameters
dev- Device descriptor
sock_id- Socket number (0-7)
buf- Data buffer to send
len- Data length
to- Destination address (IP and port)
Returns
0 on success, negative error code otherwise

◆ w5500_tcp_config()

int w5500_tcp_config ( struct w5500_dev * dev,
uint16_t retry_time,
uint8_t retry_count )

Configure W5500 TCP parameters (RTR and RCR)

Configure W5500 TCP parameters (RTR and RCR)

Parameters
dev- The device descriptor
retry_time- Retry timeout value in 100μs units (default: 2000 = 200ms)
retry_count- Maximum retry count (default: 8)
Returns
0 on success, negative error code otherwise
Here is the caller graph for this function: