STM32CUBEMX中的LTDC配置
例如只选用layer1层,窗口的像素位置设置说明如下:
我使用的是480×272像素的LCD屏,使用整个像素平面作为层窗口,按照图1进行CUBE配置并生成代码,如下所示,一些不必要的代码省略:
static void MX_LTDC_Init(void)
{
/* USER CODE BEGIN LTDC_Init 0 */
/* USER CODE END LTDC_Init 0 */
LTDC_LayerCfgTypeDef pLayerCfg = {
0};
/* USER CODE BEGIN LTDC_Init 1 */
/* USER CODE END LTDC_Init 1 */
hltdc.Instance = LTDC;
hltdc.Init.HSPolarity = LTDC_HSPOLARITY_AL;
hltdc.Init.VSPolarity = LTDC_VSPOLARITY_AL;
hltdc.Init.DEPolarity = LTDC_DEPOLARITY_AL;
hltdc.Init.PCPolarity = LTDC_PCPOLARITY_IPC;
hltdc.Init.HorizontalSync = 0;
hltdc.Init.VerticalSync = 0;
hltdc.Init.AccumulatedHBP = 40;
hltdc.Init.AccumulatedVBP = 8;
hltdc.Init.AccumulatedActiveW = 520;
hltdc.Init.AccumulatedActiveH = 280;
hltdc.Init.TotalWidth = 525;
hltdc.Init.TotalHeigh = 288;
hltdc.Init.Backcolor.Blue = 255;
hltdc.Init.Backcolor.Green = 255;
hltdc.Init.Backcolor.Red = 255;
if (HAL_LTDC_Init(&hltdc) !=