Closed tttonyyy closed 1 year ago
The project has been dormant for years. You should probably be working with the mainstream Micropython releases.
Thinking about it (it was late, I was tired) it might be working correctly anyway; sharing SPI requires the devices to use the same clock and miso/mosi pins. I don't think the HSPI pins the display uses are externally exposed.
The the TFT uses HSPI, but if I attempt to use VSPI while the TFT is initialised, I get the following error:
>>> vspi = SPI(spihost=SPI.VSPI, sck=25, mosi=33, miso=27, cs=26)
E (36855689) spi_master: spi_bus_initialize(95): dma channel already in use
E (36855689) [SPI_UTILS]: spi bus initialization failed with rc=0x103
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: invalid state
This device has no PSRAM, so VSPI should be available. I do not get the same errror if the TFT is not initilised.
The TFT driver and hw spi appear to use the same DMA channel even if different SPI interfaces are used.
I modified components/micropython/esp32/machine_hw_spi.c
to change the channel from 1 to 0 (no DMA - can't use dma channel 2 because that's used for VFS). My SPI peripheral is low-bandwidth so this is not a problem:
self->spi.dma_channel = 0;
Now I can use the TFT on HSPI and my thermocouple on VSPI.
Really love the project and have it up and running on a TTGO board with display.
The issue I've got is that I can't use the display and an externally connected SPI thermocouple at the same time.
Whichever is initialised first seems to have exclusive use of HSPI.
In the example above, any attempt to access the tft results in clocking on pin 25.
If I init the TFT first then SPI, the display works fine, but a hspi read does not produce any clock signal on pin 25. (The chip select does assert, though).
I can deinit one and init the other and use them one at a time, but really the chip select should do that for me.