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
This commit is contained in:
leosun 2023-06-15 07:48:19 +08:00
parent 666fb94ca3
commit 7354e2ad03

View File

@ -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 both MOSI and MISO exist, loop search normally
if ((mosi != NULL) && (miso != NULL)) { if ((mosi != NULL) && (miso != NULL)) {
for (uint j = 0; j < mosi_count; j++) { 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)) { || (mcu_spi_sck_list[i].bank_idx != mcu_spi_sdo_list[j].bank_idx)) {
continue; continue;
} }