fix: initialize SPI callback union member for SPI-mode builds (AUD-003) - #182
Open
occamsshavingkit wants to merge 1 commit into
Open
fix: initialize SPI callback union member for SPI-mode builds (AUD-003)#182occamsshavingkit wants to merge 1 commit into
occamsshavingkit wants to merge 1 commit into
Conversation
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.
niansa
added a commit
to niansa/ioLibrary_Driver
that referenced
this pull request
Jul 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes incompatible callback initialization in the
WIZCHIPglobal for SPI-mode builds.Problem
The
WIZCHIPglobal initializer atEthernet/wizchip_conf.c:256-277only initialized theIF.BUSunion member (iodata_t (*)(uint32_t)signatures), even when_WIZCHIP_IO_MODE_selected SPI mode. W5500 register access calls throughIF.SPI._read_byte(uint8_t (*)(void)) andIF.SPI._write_byte(void (*)(uint8_t)) — incompatible function signatures through the wrong union member. Any W5500 access before SPI callback registration could HardFault or corrupt memory on common ARM ABIs.Fix
Add
#if (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_)conditional around the union initializer:IF.SPIwithwizchip_spi_readbyte(returns 0),wizchip_spi_writebyte(no-op), and NULL burst callbacksIF.BUS._read_data/_write_datainitialization under#elseVerification
_WIZCHIP_valueswizchip_spi_readbyte/wizchip_spi_writebytestubs atwizchip_conf.c:172-182are reused