From 80584d7aac412fb739b661fc59666c7fa6baf90e Mon Sep 17 00:00:00 2001 From: Abe Kabakoff Date: Sat, 18 Jul 2026 17:50:08 +0200 Subject: [PATCH] fix: initialize SPI callback union member for SPI-mode builds (AUD-003) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The WIZCHIP global initializer at wizchip_conf.c:256-277 only initialized the IF.BUS union member (iodata_t (*)(uint32_t) signatures), even when _WIZCHIP_IO_MODE_ selected SPI mode. W5500 SPI access calls through IF.SPI._read_byte (uint8_t (*)(void)) and IF.SPI._write_byte (void (*)(uint8_t)) — incompatible signatures through the wrong union member, which can HardFault or corrupt memory on common ARM ABIs. Fix: when _WIZCHIP_IO_MODE_ has the SPI bit set, initialize IF.SPI with the existing wizchip_spi_readbyte/wizchip_spi_writebyte stubs (return 0 / no-op) and NULL burst callbacks. BUS mode keeps its existing initialization under #else. --- Ethernet/wizchip_conf.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Ethernet/wizchip_conf.c b/Ethernet/wizchip_conf.c index 9409b60..7eb7253 100644 --- a/Ethernet/wizchip_conf.c +++ b/Ethernet/wizchip_conf.c @@ -264,6 +264,16 @@ _WIZCHIP WIZCHIP = { wizchip_cs_select, wizchip_cs_deselect }, +#if (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_) + { + .SPI = { + ._read_byte = wizchip_spi_readbyte, + ._write_byte = wizchip_spi_writebyte, + ._read_burst = 0, + ._write_burst = 0 + } + } +#else { { //M20150601 : Rename the function @@ -274,6 +284,7 @@ _WIZCHIP WIZCHIP = { }, } +#endif };