![]() |
no-OS
|
Implementation of W5500 Driver. More...
#include "w5500.h"#include <errno.h>#include <string.h>#include "no_os_alloc.h"#include "no_os_delay.h"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. | |
Implementation of W5500 Driver.
Copyright 2025(c) Analog Devices, Inc.
SPDX-License-Identifier: BSD-3-Clause
| int w5500_check_link_status | ( | struct w5500_dev * | dev | ) |
Check the Ethernet link status.
| dev | - The device descriptor |
| int w5500_get_gateway | ( | struct w5500_dev * | dev, |
| uint8_t | gateway[4] ) |
Get gateway address.
| dev | - The device descriptor |
| gateway | - Buffer to store the 4-byte gateway address |
| int w5500_get_ip | ( | struct w5500_dev * | dev, |
| uint8_t | ip[4] ) |
Get IP address.
| dev | - The device descriptor |
| ip | - Buffer to store the 4-byte IP address |
| int w5500_get_mac | ( | struct w5500_dev * | dev, |
| uint8_t | mac[6] ) |
Get MAC address.
| dev | - The device descriptor |
| mac | - Buffer to store the 6-byte MAC address |
| int w5500_get_subnet | ( | struct w5500_dev * | dev, |
| uint8_t | subnet[4] ) |
Get subnet mask.
| dev | - The device descriptor |
| subnet | - Buffer to store the 4-byte subnet mask |
| int w5500_init | ( | struct w5500_dev ** | device, |
| struct w5500_init_param * | init_param ) |
Initialize the device.
| device | - Pointer to the device descriptor to be initialized |
| init_param | - The device's initialization parameters |
| 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.
| 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 |
| 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.
| 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 |
| 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.
| 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 |
| int w5500_remove | ( | struct w5500_dev * | dev | ) |
Free a device descriptor and release resources.
| dev | - The device descriptor to be removed |
| int w5500_reset | ( | struct w5500_dev * | dev | ) |
Reset the W5500 chip using hardware or software method.
| dev | - The device descriptor |
| int w5500_set_gateway | ( | struct w5500_dev * | dev, |
| const uint8_t | gateway[4] ) |
Set gateway address.
| dev | - The device descriptor |
| gateway | - 4-byte gateway address array |
| int w5500_set_ip | ( | struct w5500_dev * | dev, |
| const uint8_t | ip[4] ) |
Set IP address.
| dev | - The device descriptor |
| ip | - 4-byte IP address array |
| int w5500_set_mac | ( | struct w5500_dev * | dev, |
| const uint8_t | mac[6] ) |
Set MAC address.
| dev | - The device descriptor |
| mac | - 6-byte MAC address array |
| int w5500_set_subnet | ( | struct w5500_dev * | dev, |
| const uint8_t | subnet[4] ) |
Set subnet mask.
| dev | - The device descriptor |
| subnet | - 4-byte subnet mask array |
| int w5500_setup | ( | struct w5500_dev * | dev | ) |
Setup the W5500 chip with basic configuration.
| dev | - The device descriptor |
| int w5500_socket_bind | ( | struct w5500_dev * | dev, |
| uint8_t | sock_id, | ||
| uint16_t | port ) |
Bind a socket to a specific port (server mode)
| dev | - Device descriptor |
| sock_id | - Socket number (0-7) |
| port | - Local port number |
| int w5500_socket_clear_interrupt | ( | struct w5500_dev * | dev, |
| uint8_t | sock_id, | ||
| uint8_t | flags ) |
Clear specific socket interrupt flags.
| dev | - Device descriptor |
| sock_id | - Socket number (0-7) |
| flags | - Interrupt flags to clear |
| int w5500_socket_close | ( | struct w5500_dev * | dev, |
| uint8_t | sock_id ) |
Close a socket.
| dev | - Device descriptor |
| sock_id | - Socket number (0-7) |
| 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.
| dev | - The device descriptor |
| sock_id | - Socket number (0-7) |
| val | - Command value to write |
| 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)
| dev | - Device descriptor |
| sock_id | - Socket number (0-7) |
| addr | - Socket address structure containing remote IP and port |
| int w5500_socket_disconnect | ( | struct w5500_dev * | dev, |
| uint8_t | sock_id ) |
Disconnect a TCP connection.
| dev | - Device descriptor |
| sock_id | - Socket number (0-7) |
| int w5500_socket_init | ( | struct w5500_dev * | dev, |
| uint8_t | sock_id ) |
Initialize a socket.
| dev | - Device descriptor |
| sock_id | - Socket number (0-7) |
| int w5500_socket_listen | ( | struct w5500_dev * | dev, |
| uint8_t | sock_id ) |
Set socket to listen mode (TCP server)
| dev | - Device descriptor |
| sock_id | - Socket number (0-7) |
| 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.
| 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) |
| int w5500_socket_read_status | ( | struct w5500_dev * | dev, |
| uint8_t | sock_id, | ||
| uint8_t * | status ) |
Read status of a socket.
| dev | - The device descriptor |
| sock_id | - Socket number (0-7) |
| status | - Variable to store status |
| int w5500_socket_recv | ( | struct w5500_dev * | dev, |
| uint8_t | sock_id, | ||
| void * | buf, | ||
| uint16_t | len ) |
Receive data from a socket.
| dev | - Device descriptor |
| sock_id | - Socket number (0-7) |
| buf | - Buffer to store received data |
| len | - Maximum length to receive |
| 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)
| 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 |
| int w5500_socket_send | ( | struct w5500_dev * | dev, |
| uint8_t | sock_id, | ||
| const void * | buf, | ||
| uint16_t | len ) |
Send data through a socket.
| dev | - Device descriptor |
| sock_id | - Socket number (0-7) |
| buf | - Data buffer to send |
| len | - Data length |
| 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)
| dev | - Device descriptor |
| sock_id | - Socket number (0-7) |
| buf | - Data buffer to send |
| len | - Data length |
| to | - Destination address (IP and port) |
| int w5500_tcp_config | ( | struct w5500_dev * | dev, |
| uint16_t | retry_time, | ||
| uint8_t | retry_count ) |
Configure W5500 TCP parameters (RTR and RCR)
| dev | - The device descriptor |
| retry_time | - Retry timeout value in 100μs units (default: 2000 = 200ms) |
| retry_count | - Maximum retry count (default: 8) |