Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion drivers/spi/spi_ll_stm32.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,11 @@ static int spi_stm32_configure(const struct device *dev,

#if !defined(CONFIG_SOC_SERIES_STM32F1X) \
&& (!defined(CONFIG_SOC_SERIES_STM32L1X) || defined(SPI_CR2_FRF))
LL_SPI_SetStandard(spi, LL_SPI_PROTOCOL_MOTOROLA);
if (cfg->ti_mode) {
LL_SPI_SetStandard(spi, LL_SPI_PROTOCOL_TI);
} else {
LL_SPI_SetStandard(spi, LL_SPI_PROTOCOL_MOTOROLA);
}
#endif

/* At this point, it's mandatory to set this on the context! */
Expand Down Expand Up @@ -922,6 +926,14 @@ static void spi_stm32_irq_config_func_##id(const struct device *dev) \
#define SPI_DMA_STATUS_SEM(id)
#endif

#if !defined(CONFIG_SOC_SERIES_STM32F1X) \
&& (!defined(CONFIG_SOC_SERIES_STM32L1X) || defined(SPI_CR2_FRF))
#define STM32_SPI_TI_MODE_CONFIG(id) \
.ti_mode = DT_INST_PROP(id, frame_format),
#else
#define STM32_SPI_TI_MODE_CONFIG(id)
#endif

#if DT_HAS_COMPAT_STATUS_OKAY(st_stm32_spi_subghz)
#define STM32_SPI_USE_SUBGHZSPI_NSS_CONFIG(id) \
.use_subghzspi_nss = DT_INST_PROP_OR( \
Expand All @@ -946,6 +958,7 @@ static const struct spi_stm32_config spi_stm32_cfg_##id = { \
.pinctrl_list_size = ARRAY_SIZE(spi_pins_##id), \
STM32_SPI_IRQ_HANDLER_FUNC(id) \
STM32_SPI_USE_SUBGHZSPI_NSS_CONFIG(id) \
STM32_SPI_TI_MODE_CONFIG(id) \
}; \
\
static struct spi_stm32_data spi_stm32_dev_data_##id = { \
Expand Down
10 changes: 10 additions & 0 deletions drivers/spi/spi_ll_stm32.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ struct spi_stm32_config {
#ifdef CONFIG_SPI_STM32_INTERRUPT
irq_config_func_t irq_config;
#endif

#if !defined(CONFIG_SOC_SERIES_STM32F1X) \
&& (!defined(CONFIG_SOC_SERIES_STM32L1X) || defined(SPI_CR2_FRF))
/*
* if supported by the instance, this bit will configure the frame-format
* of the SPI to be compliant with the TI protocol.
*/
bool ti_mode;
#endif

#if DT_HAS_COMPAT_STATUS_OKAY(st_stm32_spi_subghz)
bool use_subghzspi_nss;
#endif
Expand Down
10 changes: 10 additions & 0 deletions dts/bindings/spi/st,stm32-spi-common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ properties:
interrupts:
required: true

frame-format:
type: boolean
required: false
description: |
Use Frame Format to support TI or motorola SPI mode when the SPI
interface is compatible with the TI protocol. The FRF bit of the
SPIx_CR2 configures the SPI to be compliant with this protocol.
false: SPI Motorola mode (default)
true: SPI TI mode

pinctrl-0:
Copy link
Contributor

@avisconti avisconti Sep 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default is "false" for booleans, right?

type: phandles
required: false
Expand Down