summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/stm32/spi.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/ports/stm32/spi.c b/ports/stm32/spi.c
index 19f2b65ed..248075579 100644
--- a/ports/stm32/spi.c
+++ b/ports/stm32/spi.c
@@ -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