How to use LTDC?
You can refer to the configuration of the official routine. It should be noted that it is only an LCD controller and the cache address needs to be defined. It can be set in the flash, but it is not easy to operate. Generally, it is recommended to set it in the external SDRAM.
How to use DMA2D in LTDC? The 2D acceleration function of LTDC in 429 is relatively simple. There are only 4 modes of
DMA2D function:
DMA2D_M2M copy from flash to video memory
DMA2D_M2M_PFC copy from flash to video memory, and can perform color format conversion, replace/unchange/mix
DMA2D_M2M_BLEND copy from flash To the video memory, and first mix the foreground and the
background scene DMA2D_R2M copy the fixed color to the video memory
M2M use:
/*
将图片数据通过DMA2D搬运到显存中
函数参数
Show_X :显示图片位置的X坐标
Show_Y :显示图片位置的Y坐标
Picture_W:图片的宽
Picture_H:图片的高
PictureAdd:存放图片的地址
*/
void ShowPicture(int Show_X,int Show_Y,int Picture_W,int Picture_H,uint32_t PictureAdd)
{
DMA2D_InitTypeDef DMA2D_InitStruct;
DMA2D_FG_InitTypeDef DMA2D_FG_InitStruct;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2D, ENABLE);
DMA2D_DeInit();
DMA2D_InitStruct.DMA2D_Mode = DMA2D_M2M;
DMA2D_InitStruct.DMA2D_CMode = DMA2D_RGB565;
DMA2D_InitStruct.DMA2D_OutputMemoryAdd = (uint32_t)(LCD_FRAME_BUFFER+2*(LCD_PIXEL_WIDTH*Show_Y + Show_X)); //SDRAM地址空间
DMA2D_InitStruct.DMA2D_OutputOffset = Show_X;
DMA2D_InitStruct.DMA2D_NumberOfLine = Picture_H;
DMA2D_InitStruct.DMA2D_PixelPerLine = Picture_W;
DMA2D_Init(&DMA2D_InitStruct);
DMA2D_FG_StructInit(&DMA2D_FG_InitStruct);
DMA2D_FG_InitStruct.DMA2D_FGCM = DMA2D_RGB565;
DMA2D_FG_InitStruct.DMA2D_FGMA = PictureAdd; //falsh的图片地址
DMA2D_FGConfig(&DMA2D_FG_InitStruct);
/* Start Transfer */
DMA2D_StartTransfer();
/* Wait for CTC Flag activation */
while(DMA2D_GetFlagStatus(DMA2D_FLAG_TC) == RESET)
{
}
}
The function of this function is to display a picture of a specified size at a specified position on the LCD screen
ShowPicture(0,0,240,320,(uint32_t)&gImage_Hsq1); //函数调用方法 gImage_Hsq1为利用图片取模软件生成的.c文件数组