Skip to content
Permalink
Browse files

drivers: spi: spi_ll_stm32: set NSS before mode

This commit solves an issue where the NSS must be set before the
mode on the stm32mp157c_dk2, else LL_SPI_SetMode won't affect the
mode registry.
stm32mp1x (and stm32h7) LL function SPI_Init seems to also define
first the NSS then the mode, unlike other STM32 boards where this
is not specified.
Changing the order shouldn't have bad repercussions on other boards,
ZephyrnSPI driver test has been passed successfully on disco_l475_iot1
board.

Signed-off-by: Yaël Boutreux <yael.boutreux@st.com>
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com>
  • Loading branch information...
yboutreux authored and MaureenHelm committed Jul 24, 2019
1 parent b7ee23b commit c935508c0591138ca058b7914a04070188bead46
Showing with 6 additions and 6 deletions.
  1. +6 −6 drivers/spi/spi_ll_stm32.c
@@ -307,12 +307,6 @@ static int spi_stm32_configure(struct device *dev,

LL_SPI_DisableCRC(spi);

if (config->operation & SPI_OP_MODE_SLAVE) {
LL_SPI_SetMode(spi, LL_SPI_MODE_SLAVE);
} else {
LL_SPI_SetMode(spi, LL_SPI_MODE_MASTER);
}

if (config->cs || !IS_ENABLED(CONFIG_SPI_STM32_USE_HW_SS)) {
LL_SPI_SetNSSMode(spi, LL_SPI_NSS_SOFT);
} else {
@@ -323,6 +317,12 @@ static int spi_stm32_configure(struct device *dev,
}
}

if (config->operation & SPI_OP_MODE_SLAVE) {
LL_SPI_SetMode(spi, LL_SPI_MODE_SLAVE);
} else {
LL_SPI_SetMode(spi, LL_SPI_MODE_MASTER);
}

if (SPI_WORD_SIZE_GET(config->operation) == 8) {
LL_SPI_SetDataWidth(spi, LL_SPI_DATAWIDTH_8BIT);
} else {

0 comments on commit c935508

Please sign in to comment.
You can’t perform that action at this time.