static void DMA2D_CopySTLogo(uint32_t lineOffset) { DMA2D_InitTypeDef DMA2D_InitStruct; DMA2D_FG_InitTypeDef DMA2D_FG_InitStruct; DMA2D_BG_InitTypeDef DMA2D_BG_InitStruct; /* Enable the DMA2D Clock */ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2D, ENABLE); /* Transfer mode => Memory to memory with pixel format conversion*/ DMA2D_InitStruct.DMA2D_Mode = DMA2D_M2M_PFC; /* Output color mode */ DMA2D_InitStruct.DMA2D_CMode = DMA2D_RGB565; /* Output Address at SRAM memory */ DMA2D_InitStruct.DMA2D_OutputMemoryAdd = (uint32_t)(LCD_FRAME_BUFFER + BUFFER_OFFSET + lineOffset); /* Initialize the alpha and RGB values */ DMA2D_InitStruct.DMA2D_OutputGreen = 0; DMA2D_InitStruct.DMA2D_OutputBlue = 0; DMA2D_InitStruct.DMA2D_OutputRed = 0; DMA2D_InitStruct.DMA2D_OutputAlpha = 0; /* Initialize the output offset */ DMA2D_InitStruct.DMA2D_OutputOffset = 0; /* Number of lines : height */ DMA2D_InitStruct.DMA2D_NumberOfLine = ImageSTLogo_height; /* Number of pixel per line : width */ DMA2D_InitStruct.DMA2D_PixelPerLine = ImageSTLogo_width; /* Initialize DMA2D */ DMA2D_Init(&DMA2D_InitStruct); /* Configure default values for foreground */ DMA2D_FG_StructInit(&DMA2D_FG_InitStruct); /* Input Address at flash memory */ DMA2D_FG_InitStruct.DMA2D_FGMA = (uint32_t)ImageSTLogo; DMA2D_FG_InitStruct.DMA2D_FGPFC_ALPHA_VALUE = 100; /* Input color mode */ DMA2D_FG_InitStruct.DMA2D_FGCM = CM_RGB565; /* Initialize foreground */ DMA2D_FGConfig(&DMA2D_FG_InitStruct); /* Configure default values for background */ DMA2D_BG_StructInit(&DMA2D_BG_InitStruct); /* Input Address at flash memory */ DMA2D_BG_InitStruct.DMA2D_BGMA = (uint32_t)frameBuffer; DMA2D_BG_InitStruct.DMA2D_BGPFC_ALPHA_VALUE = 100; /* Input color mode */ DMA2D_BG_InitStruct.DMA2D_BGCM = CM_RGB565; /* Initialize background */ DMA2D_BGConfig(&DMA2D_BG_InitStruct); /* Start Transfer */ DMA2D_StartTransfer(); while (!DMA2D_GetFlagStatus(DMA2D_FLAG_TC)) { } }
static void DMA2D_Config(void) { DMA2D_InitTypeDef DMA2D_InitStruct; DMA2D_FG_InitTypeDef DMA2D_FG_InitStruct; DMA2D_BG_InitTypeDef DMA2D_BG_InitStruct; /* Enable the DMA2D Clock */ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2D, ENABLE); /* DMA2D DeInitialization */ DMA2D_DeInit(); /* Configure transfer mode : memory to memory with blending */ DMA2D_InitStruct.DMA2D_Mode = DMA2D_M2M_BLEND; /* Configure color mode : RGB565 pixel format */ DMA2D_InitStruct.DMA2D_CMode = DMA2D_RGB565; /* Configure output Address : output frame buffer is located at SRAM */ DMA2D_InitStruct.DMA2D_OutputMemoryAdd = (uint32_t)&aBlendedImage; /* Configure the alpha and RGB values */ DMA2D_InitStruct.DMA2D_OutputGreen = 0; DMA2D_InitStruct.DMA2D_OutputBlue = 0; DMA2D_InitStruct.DMA2D_OutputRed = 0; DMA2D_InitStruct.DMA2D_OutputAlpha = 0; /* Configure the output offset */ DMA2D_InitStruct.DMA2D_OutputOffset = 0; /* Configure number of lines : height */ DMA2D_InitStruct.DMA2D_NumberOfLine = 130; /* Configure number of pixel per line : width */ DMA2D_InitStruct.DMA2D_PixelPerLine = 240; /* DMA2D Initialization */ DMA2D_Init(&DMA2D_InitStruct); /* Configure default values for foreground */ DMA2D_FG_StructInit(&DMA2D_FG_InitStruct); /* Configure foreground memory address : first input memory address at FLASH memory */ DMA2D_FG_InitStruct.DMA2D_FGMA = (uint32_t)&RGB565_240x130_1; /* Configure foreground color mode */ DMA2D_FG_InitStruct.DMA2D_FGCM = CM_RGB565; /* Configure foreground alpha value */ DMA2D_FG_InitStruct.DMA2D_FGPFC_ALPHA_MODE = REPLACE_ALPHA_VALUE; /* Configure foreground alpha mode : The constant alpha for foreground is decreased to see the background */ DMA2D_FG_InitStruct.DMA2D_FGPFC_ALPHA_VALUE = 0x75; /* Foreground Initialization */ DMA2D_FGConfig(&DMA2D_FG_InitStruct); /* Configure default values for background */ DMA2D_BG_StructInit(&DMA2D_BG_InitStruct); /* Configure background memory address : second input memory address at FLASH memory */ DMA2D_BG_InitStruct.DMA2D_BGMA = (uint32_t)&RGB565_240x130_2; /* Configure background color mode */ DMA2D_BG_InitStruct.DMA2D_BGCM = CM_RGB565; /* Configure background alpha mode */ DMA2D_BG_InitStruct.DMA2D_BGPFC_ALPHA_MODE = NO_MODIF_ALPHA_VALUE; /* Configure background alpha value */ DMA2D_BG_InitStruct.DMA2D_BGPFC_ALPHA_VALUE = 255; /* Background Initialization */ DMA2D_BGConfig(&DMA2D_BG_InitStruct); }