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
20 changes: 15 additions & 5 deletions drivers/spi/spi_ll_stm32.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,21 @@ static int spi_stm32_configure(const struct device *dev,
return -ENOTSUP;
}

/* configure the frame format Motorola (default) or TI */
if ((config->operation & SPI_FRAME_FORMAT_TI) == SPI_FRAME_FORMAT_TI) {
#ifdef LL_SPI_PROTOCOL_TI
LL_SPI_SetStandard(spi, LL_SPI_PROTOCOL_TI);
#else
LOG_ERR("Frame Format TI not supported");
/* on stm32F1 or some stm32L1 (cat1,2) without SPI_CR2_FRF */
return -ENOTSUP;
#endif
#if defined(LL_SPI_PROTOCOL_MOTOROLA) && defined(SPI_CR2_FRF)
} else {
LL_SPI_SetStandard(spi, LL_SPI_PROTOCOL_MOTOROLA);
#endif
}

if (clock_control_get_rate(DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE),
(clock_control_subsys_t) &cfg->pclken, &clock) < 0) {
LOG_ERR("Failed call clock_control_get_rate");
Expand Down Expand Up @@ -561,11 +576,6 @@ static int spi_stm32_configure(const struct device *dev,
ll_func_set_fifo_threshold_8bit(spi);
#endif

#if !defined(CONFIG_SOC_SERIES_STM32F1X) \
&& (!defined(CONFIG_SOC_SERIES_STM32L1X) || defined(SPI_CR2_FRF))
LL_SPI_SetStandard(spi, LL_SPI_PROTOCOL_MOTOROLA);
#endif

/* At this point, it's mandatory to set this on the context! */
data->ctx.config = config;

Expand Down
1 change: 1 addition & 0 deletions samples/drivers/led_ws2812/boards/nucleo_f070rb.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
/* SPI */
reg = <0>; /* ignored, but necessary for SPI bindings */
spi-max-frequency = <B1414_SPI_FREQ>;
frame-format = <32768>; /* SPI_FRAME_FORMAT_TI */

/* B1414 */
chain-length = <18>; /* arbitrary; change at will */
Expand Down
33 changes: 33 additions & 0 deletions samples/drivers/led_ws2812/boards/nucleo_g071rb.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2021, STMicroelectronics
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <dt-bindings/led/led.h>

&arduino_spi {
led_strip: ws2812@0 {
compatible = "worldsemi,ws2812-spi";
label = "WS2812";

/* SPI */
reg = <0>; /* ignored, but necessary for SPI bindings */
spi-max-frequency = <4000000>;
frame-format = <32768>; /* SPI_FRAME_FORMAT_TI */

/* WS2812 */
chain-length = <16>; /* arbitrary; change at will */
spi-one-frame = <0x70>;
spi-zero-frame = <0x40>;
color-mapping = <LED_COLOR_ID_GREEN
LED_COLOR_ID_RED
LED_COLOR_ID_BLUE>;
};
};

/ {
aliases {
led-strip = &led_strip;
};
};
1 change: 1 addition & 0 deletions samples/drivers/led_ws2812/boards/nucleo_l476rg.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
/* SPI */
reg = <0>; /* ignored, but necessary for SPI bindings */
spi-max-frequency = <4000000>;
frame-format = <32768>; /* SPI_FRAME_FORMAT_TI */

/* WS2812 */
chain-length = <16>; /* arbitrary; change at will */
Expand Down