From fe6b92f8b700db5310164339e71110953a59e110 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Sun, 2 Mar 2025 13:38:44 -0700 Subject: libhw: w5500: Re-add SPI validation This reverts commit 063f263f84d517c6497e7ca37f503956bad7075a. --- libhw/w5500.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'libhw/w5500.c') 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); -- cgit v1.2.3-2-g168b