LTDC DSI GFXMMU Doublebuffer - STM32U5A9J-DK
Hi, 2 questions:
- how to develop doubleframebuffer
- is clear framebuffer time 10ms top performance (-Ofast 160MHz)?
Details:
I'm experimenting with STM32U5A9J-DK round display board. After many trials and errors, comparing U5 examples with much richer ones for F4 pack I got working DSI LCD with singlebuffer.
I created GFXMMU Excel as asked in Cube creator. Attached virtual GFXMMU buffer to LTDC. Got line interrupt on front vertical porch. Finally evaluated some timing.

Now I want to use double framebuffer, and mu question: what is best approach to do this? I used to implement similar solution with SPI, DMA and half complete callback for STx driver. But I'm not sure how shoud it look like in this case.
I see that LTDC has 2 layers. Should I pass 2 GFXMMU buffers and swap layers somehow? Or use 1 layer and replace buffers during blanking period?

Question 2: Despite that I have some bad feeling about clearing screen. How should I draw to framebuffer? With memset i takes 36ms :(
void gfx_prepare() {
int32_t ltdc_clear_sreen_start_us = microtimer_get_us();
/* Clear screen */
gfx_fillscreen(0xFFFF0000); // RED
gfx_draw_fillrect(LCD_WIDTH/2 - 20, LCD_HEIGHT-40, 40, 40, 0xff0000ff);
ltdc_clear_sreen_duriation_us = microtimer_get_us() - ltdc_clear_sreen_start_us;
}
void gfx_draw_fillrect(uint32_t x_pos, uint32_t y_pos, uint32_t width, uint32_t height, uint32_t color) {
uint32_t px_address = 0;
uint32_t i;
uint32_t j;
/* Get the rectangle start address */
uint32_t startaddress = (hltdc.LayerCfg[0].FBStartAdress + (4 * (y_pos * PIXEL_PERLINE + x_pos)));
/* Fill the rectangle */
for (i = 0; i < height; i++) {
px_address = startaddress + (3072 * i); //768 * 4
for (j = 0; j < width; j++) {
*(__IO uint32_t *)(px_address) = color;
px_address += 4;
}
}
}
void gfx_fillscreen(uint32_t color) {
gfx_draw_fillrect(0, 0, LCD_WIDTH, LCD_HEIGHT, color);
}
With optimization -Ofast it is faster and takes 10ms.

Is it top performace? Is using DMA2D and copy-paste some batches will increase speed?
