summaryrefslogtreecommitdiff
path: root/libhw/w5500.c
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-03-02 13:38:44 -0700
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-03-02 13:43:51 -0700
commitfe6b92f8b700db5310164339e71110953a59e110 (patch)
tree652e3e23e35ab302ab3f868610b716ca3227b4ad /libhw/w5500.c
parent355d7a495b0ca1a622d600427a8c737f3207a803 (diff)
libhw: w5500: Re-add SPI validation
This reverts commit 063f263f84d517c6497e7ca37f503956bad7075a.
Diffstat (limited to 'libhw/w5500.c')
-rw-r--r--libhw/w5500.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/libhw/w5500.c b/libhw/w5500.c
index b4ad86b..fafc846 100644
--- a/libhw/w5500.c
+++ b/libhw/w5500.c
@@ -312,6 +312,15 @@ void _w5500_init(struct w5500 *chip,
};
}
+ /* Validate that SPI works correctly. */
+ for (uint16_t a = 0; a < 0x100; a++) {
+ w5500ll_write_sock_reg(chip->spidev, 0, mode, a);
+ uint8_t b = w5500ll_read_sock_reg(chip->spidev, 0, mode);
+ if (b != a)
+ errorf("SPI to W5500 does not appear to be functional: wrote:%d != read:%d", a, b);
+ }
+ w5500ll_write_sock_reg(chip->spidev, 0, mode, 0);
+
/* Initialize the hardware. */
gpioirq_set_and_enable_exclusive_handler(pin_intr, GPIO_IRQ_EDGE_FALL, w5500_intrhandler, chip);
gpio_set_dir(chip->pin_reset, GPIO_OUT);