mirror of https://github.com/arendst/Tasmota.git
LVGL fix conflict between SPI DMA and SD card
This commit is contained in:
parent
a3389f74eb
commit
80ab5c3060
|
@ -34,7 +34,7 @@ typedef struct LVGL_PARAMS {
|
||||||
struct {
|
struct {
|
||||||
uint8_t use_dma : 1;
|
uint8_t use_dma : 1;
|
||||||
uint8_t swap_color : 1;
|
uint8_t swap_color : 1;
|
||||||
uint8_t resvd_0 : 1;
|
uint8_t async_dma : 1; // force DMA completion before returning, avoid conflict with other devices on same bus. If set you should make sure the display is the only device on the bus
|
||||||
uint8_t resvd_1 : 1;
|
uint8_t resvd_1 : 1;
|
||||||
uint8_t resvd_2 : 1;
|
uint8_t resvd_2 : 1;
|
||||||
uint8_t resvd_3 : 1;
|
uint8_t resvd_3 : 1;
|
||||||
|
|
|
@ -465,7 +465,7 @@ Renderer *uDisplay::Init(void) {
|
||||||
uspi->begin(spi_clk, spi_miso, spi_mosi, -1);
|
uspi->begin(spi_clk, spi_miso, spi_mosi, -1);
|
||||||
if (lvgl_param.use_dma) {
|
if (lvgl_param.use_dma) {
|
||||||
spi_host = VSPI_HOST;
|
spi_host = VSPI_HOST;
|
||||||
initDMA(spi_cs);
|
initDMA(lvgl_param.async_dma ? spi_cs : -1); // disable DMA CS if sync, we control it directly
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (spi_nr == 2) {
|
} else if (spi_nr == 2) {
|
||||||
|
@ -473,7 +473,7 @@ Renderer *uDisplay::Init(void) {
|
||||||
uspi->begin(spi_clk, spi_miso, spi_mosi, -1);
|
uspi->begin(spi_clk, spi_miso, spi_mosi, -1);
|
||||||
if (lvgl_param.use_dma) {
|
if (lvgl_param.use_dma) {
|
||||||
spi_host = HSPI_HOST;
|
spi_host = HSPI_HOST;
|
||||||
initDMA(spi_cs);
|
initDMA(lvgl_param.async_dma ? spi_cs : -1); // disable DMA CS if sync, we control it directly
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pinMode(spi_clk, OUTPUT);
|
pinMode(spi_clk, OUTPUT);
|
||||||
|
@ -1974,24 +1974,13 @@ void uDisplay::beginTransaction(SPISettings s) {
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
if (lvgl_param.use_dma) {
|
if (lvgl_param.use_dma) {
|
||||||
dmaWait();
|
dmaWait();
|
||||||
} else {
|
|
||||||
uspi->beginTransaction(s);
|
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
uspi->beginTransaction(s);
|
|
||||||
#endif
|
#endif
|
||||||
|
uspi->beginTransaction(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void uDisplay::endTransaction(void) {
|
void uDisplay::endTransaction(void) {
|
||||||
#ifdef ESP32
|
|
||||||
if (lvgl_param.use_dma) {
|
|
||||||
dmaBusy();
|
|
||||||
} else {
|
|
||||||
uspi->endTransaction();
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
uspi->endTransaction();
|
uspi->endTransaction();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2002,7 +1991,7 @@ void uDisplay::endTransaction(void) {
|
||||||
** Function name: initDMA
|
** Function name: initDMA
|
||||||
** Description: Initialise the DMA engine - returns true if init OK
|
** Description: Initialise the DMA engine - returns true if init OK
|
||||||
***************************************************************************************/
|
***************************************************************************************/
|
||||||
bool uDisplay::initDMA(bool ctrl_cs)
|
bool uDisplay::initDMA(int32_t ctrl_cs)
|
||||||
{
|
{
|
||||||
if (DMA_Enabled) return false;
|
if (DMA_Enabled) return false;
|
||||||
|
|
||||||
|
@ -2018,9 +2007,6 @@ bool uDisplay::initDMA(bool ctrl_cs)
|
||||||
.intr_flags = 0
|
.intr_flags = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
int8_t pin = -1;
|
|
||||||
if (ctrl_cs) pin = spi_cs;
|
|
||||||
|
|
||||||
spi_device_interface_config_t devcfg = {
|
spi_device_interface_config_t devcfg = {
|
||||||
.command_bits = 0,
|
.command_bits = 0,
|
||||||
.address_bits = 0,
|
.address_bits = 0,
|
||||||
|
@ -2031,7 +2017,7 @@ bool uDisplay::initDMA(bool ctrl_cs)
|
||||||
.cs_ena_posttrans = 0,
|
.cs_ena_posttrans = 0,
|
||||||
.clock_speed_hz = spi_speed*1000000,
|
.clock_speed_hz = spi_speed*1000000,
|
||||||
.input_delay_ns = 0,
|
.input_delay_ns = 0,
|
||||||
.spics_io_num = pin,
|
.spics_io_num = ctrl_cs,
|
||||||
.flags = SPI_DEVICE_NO_DUMMY, //0,
|
.flags = SPI_DEVICE_NO_DUMMY, //0,
|
||||||
.queue_size = 1,
|
.queue_size = 1,
|
||||||
.pre_cb = 0, //dc_callback, //Callback to handle D/C line
|
.pre_cb = 0, //dc_callback, //Callback to handle D/C line
|
||||||
|
@ -2119,6 +2105,9 @@ void uDisplay::pushPixelsDMA(uint16_t* image, uint32_t len) {
|
||||||
assert(ret == ESP_OK);
|
assert(ret == ESP_OK);
|
||||||
|
|
||||||
spiBusyCheck++;
|
spiBusyCheck++;
|
||||||
|
if (!lvgl_param.async_dma) {
|
||||||
|
dmaWait();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************************************
|
/***************************************************************************************
|
||||||
|
@ -2145,6 +2134,9 @@ void uDisplay::pushPixels3DMA(uint8_t* image, uint32_t len) {
|
||||||
assert(ret == ESP_OK);
|
assert(ret == ESP_OK);
|
||||||
|
|
||||||
spiBusyCheck++;
|
spiBusyCheck++;
|
||||||
|
if (!lvgl_param.async_dma) {
|
||||||
|
dmaWait();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -233,7 +233,7 @@ class uDisplay : public Renderer {
|
||||||
spi_device_handle_t dmaHAL;
|
spi_device_handle_t dmaHAL;
|
||||||
spi_host_device_t spi_host = VSPI_HOST;
|
spi_host_device_t spi_host = VSPI_HOST;
|
||||||
// spi_host_device_t spi_host = VSPI_HOST;
|
// spi_host_device_t spi_host = VSPI_HOST;
|
||||||
bool initDMA(bool ctrl_cs);
|
bool initDMA(int32_t ctrl_cs);
|
||||||
void deInitDMA(void);
|
void deInitDMA(void);
|
||||||
bool dmaBusy(void);
|
bool dmaBusy(void);
|
||||||
void dmaWait(void);
|
void dmaWait(void);
|
||||||
|
|
Loading…
Reference in New Issue