mirror of
https://github.com/esphome/esphome.git
synced 2026-09-23 13:08:41 +00:00
[spi] Fix IndexError on invalid RP2040 CLK pin (#15562)
This commit is contained in:
@@ -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]:
|
||||
|
||||
Reference in New Issue
Block a user