|

楼主 |
发表于 2016-3-7 12:11:04
|
显示全部楼层
下面是我的配置,请帮忙看看是不是缺了点么事。。。。。。
static void LTDC_Layers_Init(uint32_t LayerIndex)
{
LTDC_InitTypeDef LTDC_InitStruct;
LTDC_Layer_InitTypeDef LTDC_Layer_Init;
LTDC_CLUT_InitTypeDef LTDC_CLUT_InitStruct;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_LTDC, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2D, ENABLE);
/* 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_DEPolarity_AL;
/* 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;
RCC_PLLSAIConfig(192, 7, 4);
RCC_LTDCCLKDivConfig(RCC_PLLSAIDivR_Div4);
RCC_PLLSAICmd(ENABLE); /* Enable PLLSAI Clock */
while(RCC_GetFlagStatus(RCC_FLAG_PLLSAIRDY) == RESET) { } /* Wait for PLLSAI activation */
LTDC_InitStruct.LTDC_HorizontalSync = HSW;
LTDC_InitStruct.LTDC_VerticalSync = VSW; /* Configure vertical synchronization height */
LTDC_InitStruct.LTDC_AccumulatedHBP = HBP; /* Configure accumulated horizontal back porch */
LTDC_InitStruct.LTDC_AccumulatedVBP = VBP; /* Configure accumulated vertical back porch */
LTDC_InitStruct.LTDC_AccumulatedActiveW = LCD_XSIZE + HBP; /* Configure accumulated active width */
LTDC_InitStruct.LTDC_AccumulatedActiveH = LCD_YSIZE + VBP; /* Configure accumulated active height */
LTDC_InitStruct.LTDC_TotalWidth = LCD_XSIZE + HBP + HFP; /* Configure total width (1056)*/
LTDC_InitStruct.LTDC_TotalHeigh = LCD_YSIZE + VBP + VFP; /* Configure total height (525)*/
LTDC_Init(&LTDC_InitStruct);
LTDC_Layer_Init.LTDC_HorizontalStart = HBP + 1;
LTDC_Layer_Init.LTDC_HorizontalStop = (LCD_XSIZE + HBP);
LTDC_Layer_Init.LTDC_VerticalStart = VBP + 1;
LTDC_Layer_Init.LTDC_VerticalStop = (LCD_YSIZE + VBP);
LTDC_Layer_Init.LTDC_PixelFormat = LTDC_Pixelformat_RGB565;
LTDC_Layer_Init.LTDC_CFBLineLength = (LCD_XSIZE*2) + 3;
LTDC_Layer_Init.LTDC_CFBPitch = (LCD_XSIZE*2);
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;
LTDC_Layer_Init.LTDC_CFBLineNumber = LCD_YSIZE;
LTDC_Layer_Init.LTDC_CFBStartAdress = Layer_Address[LayerIndex];
LTDC_LayerInit((LayerIndex == 0 ? LTDC_Layer1 : LTDC_Layer2), &LTDC_Layer_Init);
LTDC_ReloadConfig(LTDC_IMReload); /* LTDC configuration reload */
LTDC_LayerCmd((LayerIndex == 0 ? LTDC_Layer1 : LTDC_Layer2), ENABLE);/* Enable foreground & background Layers */
LTDC_ReloadConfig(LTDC_IMReload); /* LTDC configuration reload */
LTDC_Cmd(ENABLE); /* display ON */
LTDC_DitherCmd(ENABLE);/* dithering activation */
}
static void DMA_DrawBitmapL8(void * pSrc, void * pDst, uint32_t OffSrc, uint32_t OffDst, uint32_t PixelFormatDst, uint32_t xSize, uint32_t ySize)
{
/* Set up mode */
DMA2D->CR = 0x00010000UL; /* Control Register (Memory to memory with pixel format conversion and TCIE) */
/* Set up pointers */
DMA2D->FGMAR = (uint32_t)pSrc; /* Foreground Memory Address Register (Source address) */
DMA2D->OMAR = (uint32_t)pDst; /* Output Memory Address Register (Destination address) */
/* Set up offsets */
DMA2D->FGOR = OffSrc; /* Foreground Offset Register (Source line offset) */
DMA2D->OOR = OffDst; /* Output Offset Register (Destination line offset) */
/* Set up pixel format */
DMA2D->FGPFCCR = LTDC_Pixelformat_L8; /* Foreground PFC Control Register (Defines the input pixel format) */
DMA2D->OPFCCR = PixelFormatDst; /* Output PFC Control Register (Defines the output pixel format) */
/* Set up size */
DMA2D->NLR = (uint32_t)(xSize << 16) | ySize; /* Number of Line Register (Size configuration of area to be transfered) */
/* Execute operation */
DMA2D->CR |= 1; /* Start operation */
/* Wait until transfer is done */
while (DMA2D->CR & DMA2D_CR_START) { }
}
void LCD_DrawBitmap8bpp(int x, int y, int xSize, int ySize, uint8_t const * p, int BytesPerLine)
{
uint32_t BufferSize, AddrDst;
int OffLineSrc, OffLineDst;
AddrDst = LCD_DISPLAY_BUFFER_ADDRESS + (y * LCD_XSIZE + x) * BYTES_PER_PIXEL;
OffLineSrc = BytesPerLine - xSize;
OffLineDst = LCD_XSIZE - xSize;;
DMA_DrawBitmapL8((void *)p, (void *)AddrDst, OffLineSrc, OffLineDst, PIXELFORMAT, xSize, ySize);
} |
|