
Chrom-ART Accelerator™ (DMA2D) configuration in STM32CubeL4
AN4943
12/22
DocID029937 Rev 2
Dma2dHandle.Init.ColorMode = DMA2D_OUTPUT_RGB565; /* Output color mode
is RGB565: 16 bpp */
Dma2dHandle.Init.OutputOffset = 0x0; /* No offset in output */
Dma2dHandle.Init.RedBlueSwap = DMA2D_RB_REGULAR; /* No R&B swap for
the output image */
Dma2dHandle.Init.AlphaInverted = DMA2D_REGULAR_ALPHA; /* No alpha
inversion for the output image */
/* DMA2D Callbacks configuration */
Dma2dHandle.XferCpltCallback = TransferComplete;
Dma2dHandle.XferErrorCallback = TransferError;
/* Foreground configuration: Layer 1 */
Dma2dHandle.LayerCfg[1].AlphaMode = DMA2D_NO_MODIF_ALPHA;
Dma2dHandle.LayerCfg[1].InputAlpha = 0xFF; /* Fully opaque */
Dma2dHandle.LayerCfg[1].InputColorMode = DMA2D_INPUT_RGB565; /* Foreground
layer format is RGB565 : 16 bpp */
Dma2dHandle.LayerCfg[1].InputOffset = 0x0; /* No offset in input */
Dma2dHandle.LayerCfg[1].RedBlueSwap = DMA2D_RB_REGULAR; /* No R&B
swap for the input foreground image */
Dma2dHandle.LayerCfg[1].AlphaInverted = DMA2D_REGULAR_ALPHA; /* No alpha
inversion for the input foreground image */
Dma2dHandle.Instance = DMA2D;
/* DMA2D initialization */
hal_status =
HAL_DMA2D_Init
(&Dma2dHandle);
OnError_Handler(hal_status != HAL_OK);
hal_status
= HAL_DMA2D_ConfigLayer
(&Dma2dHandle, 1);
OnError_Handler(hal_status != HAL_OK);
}
A full refresh is of course done in the same way but initializing the LCD 1
st
pixel at (0, 0) and
the image size to the LCD size.
LCD_ImagePreparation
(
0, 0, ST7789H2_LCD_PIXEL_WIDTH,
ST7789H2_LCD_PIXEL_HEIGHT
);
And changing the number of pixels to be transferred in the DMA2D start command:
hal_status =
HAL_DMA2D_Start_IT
(&Dma2dHandle,
(uint32_t)&RGB565_240x240, /* Source buffer in format RGB565 and size
240x240 */
(uint32_t)&(LCD_ADDR->REG), /* LCD data address */
1,
ST7789H2_LCD_PIXEL_HEIGHT * ST7789H2_LCD_PIXEL_WIDTH
); /* number of
pixel to transfer */
OnError_Handler(hal_status != HAL_OK);