Skip to content

Commit 7016900

Browse files
committed
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>
1 parent acb294f commit 7016900

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ports/stm32/spi.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,10 @@ int spi_init(const spi_t *self, bool enable_nss_pin) {
481481
if (pins[i] == NULL) {
482482
continue;
483483
}
484-
mp_hal_pin_config_alt(pins[i], mode, pull, AF_FN_SPI, (self - &spi_obj[0]) + 1);
484+
if (!mp_hal_pin_config_alt(pins[i], mode, pull, AF_FN_SPI, (self - &spi_obj[0]) + 1)) {
485+
// Pin does not have SPI alternate function.
486+
return -MP_EINVAL;
487+
}
485488
}
486489

487490
// init the SPI device

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy