Skip to content

Commit d563313

Browse files
FRASTMcfriedt
authored andcommitted
drivers: spi: stm32 can support TI mode for the SPI frame format
Depending of the soc and SPI peripheral, the Frame-Format of the SPI can be configured to support TI or Motorola protocol. This is configured through a new DTS property. Signed-off-by: Francois Ramu <[email protected]>
1 parent 3949963 commit d563313

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

drivers/spi/spi_ll_stm32.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,11 @@ static int spi_stm32_configure(const struct device *dev,
559559

560560
#if !defined(CONFIG_SOC_SERIES_STM32F1X) \
561561
&& (!defined(CONFIG_SOC_SERIES_STM32L1X) || defined(SPI_CR2_FRF))
562-
LL_SPI_SetStandard(spi, LL_SPI_PROTOCOL_MOTOROLA);
562+
if (cfg->ti_mode) {
563+
LL_SPI_SetStandard(spi, LL_SPI_PROTOCOL_TI);
564+
} else {
565+
LL_SPI_SetStandard(spi, LL_SPI_PROTOCOL_MOTOROLA);
566+
}
563567
#endif
564568

565569
/* At this point, it's mandatory to set this on the context! */
@@ -924,6 +928,14 @@ static void spi_stm32_irq_config_func_##id(const struct device *dev) \
924928
#define SPI_DMA_STATUS_SEM(id)
925929
#endif
926930

931+
#if !defined(CONFIG_SOC_SERIES_STM32F1X) \
932+
&& (!defined(CONFIG_SOC_SERIES_STM32L1X) || defined(SPI_CR2_FRF))
933+
#define STM32_SPI_TI_MODE_CONFIG(id) \
934+
.ti_mode = DT_INST_PROP(id, frame_format),
935+
#else
936+
#define STM32_SPI_TI_MODE_CONFIG(id)
937+
#endif
938+
927939
#if DT_HAS_COMPAT_STATUS_OKAY(st_stm32_spi_subghz)
928940
#define STM32_SPI_USE_SUBGHZSPI_NSS_CONFIG(id) \
929941
.use_subghzspi_nss = DT_INST_PROP_OR( \
@@ -948,6 +960,7 @@ static const struct spi_stm32_config spi_stm32_cfg_##id = { \
948960
.pinctrl_list_size = ARRAY_SIZE(spi_pins_##id), \
949961
STM32_SPI_IRQ_HANDLER_FUNC(id) \
950962
STM32_SPI_USE_SUBGHZSPI_NSS_CONFIG(id) \
963+
STM32_SPI_TI_MODE_CONFIG(id) \
951964
}; \
952965
\
953966
static struct spi_stm32_data spi_stm32_dev_data_##id = { \

drivers/spi/spi_ll_stm32.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ struct spi_stm32_config {
1919
#ifdef CONFIG_SPI_STM32_INTERRUPT
2020
irq_config_func_t irq_config;
2121
#endif
22+
23+
#if !defined(CONFIG_SOC_SERIES_STM32F1X) \
24+
&& (!defined(CONFIG_SOC_SERIES_STM32L1X) || defined(SPI_CR2_FRF))
25+
/*
26+
* if supported by the instance, this bit will configure the frame-format
27+
* of the SPI to be compliant with the TI protocol.
28+
*/
29+
bool ti_mode;
30+
#endif
31+
2232
#if DT_HAS_COMPAT_STATUS_OKAY(st_stm32_spi_subghz)
2333
bool use_subghzspi_nss;
2434
#endif

0 commit comments

Comments
 (0)