/** * @brief Main program * @param None * @retval None */ int main(void) { /* STM32F4xx HAL library initialization: - Configure the Flash prefetch, instruction and Data caches - Configure the Systick to generate an interrupt each 1 msec - Set NVIC Group Priority to 4 - Global MSP (MCU Support Package) initialization */ HAL_Init(); /* Configure LED3 & LED4*/ BSP_LED_Init(LED3); BSP_LED_Init(LED4); /* Configure the system clock */ SystemClock_Config(); /*##-1- LCD Configuration ##################################################*/ LCD_Config(); /*##-2- Configure DMA2D : Configure foreground and background ##############*/ DMA2D_Config(); /*##-3- Start DMA2D transfer ###############################################*/ if(HAL_DMA2D_BlendingStart_IT(&Dma2dHandle, (uint32_t)&aRGB565_1, (uint32_t)&aRGB565_2, (uint32_t)&aBlendedImage, 240, 160) != HAL_OK) { /* Initialization Error */ Error_Handler(); } while (1) { } }
/** * @brief Main program * @param None * @retval None */ int main(void) { uint8_t lcd_status = LCD_OK; HAL_StatusTypeDef hal_status = HAL_OK; LcdResX = WVGA_RES_X; /* WVGA landscape */ LcdResY = WVGA_RES_Y; stageNb = 1; blended_image_ready = 0; offset_address_area_blended_image_in_lcd_buffer = ((((LcdResY - LAYER_SIZE_Y) / 2) * LcdResX) + ((LcdResX - LAYER_SIZE_X) / 2)) * ARGB8888_BYTE_PER_PIXEL; /* STM32F4xx HAL library initialization: - Configure the Flash prefetch, instruction and Data caches - Systick timer is configured by default as source of time base, but user can eventually implement his proper time base source (a general purpose timer for example or other time source), keeping in mind that Time base duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and handled in milliseconds basis. - Set NVIC Group Priority to 4 - Low Level Initialization: global MSP (MCU Support Package) initialization */ HAL_Init(); /* Configure the system clock to 180 MHz */ SystemClock_Config(); /* Wait until MFX is ready after reset */ HAL_Delay(100); /* Configure LED1, LED2 and LED3 */ BSP_LED_Init(LED1); BSP_LED_Init(LED2); BSP_LED_Init(LED3); /*##-1- Initialize the LCD #################################################*/ /* Proceed to LTDC, DSI initialization and LCD screen initialization * with the configuration filled in above */ lcd_status = BSP_LCD_Init(); BSP_LCD_LayerDefaultInit(0, LCD_FB_START_ADDRESS); OnError_Handler(lcd_status != LCD_OK); /* Prepare using DMA2D the 800x480 LCD frame buffer to display background color black */ /* and title of the example */ BSP_LCD_Clear(LCD_COLOR_BLACK); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_SetBackColor(LCD_COLOR_BLUE); BSP_LCD_SetFont(&Font16); /* Print example description */ BSP_LCD_DisplayStringAt(0, 440, (uint8_t *)"DMA2D_MemToMemWithBlending example", CENTER_MODE); HAL_Delay(100); /* Go to next stageNb of display configuration, consists in refreshing only the camera */ /* frame buffer area of the complete LCD frame buffer */ stageNb++; /* stageNb == 2 */ /*##-2- Configure DMA2D : Configure foreground and background ##############*/ DMA2D_Config(); /*##-3- Start DMA2D transfer in interrupt mode ################################################*/ /*## RGB565_240x130_1[] is the foreground layer and RGB565_240x130_2[] is the background layer */ hal_status = HAL_DMA2D_BlendingStart_IT(&Dma2dHandle, (uint32_t)&RGB565_240x130_1, (uint32_t)&RGB565_240x130_2, (uint32_t)&aBlendedImage, LAYER_SIZE_X, LAYER_SIZE_Y); OnError_Handler(hal_status != HAL_OK); /*##-4- Copy blended image in center of LCD frame buffer ################################################*/ /* Wait until blended image is ready to be displayed */ while(blended_image_ready == 0) {;} /* Blocking copy Blended image buffer to LCD frame buffer center area */ /* Using the DMA2D in polling mode */ lcd_status = CopyBlendedBufferToLcdFrameBuffer((void*)&(aBlendedImage[0]), (void*)(LCD_FRAME_BUFFER + offset_address_area_blended_image_in_lcd_buffer), LAYER_SIZE_X, LAYER_SIZE_Y); while (1) { ; } }
/** * @brief Main program * @param None * @retval None */ int main(void) { RCC_PeriphCLKInitTypeDef PeriphClkInitStruct; /* Enable the CPU Cache */ CPU_CACHE_Enable(); /* STM32F7xx HAL library initialization: - Configure the Flash ART accelerator on ITCM interface - Systick timer is configured by default as source of time base, but user can eventually implement his proper time base source (a general purpose timer for example or other time source), keeping in mind that Time base duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and handled in milliseconds basis. - Set NVIC Group Priority to 4 - Low Level Initialization */ HAL_Init(); /* Configure the system clock to 216 MHz */ SystemClock_Config(); /*## LTDC Clock Configuration ###########################################*/ if(stmpe811_ts_drv.ReadID(TS_I2C_ADDRESS) == STMPE811_ID) { /* LCD clock configuration */ /* LCD clock configuration */ /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 192 Mhz */ /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 192/5 = 38.4 Mhz */ /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_4 = 38.4/4 = 9.6Mhz */ PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC; PeriphClkInitStruct.PLLSAI.PLLSAIN = 192; PeriphClkInitStruct.PLLSAI.PLLSAIR = 5; PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_4; HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); } else { /* LCD clock configuration */ /* LCD clock configuration */ /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 192 Mhz */ /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 192/2 = 96 Mhz */ /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_4 = 96/4 = 24Mhz */ PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC; PeriphClkInitStruct.PLLSAI.PLLSAIN = 192; PeriphClkInitStruct.PLLSAI.PLLSAIR = 2; PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_4; HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); } /* Configure LED1, LED2 and LED3 */ BSP_LED_Init(LED1); BSP_LED_Init(LED2); BSP_LED_Init(LED3); /*##-1- LCD Configuration ##################################################*/ LCD_Config(); /*##-2- Configure DMA2D : Configure foreground and background ##############*/ DMA2D_Config(); /*##-3- Start DMA2D transfer in interrupt mode ################################################*/ /*## RGB565_240x130_1[] is the foreground layer and RGB565_240x130_2[] is the background layer */ if(HAL_DMA2D_BlendingStart_IT(&Dma2dHandle, (uint32_t)&RGB565_240x130_1, (uint32_t)&RGB565_240x130_2, (uint32_t)&aBlendedImage, LAYER_SIZE_X, LAYER_SIZE_Y) != HAL_OK) { /* Initialization Error */ Error_Handler(); } while (1) { ; } }