Drawing area error when using spi dma transmit and keypad?

Is there any difference between the global defined disp_drv and the disp_drv passed from disp_flush?

when I copy the disp_drv passed from disp_flush to the global one , at least , the first screen is shown.
(but stucked again when the Tab window switch … .)

when I copy the disp_drv passed from disp_flush to the global one

You shouldn’t need to be manually copying disp_drv structures around like that. That is very likely to cause an issue at some point.

What I would instead suggest is that you save the pointer returned by lv_disp_drv_register to a global variable (let’s call it disp_p).

Then you can use that pointer inside the completion callback (no need for &):

void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi)

:smiley::smiley::smiley: Cool!
I think the problem is solved.

I have tested many cases, all of them are working properly with dma.
So the solutionn is :

  1. static lv_disp_drv_t * disp_p;
static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
    LCD_Send_Data_DMA(area->x1, area->y1, area->x2, area->y2, (uint8_t *)color_p);
    disp_p = disp_drv;
void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi)

I have pushed the code to github. under branch of baremental.

Thank for all of you !! @kisvegabor @embeddedt

1 Like

That solution should work fine. Glad you have it working.

Glad to hear that you made it work! :+1:

I’m looking at your code @weefnn in pandora/main.c at baremental · weefnn/pandora · GitHub

…and I don’t understand your choice of SPI configuration such as SPI_MODE_SLAVE. Isn’t your MCU the master while the OLED IC is the SPI slave?

I don’t understand SPI_POLARITY_HIGH and SPI_PHASE_2EDGE either, which differ from my STM32F405 implementation with SSD1306 (which does not work yet.)

You set some CRC variables then like SPI_CRC_LENGTH_DATASIZE and CRCPolynomial = 7 although CRC is disabled SPI_CRCCALCULATION_DISABLE.

Where did you get the information that made you decide these things?

Are you sure this is the version of your code that is working and the OLED really turns on?