I have a Lilygo T-Display-S3 AMOLED and want to use the Quad-SPI to control the AMOLED display and another SPI to do a distance measurement with a Decawave DW1000 module.
I have the code for the display with LVGL working without the DW1000.
The DW1000 also works when I don't use the display.
As soon as I try to run both the SPI connection to the DW1000 breaks down.
I assume that there are some resource conflicts but I can't find a good source of information what SPI module is connected to which pins. And the SPIs are also named different in several libaries. I found defines of "FSPI" and "HSPI" but also "SPI1_HOST" and "SPI2_HOST".
The PINs I use are:
+------------+-----------+-------------+------------+
| Signalname | Pin Flash | Pin Display | Pin DW1000 |
+------------+-----------+-------------+------------+
| CS | SPICS1 | GPIO6 | GPIO10 |
| CLK | SHICLK | SPILCK_P | GPIO12 |
| MOSI/Data0 | SPIQ | GPIO18 | GPIO11 |
| MISO/Data1 | SPID | GPIO7 | GPIO13 |
| Data2 | SPIWP | SPICLK_N | - |
| Data3 | SHIPD | GPIO5 | - |
+------------+-----------+-------------+------------+
The library for the DW1000 I use is:
and I pass a SPIClass(FSPI)
to its init function.
For the Display I used the official Lilygo LVGL example from here:
but I changed the code to use a SPIClass(HSPI)
object instead of the normal SPI
to do its stuff like .begin()
. I'm not sure where this normal SPI object is even defined and what module it defaults to. In the display driver (rm67162.cpp) are two lines that don't use the SPIClass object but expect a spi_host_device_t type
:
ret = spi_bus_initialize((spi_host_device_t)HSPI, &buscfg, SPI_DMA_CH_AUTO);
ESP_ERROR_CHECK(ret);
ret = spi_bus_add_device((spi_host_device_t)HSPI, &devcfg, &spi);
ESP_ERROR_CHECK(ret);
I just casted the HSPI to spi_host_device_t type.
As I said both snippets run fine independent of each other but the DW1000 fails as soon as spi_bus_initialize()
or spi_bus_add_device()
are called. If I delay the initialization of the DW1000 the display shows garbage and the module still does not work.
Can someone help me untangle this SPI chaos?