stm32/spi: Fail spi_init if pins can't be configured.

Follows the UART and I2C drivers.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2025-07-01 15:03:04 +10:00
parent acb294f61a
commit 7016900fbe

View File

@@ -481,7 +481,10 @@ int spi_init(const spi_t *self, bool enable_nss_pin) {
if (pins[i] == NULL) {
continue;
}
mp_hal_pin_config_alt(pins[i], mode, pull, AF_FN_SPI, (self - &spi_obj[0]) + 1);
if (!mp_hal_pin_config_alt(pins[i], mode, pull, AF_FN_SPI, (self - &spi_obj[0]) + 1)) {
// Pin does not have SPI alternate function.
return -MP_EINVAL;
}
}
// init the SPI device