Any advice to use a single SPI port with display and touch?

Id like to modify my demo project STM32F103 Demo to work with a single SPI port.
I did a first test but when I press a tab is refreshed only the tab title, tabs don’t scroll.

Could send a video to see the issue?

IMO the most flexible approach would be to use a flag (like a mutex) in disp_flush DMA to lock SPI.
For the Touchpad create a Timer and in an interrupt read the TP when the SPI is not locked. In touchpad_read just use the read touch information.

I applied your trick. result is in this video. SPI is slowed down to 1Mhz so refresh is very slow.

my code:

bool XPT2046_read(lv_indev_drv_t * drv, lv_indev_data_t*data)
uint16_t x = 0;
uint16_t y = 0;
uint8_t irq = LV_DRV_INDEV_IRQ_READ;

if (irq == 0 && SPI1_busy == 0 ) {
    XPT2046_GetTouch_XY(&x, &y, 1);
    xpt2046_corr(&x, &y);
    // xpt2046_avg(&x, &y);

    data->point.x = x;
    data->point.y = y;
    data->state = LV_INDEV_STATE_PR;
    data->state = LV_INDEV_STATE_REL;
return false;


void ILI9341_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map)
if (SPI1_busy ==0){
ILI9341_setAddressWindow((uint16_t)area->x1, (uint16_t)area->y1, (uint16_t)area->x2, (uint16_t)area->y2);
uint32_t size = (area->x2 - area->x1 + 1) * (area->y2 - area->y1 + 1);
Send_DMA_Data16((void*)color_map, size);
SPI1_busy =0;

Hi @ScarsFun what spi dma driver so you use for the Send_DMA_Data16?

I wrote it with STM32 Low Layer drivers, but before with SPL.
Check this thread:

I meant a little bit different. ILI9341_flush needs to be run in all cases. E.g. you need to wait for SPI1_busy to be cleared.

void ILI9341_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map)