ну вот так инит вобщем выглядит теперь: что тут ещё можно править?
Код:
void TFT800_480_InitLTDC(void) {
TM_ILI9341_InitPins(); /* Initialize pins used */
TM_SDRAM_Init(); /* Init SDRAM */
LTDC_InitTypeDef LTDC_InitStruct;
/* Enable the LTDC Clock */
RCC->APB2ENR |= RCC_APB2ENR_LTDCEN;
/* Enable the DMA2D Clock */
RCC->AHB1ENR |= RCC_AHB1ENR_DMA2DEN;
/* Polarity configuration */
/* Initialize the horizontal synchronization polarity as active low */
LTDC_InitStruct.LTDC_HSPolarity = LTDC_HSPolarity_AL;
/* Initialize the vertical synchronization polarity as active low */
LTDC_InitStruct.LTDC_VSPolarity = LTDC_VSPolarity_AL;
/* Initialize the data enable polarity as active low */
LTDC_InitStruct.LTDC_DEPolarity = LTDC_DEPolarity_AL;
/* Initialize the pixel clock polarity as input pixel clock */
LTDC_InitStruct.LTDC_PCPolarity = LTDC_PCPolarity_IPC;
/* Configure R,G,B component values for LCD background color */
LTDC_InitStruct.LTDC_BackgroundRedValue = 0x00;
LTDC_InitStruct.LTDC_BackgroundGreenValue = 0x00;
LTDC_InitStruct.LTDC_BackgroundBlueValue = 0x00;
/* Configure PLLSAI prescalers for LCD */
/* Enable Pixel Clock */
/* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */
/* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAI_N = 192 Mhz */
/* PLLLCDCLK = PLLSAI_VCO Output/PLLSAI_R = 192/4 = 96 Mhz */
/* LTDC clock frequency = PLLLCDCLK / RCC_PLLSAIDivR = 96/4 = 24 Mhz */
RCC_PLLSAIConfig(200, 4, 4);//RCC_PLLSAIConfig(192, 7, 4);
RCC_LTDCCLKDivConfig(RCC_PLLSAIDivR_Div2);//25MHz
/* Enable PLLSAI Clock */
RCC_PLLSAICmd(ENABLE);
/* Wait for PLLSAI activation */
while (RCC_GetFlagStatus(RCC_FLAG_PLLSAIRDY) == RESET) {
}
/* Timing configuration */
LTDC_InitStruct.LTDC_HorizontalSync = 0; /* Configure horizontal synchronization width */
LTDC_InitStruct.LTDC_VerticalSync = 0; /* Configure vertical synchronization height */
LTDC_InitStruct.LTDC_AccumulatedHBP = 46; /* Configure accumulated horizontal back porch */
LTDC_InitStruct.LTDC_AccumulatedVBP = 23; /* Configure accumulated vertical back porch */
LTDC_InitStruct.LTDC_AccumulatedActiveW = 846; /* Configure accumulated active width */
LTDC_InitStruct.LTDC_AccumulatedActiveH = 503; /* Configure accumulated active height */
LTDC_InitStruct.LTDC_TotalWidth = 862; /* Configure total width */
LTDC_InitStruct.LTDC_TotalHeigh = 510; /* Configure total height */
/* Init LTDC */
LTDC_Init(<DC_InitStruct);
}
//===============================================================================================================
//========== =====================================
//===============================================================================================================
void TFT800_480_InitLayers(void) {
LTDC_Layer_InitTypeDef LTDC_Layer_InitStruct;
/* Windowing configuration */
// Horizontal start = horizontal synchronization + Horizontal back porch
// Horizontal stop = Horizontal start + LCD_PIXEL_WIDTH - 1
// Vertical start = vertical synchronization + vertical back porch
// Vertical stop = Vertical start + LCD_PIXEL_HEIGHT - 1
LTDC_Layer_InitStruct.LTDC_HorizontalStart = 46;
LTDC_Layer_InitStruct.LTDC_HorizontalStop = 845;
LTDC_Layer_InitStruct.LTDC_VerticalStart = 23;
LTDC_Layer_InitStruct.LTDC_VerticalStop = 502;
/* Pixel Format configuration*/
LTDC_Layer_InitStruct.LTDC_PixelFormat = LTDC_Pixelformat_RGB565;
/* 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 */
LTDC_Layer_InitStruct.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_CA;
LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_CA;
/* the length of one line of pixels in bytes + 3 then :
Line Lenth = Active high width x number of bytes per pixel + 3
Active high width = LCD_PIXEL_WIDTH
number of bytes per pixel = 2 (pixel_format : RGB565)
*/
LTDC_Layer_InitStruct.LTDC_CFBLineLength = 480 * 2 +3;
/* the pitch is the increment from the start of one line of pixels to the
start of the next line in bytes, then :
Pitch = Active high width x number of bytes per pixel
*/
LTDC_Layer_InitStruct.LTDC_CFBPitch = 480 * 2;
/* Configure the number of lines */
LTDC_Layer_InitStruct.LTDC_CFBLineNumber = 800;
/* Start Address configuration : the LCD Frame buffer is defined on SDRAM */
LTDC_Layer_InitStruct.LTDC_CFBStartAdress = ILI9341_FRAME_BUFFER;
/* Initialize Layer 1 */
LTDC_LayerInit(LTDC_Layer1, <DC_Layer_InitStruct);
/* Configure Layer2 */
/* Start Address configuration : the LCD Frame buffer is defined on SDRAM w/ Offset */
LTDC_Layer_InitStruct.LTDC_CFBStartAdress = ILI9341_FRAME_BUFFER + ILI9341_FRAME_OFFSET;
/* Configure blending factors */
LTDC_Layer_InitStruct.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_PAxCA;
LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_PAxCA;
/* Initialize Layer 2 */
LTDC_LayerInit(LTDC_Layer2, <DC_Layer_InitStruct);
LTDC_ReloadConfig(LTDC_IMReload);
/* Enable foreground & background Layers */
LTDC_LayerCmd(LTDC_Layer1, ENABLE);
LTDC_LayerCmd(LTDC_Layer2, ENABLE);
/* Reload immediate */
LTDC_ReloadConfig(LTDC_IMReload);
LTDC_DitherCmd(ENABLE);
/* Display On */
LTDC_Cmd(ENABLE);
/* Set opacity */
LTDC_LayerAlpha(LTDC_Layer1, 255);
LTDC_LayerAlpha(LTDC_Layer2, 0);
/* Immediate reload */
LTDC_ReloadConfig(LTDC_IMReload);
}