Closed koattila closed 9 months ago
There's nothing in RadioLib that could "block other SPI devices" - all SPI accesses are wrapped in begin/endTransaction, as they should be.
Instead I would guess that the TFT library is attempting to init SPI with SPI::begin
. And because you are using the default SPI bus, RadioLib will attempt to initialize it too. I don't know what happens when SPI::begin
gets called twice on ESP32.
You can use a non-default SPI setup to let RadioLib know it should not automatically initalize the bus, see this wiki page: https://github.com/jgromes/RadioLib/wiki/Basics
Also, looking at its source, the TFT_Touch library seems to be doing very strange things with the SPI bus, such as directly changing the pin states as opposed to using the SPI peripheral. So I'm not sure why do you believe this is a problem in RadioLib.
Also also, out of experience, some SPI devices just plain ignore the state of the CS pin, so sometimes there is no other way but to use a different SPI bus. Keep in mind that even if everything works, it's not a good idea to put the communication module on the same bus as the control input - while the radio is writing/reading a packet, you will not get any traffic to/from the display and vice versa.
I'm kind of short of pins, so it would be hard to use separate buses. Is it possible to daisy chain these devices, or strip the CS pins to low, so the slaves on the separate buses are always enabled ?
I'm kind of short of pins, so it would be hard to use separate buses
You don't have to use a different SPI bus, you just have to explicitly specify it (even if it the same), so that RadioLib does not attempt to initialize it. You can do the following even if HSPI
happens to be the default SPI bus.
SPIClass spi(HSPI);
SPISettings spiSettings(2000000, MSBFIRST, SPI_MODE0);
CC1101 radio = new Module(cs, irq, RADIOLIB_NC, RADIOLIB_NC, spi, spiSettings);
or strip the CS pins to low, so the slaves on the separate buses are always enabled
Don't understand what you mean by that, sorry.
Closing as stale - feel free to reopen later if more information becomes available (though I remain convinced this is not an issue in RadioLib).
I don't really have anything helpful to add other than that I have a similar issue. I am using the Adafruit ILI9341 display library to control a display via SPI. The display works great unit RadioLib starts up, then goes unresponsive. I have tried calling the endWrite() function from the Adafruit library after accessing the display which should call SPI.endTransaction() but that doesn't seem to help either. I don't really have time to investigate further, as jgromes said, it could even be a hardware bug.
Controller: ESP32 Radio module: CC1101 Lib version: 5.3.0
I was using radiolib for controlling CC1101 modul (e07 400m10s), and it is working without a problem.
What I tried to do next is, to get SPI inputs from XPT2046 chip (gives touch outputs from touch screen), when I call "radio.begin();", the touch controller stops receiving inputs from SPI bus. The Radiolib is still working, so only the TFT_Touch.h actions are blocked. Can you please advice how can I use the library with other SPI devices ?
Both devices have differenct CSN pins.
Thank you in advance!