W5500Device class final
#include <hal/wizchip/w5500_device.hpp>
Low-level W5500 HAL driver for SPI-connected Ethernet MAC/PHY chip.
This class owns only hardware-facing behavior:
- SPI register and buffer transactions
- GPIO-based reset and interrupt line handling
- optional DMA-backed payload transfer over SPI
- chip/runtime setup for Socket 0 in MACRAW mode
It deliberately does not implement TCP/IP stack behavior, socket API policy, or lwIP netif adaptation. Higher layers should use this class through dependency injection and keep network policy outside HAL.
Public types
- struct Config
- Static wiring and transport configuration for one W5500 instance.
- struct RuntimeConfig
- Runtime chip configuration applied by initialize_
macraw().
Constructors, destructors, conversion operators
- W5500Device() defaulted
- ~W5500Device()
Public functions
-
auto enable_interrupt_irq(prf::
hal:: GpioIrqBinding& binding, prf:: hal:: GpioIrqBinding:: Callback callback, void* user_ctx) const -> bool - Binds falling-edge GPIO IRQ callback to the W5500 INT pin.
- auto hard_reset() -> bool
- Performs hardware reset pulse on W5500 reset pin.
- auto init(const Config& config) -> bool
- Initializes bus/pins and optionally reserves DMA channels.
- auto initialize_macraw() -> bool
- Initializes W5500 in MACRAW mode with default RuntimeConfig.
- auto initialize_macraw(const RuntimeConfig& config) -> bool
- Initializes W5500 for MACRAW operation on Socket 0.
- auto interrupt_pending() const -> bool
- Returns true when INT pin is active (low).
- auto macraw_ack_receive() -> bool
- Issues RECV command for Socket 0.
- auto macraw_interrupt_pending() const -> bool
- Convenience alias for interrupt_
pending() in MACRAW context. - auto macraw_receive_frame(uint8_t* out_frame, size_t out_capacity, size_t* out_len, uint32_t timeout_ms = 1u) -> bool
- Receives one Ethernet frame from MACRAW Socket 0.
- auto macraw_send_frame(const uint8_t* frame, size_t frame_len, uint32_t timeout_ms = 20u) -> bool
- Sends one Ethernet frame via MACRAW Socket 0.
- auto read(uint8_t block_select, uint16_t address, uint8_t* out, size_t len) -> bool
- Reads raw bytes from selected W5500 block/address over SPI.
- auto read_common_u16(uint16_t address, uint16_t* out) -> bool
- Reads 16-bit register from common register block.
- auto read_common_u8(uint16_t address, uint8_t* out) -> bool
- Reads 8-bit register from common register block.
- auto read_u16(uint8_t block_select, uint16_t address, uint16_t* out) -> bool
- Reads one 16-bit big-endian register from block/address.
- auto read_u8(uint8_t block_select, uint16_t address, uint8_t* out) -> bool
- Reads one byte from block/address.
- auto read_version(uint8_t* out_version) -> bool
- Reads W5500 VERSIONR register.
- auto ready() const -> bool
- Reports if low-level transport and pins are initialized.
- auto write(uint8_t block_select, uint16_t address, const uint8_t* data, size_t len) -> bool
- Writes raw bytes to selected W5500 block/address over SPI.
- auto write_common_u16(uint16_t address, uint16_t value) -> bool
- Writes 16-bit register to common register block.
- auto write_common_u8(uint16_t address, uint8_t value) -> bool
- Writes 8-bit register to common register block.
- auto write_u16(uint8_t block_select, uint16_t address, uint16_t value) -> bool
- Writes one 16-bit big-endian register to block/address.
- auto write_u8(uint8_t block_select, uint16_t address, uint8_t value) -> bool
- Writes one byte to block/address.
Function documentation
bool prf:: hal:: wizchip:: W5500Device:: initialize_macraw(const RuntimeConfig& config)
Initializes W5500 for MACRAW operation on Socket 0.
This applies chip-level configuration (register defaults, SHAR, retry parameters, socket buffer layout) and opens Socket 0 in MACRAW mode.
bool prf:: hal:: wizchip:: W5500Device:: macraw_receive_frame(uint8_t* out_frame,
size_t out_capacity,
size_t* out_len,
uint32_t timeout_ms = 1u)
Receives one Ethernet frame from MACRAW Socket 0.
Reads W5500 MACRAW length prefix and frame payload, advances RX pointer and issues RECV command.
bool prf:: hal:: wizchip:: W5500Device:: macraw_send_frame(const uint8_t* frame,
size_t frame_len,
uint32_t timeout_ms = 20u)
Sends one Ethernet frame via MACRAW Socket 0.
Frame data must include destination/source MAC and EtherType/payload.