From 7354e2ad0355e73c494f8fe9f03b649ca8ef42b5 Mon Sep 17 00:00:00 2001 From: leosun Date: Thu, 15 Jun 2023 07:48:19 +0800 Subject: [PATCH] fix `invalid pin` error when create `busio.SPI` on specific SCK/MOSI/MISO pins, the `common_hal_busio_spi_construct` method always skip miso pins which will lead to a `invalid pin` exception when SPI initilized --- ports/mimxrt10xx/common-hal/busio/SPI.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/mimxrt10xx/common-hal/busio/SPI.c b/ports/mimxrt10xx/common-hal/busio/SPI.c index 641714bcca..1ab9394244 100644 --- a/ports/mimxrt10xx/common-hal/busio/SPI.c +++ b/ports/mimxrt10xx/common-hal/busio/SPI.c @@ -109,7 +109,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, // if both MOSI and MISO exist, loop search normally if ((mosi != NULL) && (miso != NULL)) { for (uint j = 0; j < mosi_count; j++) { - if ((mcu_spi_sdo_list[i].pin != mosi) + if ((mcu_spi_sdo_list[j].pin != mosi) || (mcu_spi_sck_list[i].bank_idx != mcu_spi_sdo_list[j].bank_idx)) { continue; }