本帖最后由 ssssssss 于 2023-8-18 16:22 编辑
下面F429的部分代码主要意思是啥呢?
LTDC_Layer_InitStruct.LTDC_HorizontalStart = HSYNC_W + HBP + 1;
LTDC_Layer_InitStruct.LTDC_HorizontalStop = (Width + LTDC_Layer_InitStruct.LTDC_HorizontalStart - 1);
LTDC_Layer_InitStruct.LTDC_VerticalStart = VSYNC_W + VBP + 1;
LTDC_Layer_InitStruct.LTDC_VerticalStop = (Height + LTDC_Layer_InitStruct.LTDC_VerticalStart - 1);
LTDC_Layer_InitStruct.LTDC_CFBLineLength = BytesPerLine + 3;
LTDC_Layer_InitStruct.LTDC_CFBPitch = BytesPerLine;
LTDC_Layer_InitStruct.LTDC_CFBLineNumber = ySize;
[C] 纯文本查看 复制代码 static void LCD_LL_LayerInit(U32 LayerIndex)
{
LTDC_LayerCfgTypeDef layer_cfg;
static uint32_t LUT[256];
uint32_t i;
if (LayerIndex < GUI_NUM_LAYERS)
{
/* 窗口显示区设置 */
layer_cfg.WindowX0 = 0;
layer_cfg.WindowX1 = g_LcdWidth;
layer_cfg.WindowY0 = 0;
layer_cfg.WindowY1 = g_LcdHeight;
/* 配置颜色格式 */
layer_cfg.PixelFormat = _GetPixelformat(LayerIndex);
/* 显存地址 */
layer_cfg.FBStartAdress = layer_prop[LayerIndex].address;
/* Alpha常数 (255 表示完全不透明) */
layer_cfg.Alpha = 255;
/* 无背景色 */
layer_cfg.Alpha0 = 0; /* 完全透明 */
layer_cfg.Backcolor.Blue = 0;
layer_cfg.Backcolor.Green = 0;
layer_cfg.Backcolor.Red = 0;
/* 配置图层混合因数 */
layer_cfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA;
layer_cfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA;
/* 配置行列大小 */
layer_cfg.ImageWidth = g_LcdWidth;
layer_cfg.ImageHeight = g_LcdHeight;
/* 配置图层1 */
HAL_LTDC_ConfigLayer(&hltdc, &layer_cfg, LayerIndex);
/* 使能LUT */
if (LCD_GetBitsPerPixelEx(LayerIndex) <= 8)
{
HAL_LTDC_EnableCLUT(&hltdc, LayerIndex);
}
else
{
/* AL88模式(16bpp) */
if (layer_prop[LayerIndex].pColorConvAPI == GUICC_88666I)
{
HAL_LTDC_EnableCLUT(&hltdc, LayerIndex);
for (i = 0; i < 256; i++)
{
LUT[i] = LCD_API_ColorConv_8666.pfIndex2Color(i);
}
HAL_LTDC_ConfigCLUT(&hltdc, LUT, 256, LayerIndex);
}
}
}
}
[C] 纯文本查看 复制代码 static void _LCD_InitController(int LayerIndex)
{
LTDC_Layer_InitTypeDef LTDC_Layer_InitStruct = {0};
int xSize, ySize, BytesPerLine, BitsPerPixel, i;
U32 Pixelformat, Color;
static int Done;
if (LayerIndex >= GUI_COUNTOF(_apLayer))
{
return;
}
[color=#ff0000] if (Done == 0)
{
Done = 1;
//
// Enable line interrupt
//
LTDC_ITConfig(LTDC_IER_LIE, ENABLE);
NVIC_SetPriority(LTDC_IRQn, 0);
NVIC_EnableIRQ(LTDC_IRQn);
#if emWin_Optimize
//
// Enable DMA2D transfer complete interrupt
//
DMA2D_ITConfig(DMA2D_CR_TCIE, ENABLE);
NVIC_SetPriority(DMA2D_IRQn, 0);
NVIC_EnableIRQ(DMA2D_IRQn);
//
// Clear transfer complete interrupt flag
//
DMA2D->IFCR = (U32)DMA2D_IFSR_CTCIF;
#endif
}[/color]
//
// Layer configuration
//
xSize = LCD_GetXSizeEx(LayerIndex);
ySize = LCD_GetYSizeEx(LayerIndex);
// HorizontalStart = (Offset_X + Hsync + HBP);
// HorizontalStop = (Offset_X + Hsync + HBP + Window_Width - 1);
// VarticalStart = (Offset_Y + Vsync + VBP);
// VerticalStop = (Offset_Y + Vsync + VBP + Window_Heigh - 1);
[color=#ff0000] LTDC_Layer_InitStruct.LTDC_HorizontalStart = HSYNC_W + HBP + 1;
LTDC_Layer_InitStruct.LTDC_HorizontalStop = (Width + LTDC_Layer_InitStruct.LTDC_HorizontalStart - 1);
LTDC_Layer_InitStruct.LTDC_VerticalStart = VSYNC_W + VBP + 1;
LTDC_Layer_InitStruct.LTDC_VerticalStop = (Height + LTDC_Layer_InitStruct.LTDC_VerticalStart - 1);[/color]
//
// Pixel Format configuration
//
Pixelformat = _GetPixelformat(LayerIndex);
LTDC_Layer_InitStruct.LTDC_PixelFormat = Pixelformat;
//
// Alpha constant (255 totally opaque)
//
LTDC_Layer_InitStruct.LTDC_ConstantAlpha = 255;
//
// Default Color configuration (configure A, R, G, B component values)
//
LTDC_Layer_InitStruct.LTDC_DefaultColorBlue = 0;
LTDC_Layer_InitStruct.LTDC_DefaultColorGreen = 0;
LTDC_Layer_InitStruct.LTDC_DefaultColorRed = 0;
LTDC_Layer_InitStruct.LTDC_DefaultColorAlpha = 0;
//
// Configure blending factors
//
BytesPerLine = _GetBytesPerLine(LayerIndex, xSize);
LTDC_Layer_InitStruct.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_PAxCA;
LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_PAxCA;
[color=#ff0000] LTDC_Layer_InitStruct.LTDC_CFBLineLength = BytesPerLine + 3;
LTDC_Layer_InitStruct.LTDC_CFBPitch = BytesPerLine;
LTDC_Layer_InitStruct.LTDC_CFBLineNumber = ySize;[/color]
//
// Input Address configuration
//
LTDC_Layer_InitStruct.LTDC_CFBStartAdress = _aAddr[LayerIndex];
LTDC_LayerInit(_apLayer[LayerIndex], <DC_Layer_InitStruct);
//
// Enable LUT on demand
//
BitsPerPixel = LCD_GetBitsPerPixelEx(LayerIndex);
if (BitsPerPixel <= 8)
{
//
// Enable usage of LUT for all modes with <= 8bpp
//
_LTDC_LayerEnableLUT(_apLayer[LayerIndex], ENABLE);
//
// Optional CLUT initialization for L8 mode (8bpp)
//
if (_apColorConvAPI[LayerIndex] == GUICC_1616I)
{
for (i = 0; i < 16; i++)
{
Color = LCD_API_ColorConv_1616I.pfIndex2Color(i);
_LTDC_SetLUTEntry(LayerIndex, Color, i);
}
}
//
// Optional CLUT initialization for AL44 mode (8bpp)
//
if (_apColorConvAPI[LayerIndex] == GUICC_8666)
{
for (i = 0; i < 16; i++)
{
Color = LCD_API_ColorConv_8666.pfIndex2Color(i);
_LTDC_SetLUTEntry(LayerIndex, Color, i);
}
}
}
else
{
//
// Optional CLUT initialization for AL88 mode (16bpp)
//
if (_apColorConvAPI[LayerIndex] == GUICC_88666I)
{
_LTDC_LayerEnableLUT(_apLayer[LayerIndex], ENABLE);
for (i = 0; i < 256; i++)
{
Color = LCD_API_ColorConv_8666.pfIndex2Color(i);
_LTDC_SetLUTEntry(LayerIndex, Color, i);
}
}
}
//
// Enable layer
//
LTDC_LayerCmd(_apLayer[LayerIndex], ENABLE);
//
// Reload configuration
//
LTDC_ReloadConfig(LTDC_SRCR_IMR);
}
|