diff options
-rw-r--r-- | libhw/w5500.c | 9 |
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); |