static void DMA2D_Config(void) { HAL_StatusTypeDef hal_status = HAL_OK; /* Configure the DMA2D Mode, Color Mode and output offset */ Dma2dHandle.Init.Mode = DMA2D_M2M_PFC; /* DMA2D mode Memory to Memory with Pixel Format Conversion */ Dma2dHandle.Init.ColorMode = DMA2D_ARGB4444; /* DMA2D Output color mode is ARGB4444 (16 bpp) */ Dma2dHandle.Init.OutputOffset = 0x0; /* No offset in output */ /* DMA2D Callbacks Configuration */ Dma2dHandle.XferCpltCallback = TransferComplete; Dma2dHandle.XferErrorCallback = TransferError; /* Foreground layer Configuration : layer 1 */ Dma2dHandle.LayerCfg[1].AlphaMode = DMA2D_NO_MODIF_ALPHA; Dma2dHandle.LayerCfg[1].InputAlpha = 0xFF; /* Alpha fully opaque */ Dma2dHandle.LayerCfg[1].InputColorMode = CM_ARGB8888; /* Layer 1 input format is ARGB8888 (32 bpp) */ Dma2dHandle.LayerCfg[1].InputOffset = 0x0; /* No offset in input */ Dma2dHandle.Instance = DMA2D; /* DMA2D Initialization */ hal_status = HAL_DMA2D_Init(&Dma2dHandle); OnError_Handler(hal_status != HAL_OK); hal_status = HAL_DMA2D_ConfigLayer(&Dma2dHandle, 1); OnError_Handler(hal_status != HAL_OK); }
/** * @brief Main program * @param None * @retval None */ int main(void) { HAL_StatusTypeDef hal_status = HAL_OK; uint8_t lcd_status = LCD_OK; /* 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 */ 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 SDRAM ##############################################*/ BSP_SDRAM_Init(); /*##-2- Initialize the LCD #################################################*/ /* Proceed to LTDC, DSI initialization and LCD screen initialization * with the configuration filled in above */ lcd_status = BSP_LCD_Init(); LCD_LayerDefaultInit(1, (uint32_t)&aBufferResult); BSP_LCD_SelectLayer(1); OnError_Handler(lcd_status != LCD_OK); HAL_Delay(100); /*##-3- DMA2D configuration ################################################*/ DMA2D_Config(); /*##-4- Start DMA2D transfer ###############################################*/ hal_status = HAL_DMA2D_Start_IT(&Dma2dHandle, (uint32_t)LCD_COLOR_GREEN, /* Fill the DMA2D output register with this color */ (uint32_t)&aBufferResult, /* DMA2D output register */ LAYER_SIZE_X, LAYER_SIZE_Y); OnError_Handler(hal_status != HAL_OK); while (1) { ; } }
/** * @brief Main program * @param None * @retval None */ int main(void) { HAL_StatusTypeDef hal_status = HAL_OK; uint8_t lcd_status = LCD_OK; /* 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 */ 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(); LCD_LayerDefaultInit(0, (uint32_t)&ARGB8888_300x120); //Background layer shows original image, on top of the screen LCD_LayerDefaultInit(1, (uint32_t)&aBufferResult); //Forground layer shows converted image, on bottom of the screen BSP_LCD_SelectLayer(1); OnError_Handler(lcd_status != LCD_OK); HAL_Delay(100); /*##-2- DMA2D configuration ################################################*/ DMA2D_Config(); /*##-3- Start DMA2D transfer ###############################################*/ hal_status = HAL_DMA2D_Start_IT(&Dma2dHandle, (uint32_t)&ARGB8888_300x120, /* Input image 300x120 of format ARGB8888 (32 bpp) */ (uint32_t)&aBufferResult, /* Output image of same size 300x120 after conversion by PFC in ARGB4444 (16 bpp) */ LAYER_SIZE_X, LAYER_SIZE_Y); OnError_Handler(hal_status != HAL_OK); while (1) { ; } }
/** * @brief Main program * @param None * @retval None */ int main(void) { uint8_t lcd_status = LCD_OK; /* 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(); /* Initialize the SDRAM */ BSP_SDRAM_Init(); /* Initialize the LCD */ lcd_status = LCD_Init(); OnError_Handler(lcd_status != LCD_OK); /* Initialize LTDC layer 0 iused for Hint */ BSP_LCD_LayerDefaultInit(0, LAYER0_ADDRESS); BSP_LCD_SelectLayer(0); /* Display example brief */ LCD_BriefDisplay(); /*Draw first image */ CopyBuffer((uint32_t *)Images[ImageIndex++], (uint32_t *)LAYER0_ADDRESS, 240, 160, 320, 240); pending_buffer = 0; /*Refresh the LCD display*/ HAL_DSI_Refresh(&hdsi_eval); /* Infinite loop */ while (1) { if(pending_buffer < 0) { CopyBuffer((uint32_t *)Images[ImageIndex++], (uint32_t *)LAYER0_ADDRESS, 240, 160, 320, 240); if(ImageIndex >= 2) { ImageIndex = 0; } pending_buffer = 0; HAL_DSI_Refresh(&hdsi_eval); } /* Wait some time before switching to next image */ HAL_Delay(2000); } }
/** * @brief Main program * @param None * @retval None */ int main(void) { uint8_t lcd_status = LCD_OK; /* 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(); /* Initialize the LCD */ lcd_status = BSP_LCD_Init(); OnError_Handler(lcd_status != LCD_OK); BSP_LCD_LayerDefaultInit(0, LAYER0_ADDRESS); BSP_LCD_SelectLayer(0); /* Set LTDC Line Event */ HAL_LTDC_ProgramLineEvent(&hltdc_eval, 0); /* Display example brief */ LCD_BriefDisplay(); /* Copy Buffer 0 into buffer 1, so only image area to be redrawn later */ CopyBuffer((uint32_t *)Buffers[0], (uint32_t *)Buffers[1], 0, 0, 800, 480); /* Infinite loop */ while (1) { if(pend_buffer < 0) { /* Prepare back buffer */ CopyBuffer((uint32_t *)Images[ImageIndex++], (uint32_t *)Buffers[1- front_buffer], 240, 160, 320, 240); pend_buffer = 1- front_buffer; if(ImageIndex >= 2) { ImageIndex = 0; } /* Wait some time before switching to next stage */ HAL_Delay(2000); } } }
static void DMA2D_Config(void) { HAL_StatusTypeDef hal_status = HAL_OK; /* Register to memory mode with ARGB8888 as colorMode */ Dma2dHandle.Init.Mode = DMA2D_R2M; Dma2dHandle.Init.ColorMode = DMA2D_ARGB8888; Dma2dHandle.Init.OutputOffset = 0x0; Dma2dHandle.XferCpltCallback = TransferComplete; Dma2dHandle.XferErrorCallback = TransferError; Dma2dHandle.Instance = DMA2D; /* DMA2D Initialization */ hal_status = HAL_DMA2D_Init(&Dma2dHandle); OnError_Handler(hal_status != HAL_OK); hal_status = HAL_DMA2D_ConfigLayer(&Dma2dHandle, 1); OnError_Handler(hal_status != HAL_OK); }
static void DMA2D_Config(void) { HAL_StatusTypeDef hal_status = HAL_OK; /* Configure the DMA2D Mode, Color Mode and output offset */ Dma2dHandle.Init.Mode = DMA2D_M2M_BLEND; /* DMA2D mode Memory to Memory with Blending */ Dma2dHandle.Init.ColorMode = DMA2D_RGB565; /* output format of DMA2D */ Dma2dHandle.Init.OutputOffset = 0x0; /* No offset in output */ /* DMA2D Callbacks Configuration */ Dma2dHandle.XferCpltCallback = TransferComplete; Dma2dHandle.XferErrorCallback = TransferError; /* Foreground layer Configuration */ Dma2dHandle.LayerCfg[1].AlphaMode = DMA2D_REPLACE_ALPHA; Dma2dHandle.LayerCfg[1].InputAlpha = 0x7F; /* 127 : semi-transparent */ Dma2dHandle.LayerCfg[1].InputColorMode = CM_RGB565; Dma2dHandle.LayerCfg[1].InputOffset = 0x0; /* No offset in input */ /* Background layer Configuration */ Dma2dHandle.LayerCfg[0].AlphaMode = DMA2D_REPLACE_ALPHA; Dma2dHandle.LayerCfg[0].InputAlpha = 0x7F; /* 127 : semi-transparent */ Dma2dHandle.LayerCfg[0].InputColorMode = CM_RGB565; Dma2dHandle.LayerCfg[0].InputOffset = 0x0; /* No offset in input */ Dma2dHandle.Instance = DMA2D; /* DMA2D Initialization */ hal_status = HAL_DMA2D_Init(&Dma2dHandle); OnError_Handler(hal_status != HAL_OK); /* Apply DMA2D Foreground configuration */ HAL_DMA2D_ConfigLayer(&Dma2dHandle, 1); /* Apply DMA2D Background configuration */ HAL_DMA2D_ConfigLayer(&Dma2dHandle, 0); }
/** * @brief Main program * @param None * @retval None */ int main(void) { uint8_t lcd_status = LCD_OK; /* 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(); /* Initialize the SDRAM */ BSP_SDRAM_Init(); /* Initialize the LCD */ lcd_status = LCD_Init(); OnError_Handler(lcd_status != LCD_OK); /* Initialize LTDC layer 0 iused for Hint */ LCD_LayertInit(0, LAYER0_ADDRESS); BSP_LCD_SelectLayer(0); HAL_DSI_LongWrite(&hdsi_eval, 0, DSI_DCS_LONG_PKT_WRITE, 4, OTM8009A_CMD_CASET, pColLeft); HAL_DSI_LongWrite(&hdsi_eval, 0, DSI_DCS_LONG_PKT_WRITE, 4, OTM8009A_CMD_PASET, pPage); /* Update pitch : the draw is done on the whole physical X Size */ HAL_LTDC_SetPitch(&hltdc_eval, BSP_LCD_GetXSize(), 0); /* Display example brief */ LCD_BriefDisplay(); /* Show first image */ CopyPicture((uint32_t *)Images[ImageIndex++], (uint32_t *)LAYER0_ADDRESS, 240, 160, 320, 240); pending_buffer = 0; active_area = LEFT_AREA; HAL_DSI_LongWrite(&hdsi_eval, 0, DSI_DCS_LONG_PKT_WRITE, 2, OTM8009A_CMD_WRTESCN, pSyncLeft); /* Infinite loop */ while (1) { if(pending_buffer < 0) { CopyPicture((uint32_t *)Images[ImageIndex++], (uint32_t *)LAYER0_ADDRESS, 240, 160, 320, 240); if(ImageIndex >= 2) { ImageIndex = 0; } pending_buffer = 1; HAL_DSI_LongWrite(&hdsi_eval, 0, DSI_DCS_LONG_PKT_WRITE, 2, OTM8009A_CMD_WRTESCN, pSyncLeft); } /* Wait some time before switching to next image */ HAL_Delay(2000); } }
/** * @brief Main program * @param None * @retval None */ int main(void) { RCC_PeriphCLKInitTypeDef PeriphClkInitStruct; HAL_StatusTypeDef hal_status = HAL_OK; /* Configure the MPU attributes as Write Through */ MPU_Config(); /* Enable the CPU Cache */ CPU_CACHE_Enable(); /* STM32F7xx HAL library initialization: - Configure the Flash prefetch - 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 */ SystemClock_Config(); /*## LTDC 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); /* Configure LED1 */ BSP_LED_Init(LED1); /*##-1- LCD Configuration ##################################################*/ LCD_Config(); /*##-2- DMA2D configuration ################################################*/ DMA2D_Config(); /*##-3- Start DMA2D transfer ###############################################*/ hal_status = HAL_DMA2D_Start_IT(&Dma2dHandle, (uint32_t)&ARGB8888_300x120, /* Input image 300x120 of format ARGB8888 (32 bpp) */ (uint32_t)&aBufferResult, /* Output image of same size 300x120 after conversion by PFC in ARGB4444 (16 bpp) */ LAYER_SIZE_X, LAYER_SIZE_Y); OnError_Handler(hal_status != HAL_OK); while (1) { ; } }
/** * @brief LCD Configuration. * @note This function Configure the LTDC peripheral : * 1) Configure the Pixel Clock for the LCD * 2) Configure the LTDC Timing and Polarity * 3) Configure the LTDC Layer 1 : * - ARGB8888 as pixel format * - The frame buffer is located in internal Flash : original image 300x120 in ARGB8888 format * - The Layer size configuration : 300x120 * 4) Configure the LTDC Layer 2 : * - ARGB4444 as pixel format * - The frame buffer is located at internal SRAM : The output of DMA2D transfer * - The Layer size configuration : 300x120 * @retval * None */ static void LCD_Config(void) { HAL_StatusTypeDef hal_status = HAL_OK; static LTDC_HandleTypeDef LtdcHandle; static LTDC_LayerCfgTypeDef pLayerCfg; static LTDC_LayerCfgTypeDef pLayerCfg1; /* LTDC Initialization -------------------------------------------------------*/ /* Polarity configuration */ /* Initialize the horizontal synchronization polarity as active low */ LtdcHandle.Init.HSPolarity = LTDC_HSPOLARITY_AL; /* Initialize the vertical synchronization polarity as active low */ LtdcHandle.Init.VSPolarity = LTDC_VSPOLARITY_AL; /* Initialize the data enable polarity as active low */ LtdcHandle.Init.DEPolarity = LTDC_DEPOLARITY_AL; /* Initialize the pixel clock polarity as input pixel clock */ LtdcHandle.Init.PCPolarity = LTDC_PCPOLARITY_IPC; /* Timing configuration for RK043FN48H 480x272 LCD */ /* Horizontal synchronization width = Hsync - 1 */ LtdcHandle.Init.HorizontalSync = 40; /* Vertical synchronization height = Vsync - 1 */ LtdcHandle.Init.VerticalSync = 9; /* Accumulated horizontal back porch = Hsync + HBP - 1 */ LtdcHandle.Init.AccumulatedHBP = 53; /* Accumulated vertical back porch = Vsync + VBP - 1 */ LtdcHandle.Init.AccumulatedVBP = 11; /* Accumulated active width = Hsync + HBP + Active Width - 1 */ LtdcHandle.Init.AccumulatedActiveH = 283; /* Accumulated active height = Vsync + VBP + Active Height - 1 */ LtdcHandle.Init.AccumulatedActiveW = 533; /* Total height = Vsync + VBP + Active Height + VFP - 1 */ LtdcHandle.Init.TotalHeigh = 285; /* Total width = Hsync + HBP + Active Width + HFP - 1 */ LtdcHandle.Init.TotalWidth = 565; /* Configure R,G,B component values for LCD background color */ LtdcHandle.Init.Backcolor.Blue = 0; /* All black background color */ LtdcHandle.Init.Backcolor.Green = 0; LtdcHandle.Init.Backcolor.Red = 0; LtdcHandle.Instance = LTDC; /* Layer1 Configuration ------------------------------------------------------*/ /* Windowing configuration */ /* WindowX0 = Horizontal start WindowX1 = Horizontal stop WindowY0 = Vertical start WindowY1 = Vertical stop */ pLayerCfg.WindowX0 = 90; /* Translation by vector (90, 15) for display on LCD of layer 1 */ pLayerCfg.WindowX1 = 390; pLayerCfg.WindowY0 = 15; pLayerCfg.WindowY1 = 135; /* Pixel Format configuration*/ /* Layer 1 is the original image ARGB8888 of size 300x120 from Flash */ pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888; /* Start Address configuration : frame buffer is located at FLASH memory */ /* Display original buffer from Flash in ARGB8888 on LCD */ pLayerCfg.FBStartAdress = (uint32_t)&ARGB8888_300x120; /* Alpha constant (255 totally opaque) */ pLayerCfg.Alpha = 255; /* Default Color configuration (configure A,R,G,B component values) */ pLayerCfg.Alpha0 = 0; /* default color is fully transparent */ pLayerCfg.Backcolor.Blue = 0; pLayerCfg.Backcolor.Green = 0; pLayerCfg.Backcolor.Red = 0; /* Configure blending factors */ pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA; pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA; /* Configure the number of lines and number of pixels per line */ pLayerCfg.ImageWidth = LAYER_SIZE_X; pLayerCfg.ImageHeight = LAYER_SIZE_Y; /* Layer2 Configuration ------------------------------------------------------*/ /* Windowing configuration */ /* In this case all the active display area is used to display a picture */ pLayerCfg1.WindowX0 = 90; /* Translation by vector (90, 137) for display on LCD of layer 2 */ pLayerCfg1.WindowX1 = 390; pLayerCfg1.WindowY0 = 137; pLayerCfg1.WindowY1 = 257; /* Pixel Format configuration*/ pLayerCfg1.PixelFormat = LTDC_PIXEL_FORMAT_ARGB4444; /* Start Address configuration : frame buffer is located at FLASH memory */ /* This is the output buffer in ARGB4444 of the DMA2D with PFC of original buffer in ARGB8888 from Flash */ pLayerCfg1.FBStartAdress = (uint32_t)&aBufferResult; /* Alpha constant (255 totally opaque) */ pLayerCfg1.Alpha = 255; /* Default Color configuration (configure A,R,G,B component values) */ pLayerCfg1.Alpha0 = 0; /* fully transparent */ pLayerCfg1.Backcolor.Blue = 0; pLayerCfg1.Backcolor.Green = 0; pLayerCfg1.Backcolor.Red = 0; /* Configure blending factors */ pLayerCfg1.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA; pLayerCfg1.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA; /* Configure the number of lines and number of pixels per line */ pLayerCfg1.ImageWidth = LAYER_SIZE_X; pLayerCfg1.ImageHeight = LAYER_SIZE_Y; /* Configure the LTDC */ hal_status = HAL_LTDC_Init(&LtdcHandle); OnError_Handler(hal_status != HAL_OK); /* Assert display enable LCD_DISP pin */ HAL_GPIO_WritePin(GPIOI, GPIO_PIN_12, GPIO_PIN_SET); /* Assert backlight LCD_BL_CTRL pin */ HAL_GPIO_WritePin(GPIOK, GPIO_PIN_3, GPIO_PIN_SET); /* Configure the Background Layer : layer 0 of LTDC : display original image ARGB8888 300x120 */ hal_status = HAL_LTDC_ConfigLayer(&LtdcHandle, &pLayerCfg, 0); OnError_Handler(hal_status != HAL_OK); /* Configure the Foreground Layer : layer 1 of LTDC */ /* Which is DMA2D output image in ARGB4444 of size 300x120 */ hal_status = HAL_LTDC_ConfigLayer(&LtdcHandle, &pLayerCfg1, 1); OnError_Handler(hal_status != HAL_OK); }
/** * @brief Main program * @param None * @retval None */ int main(void) { blended_image_ready = 0; HAL_StatusTypeDef hal_status = HAL_OK; uint8_t lcd_status = LCD_OK; LcdResX = WVGA_RES_X; /* WVGA landscape */ LcdResY = WVGA_RES_Y; 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 */ 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_MemToMemWithLCD example", CENTER_MODE); HAL_Delay(100); /*##-2- DMA2D configuration ################################################*/ DMA2D_Config(); /*##-3- Start DMA2D transfer ###############################################*/ hal_status = HAL_DMA2D_Start_IT(&Dma2dHandle, (uint32_t)&ARGB4444_150x150, /* Source buffer in format ARGB4444 and size 150x150 */ (uint32_t)&aBufferResult, /* Destination buffer in format ARGB4444 and size 150x150 */ LAYER_SIZE_X, /* width in pixels */ LAYER_SIZE_Y); /* height in pixels */ 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*)&(aBufferResult[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) { uint8_t lcd_status = LCD_OK; /* This sample code displays a fixed image 800x480 on LCD KoD in */ /* orientation mode landscape and DSI mode video burst */ /* 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(); /* Initialize used LED1 and LED3 */ BSP_LED_Init(LED1); BSP_LED_Init(LED3); /* Configure user push-button */ BSP_PB_Init(BUTTON_WAKEUP, BUTTON_MODE_GPIO); /* Initialize the LCD DSI in Video Burst mode with LANDSCAPE orientation */ lcd_status = BSP_LCD_Init(); OnError_Handler(lcd_status != LCD_OK); /* Program a line event at line 0 */ HAL_LTDC_ProgramLineEvent(&hltdc_eval, 0); /* Copy texture to be displayed on LCD from Flash to SDRAM */ CopyPicture((uint32_t *)&candies_800x480_argb8888, (uint32_t *)LCD_FB_START_ADDRESS, 0, 0, BSP_LCD_GetXSize(), BSP_LCD_GetYSize()); BSP_LCD_LayerDefaultInit(LTDC_ACTIVE_LAYER_BACKGROUND, LCD_FB_START_ADDRESS); BSP_LCD_SelectLayer(LTDC_ACTIVE_LAYER_BACKGROUND); /* Prepare area to display frame number in the image displayed on LCD */ BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_FillRect(0, 400, BSP_LCD_GetXSize(), 80); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_SetBackColor(LCD_COLOR_BLUE); BSP_LCD_SetFont(&Font16); /* Display title */ BSP_LCD_DisplayStringAt(0, 420, (uint8_t *) "LCD_DSI_ULPM_Data example", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 440, (uint8_t *) "Press TAMPER button to enter ULPM", CENTER_MODE); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_SetBackColor(LCD_COLOR_BLUE); BSP_LCD_SetFont(&Font16); /* Infinite loop */ while (1) { /* Clear previous line */ BSP_LCD_ClearStringLine(460); /* New text to display */ sprintf(str_display, ">> Frame Nb : %lu", frameCnt); /* Print updated frame number */ BSP_LCD_DisplayStringAt(0, 460, (uint8_t *)str_display, CENTER_MODE); if (CheckForUserInput() > 0) { /* Clear previous line */ BSP_LCD_SetTextColor(LCD_COLOR_GREEN); BSP_LCD_ClearStringLine(440); BSP_LCD_DisplayStringAt(0, 440, (uint8_t *) "Enter ULPM - switch Off LCD 6 seconds", CENTER_MODE); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); /* Display Off with ULPM management Data lane only integrated */ BSP_LCD_DisplayOff(); HAL_Delay(1000); /* Switch Off bit LTDCEN */ __HAL_LTDC_DISABLE(&hltdc_eval); /* Enter ultra low power mode (data lane only integrated) */ HAL_DSI_EnterULPMData(&hdsi_eval); BSP_LED_On(LED1); HAL_Delay(6000); BSP_LCD_ClearStringLine(440); BSP_LCD_DisplayStringAt(0, 440, (uint8_t *) " Exited ULPM with success - Press To enter Again ULPM. ", CENTER_MODE); /* Exit ultra low power mode (data lane only integrated) */ HAL_DSI_ExitULPMData(&hdsi_eval); BSP_LED_Off(LED1); /* Switch On bit LTDCEN */ __HAL_LTDC_ENABLE(&hltdc_eval); /* Display On with ULPM exit Data lane only integrated */ BSP_LCD_DisplayOn(); } } }
/** * @brief Main program * @param None * @retval None */ int main(void) { uint8_t lcd_status = LCD_OK; mfx_toggle_led = 0; CameraResX = 320; CameraResY = 240; LcdResX = 800; /* WVGA landscape */ LcdResY = 480; offset_cam = 0; offset_lcd = 0; display_line_counter = 0; lcd_frame_buffer_ready = 0; start_the_camera_capture = 0; end_the_camera_capture = 0; /* 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(); /* Initialize MFX */ BSP_IO_Init(); /* Initialize used Leds */ BSP_LED_Init(LED1); BSP_LED_Init(LED3); /*##-1- Initialise the LCD #################################################*/ /* Initialize and start the LCD display in mode LCD_MODE_ADAPTED_COMMAND_TE_DSI_LINK * and orientation mode LCD_ORIENTATION_LANDSCAPE, using LCD_FRAME_BUFFER * as LCD frame buffer address. */ 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 *)"DCMI Snapshot example", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 460, (uint8_t *)"Initialize Camera", CENTER_MODE); /* Initialize the camera frame buffer 320x240 in RGB565 to a fixed grey pattern */ lcd_status = CameraFrameBufferRgb565_Init(CameraResX, CameraResY, 0x55555555); OnError_Handler(lcd_status != LCD_OK); /*##-2- Camera Initialization and start capture ############################*/ /* Initialize the Camera in QVGA mode */ BSP_CAMERA_Init(CAMERA_R320x240); /* Wait 1s to let auto-loops in the camera module converge and lead to correct exposure */ HAL_Delay(1000); /* Start the Camera Snapshot Capture */ BSP_CAMERA_SnapshotStart((uint8_t *)CAMERA_FRAME_BUFFER); /* Wait until LCD frame buffer is ready */ while(lcd_frame_buffer_ready == 0) {;} /* Stop the camera to avoid having the DMA2D work in parallel of Display */ /* which cause perturbation of LTDC */ BSP_CAMERA_Stop(); BSP_LCD_ClearStringLine(460); BSP_LCD_DisplayStringAt(0, 460, (uint8_t *)"Capture OK - Test End", CENTER_MODE); /* Notify Test OK */ BSP_LED_On(LED1); while (1) { if ( mfx_toggle_led == 1) { BSP_LED_Toggle(LED3); mfx_toggle_led = 0; } } }
/** * @brief Main program * @param None * @retval None */ int main(void) { uint8_t lcd_status = LCD_OK; /* 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(); BSP_IO_Init(); /* Initialise QSPI */ BSP_QSPI_Init(); BSP_QSPI_MemoryMappedMode(); /* Initialize the SDRAM */ BSP_SDRAM_Init(); /* Initialize the LCD */ lcd_status = LCD_Init(); OnError_Handler(lcd_status != LCD_OK); /* Initialize LTDC layer 0 iused for Hint */ LCD_LayertInit(0, LAYER0_ADDRESS); BSP_LCD_SelectLayer(0); /* Configure the User Button in GPIO Mode */ BSP_PB_Init(BUTTON_TAMPER, BUTTON_MODE_EXTI); /* Initialize the Touch Screen */ BSP_TS_Init(800, 480); /* Set active display window */ HAL_DSI_LongWrite(&hdsi_eval, 0, DSI_DCS_LONG_PKT_WRITE, 4, OTM8009A_CMD_CASET, pColLeft); HAL_DSI_LongWrite(&hdsi_eval, 0, DSI_DCS_LONG_PKT_WRITE, 4, OTM8009A_CMD_PASET, pPage); /* Update pitch : the draw is done on the whole physical X Size */ HAL_LTDC_SetPitch(&hltdc_eval, BSP_LCD_GetXSize(), 0); /* Show first image */ LL_CopyPicture((uint32_t *)image[ImageIndex], (uint32_t *)LAYER0_ADDRESS); valid_buffer = 1; active_area = LEFT_AREA; HAL_DSI_LongWrite(&hdsi_eval, 0, DSI_DCS_LONG_PKT_WRITE, 2, OTM8009A_CMD_WRTESCN, pSyncLeft); /* Infinite loop */ while (1) { BSP_TS_GetState(&TS_State); if(draw_method == HORIZONTAL_SLIDER) { LCD_DSI_HorizontalSlider(); } else { LCD_DSI_VerticalSlider(); } } }