Skip to content

Commit d65a74e

Browse files
FRASTMnashif
authored andcommitted
drivers: spi: stm32 spi drivers supports the frame format
the stm32 spi drivers now takes the DTS frame_format property from the include/ drivers/spi.h It will be possible to select the Motorola (default) or TI from the DTS entry of the device, when soc supports it, else a run time error is raised. Signed-off-by: Francois Ramu <[email protected]>
1 parent 0757678 commit d65a74e

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

drivers/spi/spi_ll_stm32.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,21 @@ static int spi_stm32_configure(const struct device *dev,
480480
return -ENOTSUP;
481481
}
482482

483+
/* configure the frame format Motorola (default) or TI */
484+
if ((config->operation & SPI_FRAME_FORMAT_TI) == SPI_FRAME_FORMAT_TI) {
485+
#ifdef LL_SPI_PROTOCOL_TI
486+
LL_SPI_SetStandard(spi, LL_SPI_PROTOCOL_TI);
487+
#else
488+
LOG_ERR("Frame Format TI not supported");
489+
/* on stm32F1 or some stm32L1 (cat1,2) without SPI_CR2_FRF */
490+
return -ENOTSUP;
491+
#endif
492+
#if defined(LL_SPI_PROTOCOL_MOTOROLA) && defined(SPI_CR2_FRF)
493+
} else {
494+
LL_SPI_SetStandard(spi, LL_SPI_PROTOCOL_MOTOROLA);
495+
#endif
496+
}
497+
483498
if (clock_control_get_rate(DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE),
484499
(clock_control_subsys_t) &cfg->pclken, &clock) < 0) {
485500
LOG_ERR("Failed call clock_control_get_rate");
@@ -561,11 +576,6 @@ static int spi_stm32_configure(const struct device *dev,
561576
ll_func_set_fifo_threshold_8bit(spi);
562577
#endif
563578

564-
#if !defined(CONFIG_SOC_SERIES_STM32F1X) \
565-
&& (!defined(CONFIG_SOC_SERIES_STM32L1X) || defined(SPI_CR2_FRF))
566-
LL_SPI_SetStandard(spi, LL_SPI_PROTOCOL_MOTOROLA);
567-
#endif
568-
569579
/* At this point, it's mandatory to set this on the context! */
570580
data->ctx.config = config;
571581

0 commit comments

Comments
 (0)