LTDC的层初始化代码- void f_LTDC_LayerInit(uint8_t LayerIndex)
 
 - {
 
 -     LTDC_Layer_InitTypeDef LTDC_Layer_Init;
 
 - //    LTDC_CLUT_InitTypeDef  LTDC_CLUT_InitStruct;
 
 -      
 
 -     LTDC_Layer_Init.LTDC_HorizontalStart = TFT_HBP ;
 
 -     LTDC_Layer_Init.LTDC_HorizontalStop = TFT_PHYW + TFT_HBP -1;
 
 -     LTDC_Layer_Init.LTDC_VerticalStart = TFT_VBP ;
 
 -     LTDC_Layer_Init.LTDC_VerticalStop = TFT_PHYH + TFT_VBP -1;
 
 -     LTDC_Layer_Init.LTDC_PixelFormat = LTDC_Pixelformat_RGB565;
 
 -     LTDC_Layer_Init.LTDC_ConstantAlpha = 255; 
 
 -     LTDC_Layer_Init.LTDC_DefaultColorBlue = 0;        
 
 -     LTDC_Layer_Init.LTDC_DefaultColorGreen = 0;       
 
 -     LTDC_Layer_Init.LTDC_DefaultColorRed = 0;         
 
 -     LTDC_Layer_Init.LTDC_DefaultColorAlpha = 0;
 
 -     LTDC_Layer_Init.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_CA;    
 
 -     LTDC_Layer_Init.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_CA;
 
 -     
 
 -     /* the length of one line of pixels in bytes + 3 then : 
 
 -     5.Line Lenth = Active high width x number of bytes per pixel + 3  
 
 -     6.Active high width         = 240  
 
 -     7.number of bytes per pixel = 2    (pixel_format : RGB565)  
 
 -     8.*/ 
 
 -     LTDC_Layer_Init.LTDC_CFBLineLength = (TFT_PHYW*2) +3;//old=3 //1224
 
 -     /*  the pitch is the increment from the start of one line of pixels to the  
 
 -     12.start of the next line in bytes, then : 
 
 -     13.Pitch = Active high width x number of bytes per pixel      
 
 -     14.*/ 
 
 -     LTDC_Layer_Init.LTDC_CFBPitch = TFT_PHYW*2;
 
 -     /* configure the number of lines */
 
 -     LTDC_Layer_Init.LTDC_CFBLineNumber = TFT_PHYH; 
 
 -     /* Input Address configuration */
 
 -     LTDC_Layer_Init.LTDC_CFBStartAdress = SDRAM_BASE;
 
 -   
 
 -     LTDC_LayerInit((LayerIndex == 0 ? LTDC_Layer1 : LTDC_Layer2), <DC_Layer_Init);
 
 -   
 
 - //  /*  Enable LUT on demand */
 
 - //  BitsPerPixel = LCD_GetBitsPerPixelEx(LayerIndex);
 
 - //  if (BitsPerPixel <= 8) 
 
 - //  {
 
 - //    /* Enable usage of LUT for all modes with <= 8bpp */
 
 - //    LTDC_CLUTCmd((LayerIndex == 0 ? LTDC_Layer1 : LTDC_Layer2), ENABLE);
 
 - //  } 
 
 - //  else 
 
 - //  {
 
 - //    /*  Optional CLUT initialization for AL88 mode (16bpp) */
 
 - //    if (apColorConvAPI[LayerIndex] == GUICC_88666I) 
 
 - //    {
 
 - //      LTDC_CLUTCmd((LayerIndex == 0 ? LTDC_Layer1 : LTDC_Layer2), ENABLE);
 
 - //      for (i = 0; i < 256; i++) 
 
 - //      {
 
 - //        Color = LCD_API_ColorConv_8666.pfIndex2Color(i);
 
 - //        LTDC_CLUT_InitStruct.LTDC_BlueValue   =  ((Color >> 16) & 0xff);
 
 - //        LTDC_CLUT_InitStruct.LTDC_GreenValue  =  ((Color >>  8) & 0xff);
 
 - //        LTDC_CLUT_InitStruct.LTDC_RedValue    =   (Color        & 0xff);
 
 - //        LTDC_CLUT_InitStruct.LTDC_CLUTAdress  =  i << 24; 
 
 - //        LTDC_CLUTInit((LayerIndex == 0 ? LTDC_Layer1 : LTDC_Layer2), <DC_CLUT_InitStruct);
 
 - //      }
 
 - //    }
 
 - //  }
 
 -   
 
 -   /*  Enable layer */
 
 -   LTDC_LayerCmd((LayerIndex == 0 ? LTDC_Layer1 : LTDC_Layer2), ENABLE);
 
 -   
 
 -   /* Reload configuration */
 
 -   LTDC_ReloadConfig(LTDC_VBReload);
 
 -   
 
 -   /* dithering activation */
 
 -   //LTDC_DitherCmd(ENABLE);
 
 -   //LTDC_ReloadConfig(LTDC_IMReload);
 
 -   LTDC_Cmd(ENABLE);
 
 - }
 
  复制代码 
 |