How to use SPI_DT_SPEC_GET? #44490
-
How to use SPI_DT_SPEC_GET? I cant find examples. I added this overlay so a cs-gpio pin is defined:
I'm not sure why struct spi_dt_spec spi_spec =
{
.bus = DEVICE_DT_GET(DT_NODELABEL(spi1)),
.config =
{
.operation = SPI_WORD_SET(8) | SPI_MODE_GET(0),
.frequency = 1*1000*1000,
.cs = &(struct spi_cs_control)
{
.gpio_dev = DEVICE_DT_GET(DT_NODELABEL(gpioa)),
.delay = 1,
.gpio_pin = 4,
.gpio_dt_flags = GPIO_ACTIVE_LOW
}
}
}; This works well but I would like to replace that with this shortcut so it depends more on the overlay file: struct spi_dt_spec spi_spec1 = SPI_DT_SPEC_GET(DT_NODELABEL(spi1), SPI_WORD_SET(8) | SPI_MODE_GET(0), 1); but that results in: #define DT_N_S_soc_S_spi_40013000_ORD 63 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 12 replies
-
Cf:
To use this macro, you should add such device in your dts description. |
Beta Was this translation helpful? Give feedback.
SPI_DT_SPEC_GET
should actually be applied to a SPI device (sensor, ...) and not a SPI bus (spi1
in your case):Cf:
To use this macro, you should add such device in your dts description.