/* 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 = ((LCD_PIXEL_WIDTH * 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 = (LCD_PIXEL_WIDTH * 2);
/* Configure the number of lines */
LTDC_Layer_InitStruct.LTDC_CFBLineNumber = LCD_PIXEL_HEIGHT;
//
//memcpy((unsigned char*)LCD_FRAME_BUFFER, gImage_photo, sizeof(gImage_photo));
//memcpy((unsigned char*)(LCD_FRAME_BUFFER + BUFFER_OFFSET), gImage_photo, sizeof(gImage_photo));
//
/* Start Address configuration : the LCD Frame buffer is defined on SDRAM */
LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD_FRAME_BUFFER;//BACKGROUND_PIC_ADD LCD_FRAME_BUFFER;
//
//memset((unsigned char*)LCD_FRAME_BUFFER, 0, BUFFER_OFFSET*2);
//
/* Initialize LTDC layer 1 */
LTDC_LayerInit(LTDC_Layer1, <DC_Layer_InitStruct);
嗯嗯,正在查,但是LTDC的RGB565配置只有那么点,想不出哪里出错
{
LTDC_InitTypeDef LTDC_InitStruct;
/* Configure the LCD Control pins ------------------------------------------*/
//LCD_CtrlLinesConfig();
/* Enable the LTDC Clock */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_LTDC, ENABLE);
/* Enable the DMA2D Clock */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2D, ENABLE);
/* Configure the LCD Control pins */
LCD_AF_GPIOConfig();
/* Configure the FMC Parallel interface : SDRAM is used as Frame Buffer for LCD */
SDRAM_Init();
/* LTDC Configuration *********************************************************/
/* 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 = 0;
LTDC_InitStruct.LTDC_BackgroundGreenValue = 0;
LTDC_InitStruct.LTDC_BackgroundBlueValue = 0;
/* 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 = 48 Mhz */
/* LTDC clock frequency = PLLLCDCLK / RCC_PLLSAIDivR = 48/8 = 6 Mhz */
//RCC_PLLSAIConfig(192, 7, 4);
//26.4 x 2 x 4 = 211 //290
RCC_PLLSAIConfig(244, 7, 3);
RCC_LTDCCLKDivConfig(RCC_PLLSAIDivR_Div2);
//RCC_PLLSAIConfig(360, 7, 3);
// RCC_LTDCCLKDivConfig(RCC_PLLSAIDivR_Div4);
//32*3*2 = 192
//RCC_PLLSAIConfig(192, 7, 3);
// RCC_LTDCCLKDivConfig(RCC_PLLSAIDivR_Div2);
/* Enable PLLSAI Clock */
RCC_PLLSAICmd(ENABLE);
/* Wait for PLLSAI activation */
while(RCC_GetFlagStatus(RCC_FLAG_PLLSAIRDY) == RESET)
{
}
/* Timing configuration */
/* Configure horizontal synchronization width */
LTDC_InitStruct.LTDC_HorizontalSync =LCD_HS;//30;//9;
/* Configure vertical synchronization height */
LTDC_InitStruct.LTDC_VerticalSync = LCD_VS;//15;//1;
/* Configure accumulated horizontal back porch */
LTDC_InitStruct.LTDC_AccumulatedHBP = LCD_HBP;//46;//29;
/* Configure accumulated vertical back porch */
LTDC_InitStruct.LTDC_AccumulatedVBP = LCD_VBP;//23;//3;
/* Configure accumulated active width */
LTDC_InitStruct.LTDC_AccumulatedActiveW = LCD_AW;//269;
/* Configure accumulated active height */
LTDC_InitStruct.LTDC_AccumulatedActiveH = LCD_AH;//323;
/* Configure total width */
LTDC_InitStruct.LTDC_TotalWidth = LCD_TOTAL_W;//200;//1055;//279;
/* Configure total height */
LTDC_InitStruct.LTDC_TotalHeigh = LCD_TOTAL_H;//20;//524;//327;
LTDC_Init(<DC_InitStruct);
}
/**
* @brief Initializes the LCD Layers.
* @param None
* @retval None
*/
void LCD_LayerInit(void)
{
LTDC_Layer_InitTypeDef LTDC_Layer_InitStruct;
/* Windowing configuration */
/* In this case all the active display area is used to display a picture then :
Horizontal start = horizontal synchronization + Horizontal back porch = 30
Horizontal stop = Horizontal start + window width -1 = 30 + 240 -1
Vertical start = vertical synchronization + vertical back porch = 4
Vertical stop = Vertical start + window height -1 = 4 + 320 -1 */
LTDC_Layer_InitStruct.LTDC_HorizontalStart = LCD_LAYER_H_START;
LTDC_Layer_InitStruct.LTDC_HorizontalStop = LCD_LAYER_H_STOP;
LTDC_Layer_InitStruct.LTDC_VerticalStart = LCD_LAYER_V_START;
LTDC_Layer_InitStruct.LTDC_VerticalStop = LCD_LAYER_V_STOP;
/* 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 = ((LCD_PIXEL_WIDTH * 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 = (LCD_PIXEL_WIDTH * 2);
/* Configure the number of lines */
LTDC_Layer_InitStruct.LTDC_CFBLineNumber = LCD_PIXEL_HEIGHT;
//
//memcpy((unsigned char*)LCD_FRAME_BUFFER, gImage_photo, sizeof(gImage_photo));
//memcpy((unsigned char*)(LCD_FRAME_BUFFER + BUFFER_OFFSET), gImage_photo, sizeof(gImage_photo));
//
/* Start Address configuration : the LCD Frame buffer is defined on SDRAM */
LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD_FRAME_BUFFER;//BACKGROUND_PIC_ADD LCD_FRAME_BUFFER;
//
//memset((unsigned char*)LCD_FRAME_BUFFER, 0, BUFFER_OFFSET*2);
//
/* Initialize LTDC layer 1 */
LTDC_LayerInit(LTDC_Layer1, <DC_Layer_InitStruct);
/* LTDC configuration reload */
LTDC_ReloadConfig(LTDC_IMReload);
/* Enable foreground & background Layers */
LTDC_LayerCmd(LTDC_Layer1, ENABLE);
//LTDC_LayerCmd(LTDC_Layer2, ENABLE);
/* LTDC configuration reload */
LTDC_ReloadConfig(LTDC_IMReload);
/* Set default font */
LCD_SetFont(&LCD_DEFAULT_FONT);
/* dithering activation */
LTDC_DitherCmd(ENABLE);
}
一周热门 更多>