From 45f349d41588b732aa5118d8da890ce35a5e86ba Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Fri, 29 Nov 2024 14:37:32 -0700 Subject: w5500: Validate SPI *before* initializing the hardware --- libhw/w5500.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'libhw/w5500.c') diff --git a/libhw/w5500.c b/libhw/w5500.c index c039226..563fd8b 100644 --- a/libhw/w5500.c +++ b/libhw/w5500.c @@ -331,11 +331,6 @@ void _w5500_init(struct w5500 *chip, }; } - /* Initialize the hardware. */ - gpio_set_irq_enabled_with_callback(pin_intr, GPIO_IRQ_EDGE_FALL, true, w5500_intrhandler); - gpio_set_dir(chip->pin_reset, GPIO_OUT); - w5500_hard_reset(chip); - /* Validate that SPI works correctly. */ for (uint16_t a = 0; a < 0x100; a++) { w5500ll_write_sock_reg(chip->spidev, 0, mode, a); @@ -345,6 +340,11 @@ void _w5500_init(struct w5500 *chip, } w5500ll_write_sock_reg(chip->spidev, 0, mode, 0); + /* Initialize the hardware. */ + gpio_set_irq_enabled_with_callback(pin_intr, GPIO_IRQ_EDGE_FALL, true, w5500_intrhandler); + gpio_set_dir(chip->pin_reset, GPIO_OUT); + w5500_hard_reset(chip); + /* Finally, wire in the interrupt handler. */ bool saved = cr_save_and_disable_interrupts(); for (size_t i = 0; i < ARRAY_LEN(w5500_chips); i++) { -- cgit v1.2.3-2-g168b