[spi] Fix IndexError on invalid RP2040 CLK pin (#15562)

This commit is contained in:
Jonathan Swoboda
2026-04-08 09:42:47 -10:00
committed by GitHub
parent 5b840c1662
commit 4a764ae1e3
+9 -5
View File
@@ -246,11 +246,15 @@ def validate_hw_pins(spi, index=-1):
return clk_pin_no >= 0
if target_platform == PLATFORM_RP2040:
pin_set = (
list(filter(lambda s: clk_pin_no in s[CONF_CLK_PIN], RP_SPI_PINSETS))[0]
if index == -1
else RP_SPI_PINSETS[index]
)
if index == -1:
matches = list(
filter(lambda s: clk_pin_no in s[CONF_CLK_PIN], RP_SPI_PINSETS)
)
if not matches:
return False
pin_set = matches[0]
else:
pin_set = RP_SPI_PINSETS[index]
if pin_set is None:
return False
if sdo_pin_no not in pin_set[CONF_MOSI_PIN]: