/** * @brief Line Event callback. * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains * the configuration information for the LTDC. * @retval None */ void HAL_LTDC_LineEventCallback(LTDC_HandleTypeDef *hltdc) { /* Increment frame count */ frameCnt++; HAL_LTDC_ProgramLineEvent(hltdc, 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 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); } } }
/** * @brief Line Event callback. * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains * the configuration information for the LTDC. * @retval None */ void HAL_LTDC_LineEventCallback(LTDC_HandleTypeDef *hltdc) { if(pend_buffer >= 0) { LTDC_LAYER(hltdc, 0)->CFBAR = ((uint32_t)Buffers[pend_buffer]); __HAL_LTDC_RELOAD_CONFIG(hltdc); front_buffer = pend_buffer; pend_buffer = -1; } HAL_LTDC_ProgramLineEvent(hltdc, 0); }
/** * @brief Line Event callback. * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains * the configuration information for the specified LTDC. * @retval None */ void HAL_LTDC_LineEvenCallback(LTDC_HandleTypeDef *hltdc) { if(Pending == 1) { /* reconfigure the layer1 position */ HAL_LTDC_SetWindowPosition(&LtdcHandle, Xpos1, Ypos1, 0); /* reconfigure the layer2 position */ HAL_LTDC_SetWindowPosition(&LtdcHandle, Xpos2, Ypos2, 1); Pending = 0; } /* Reconfigure line event */ HAL_LTDC_ProgramLineEvent(hltdc, 0); }
/** * @brief Main program * @param None * @retval None */ int main(void) { uint32_t index = 0; /* 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 the system clock to 180 MHz */ SystemClock_Config(); /* Configure LED3 */ BSP_LED_Init(LED3); /*##-1- LCD Configuration ##################################################*/ /* Configure 2 layers w/ Blending */ LCD_Config(); /*##-2- Configure line event ###############################################*/ HAL_LTDC_ProgramLineEvent(&LtdcHandle, 0); /* Infinite loop */ while (1) { for (index = 0; index < 41; index++) { /* calculate new picture position */ PicturesPosition(&Xpos1, &Ypos1, &Xpos2, &Ypos2, (index+1)); HAL_Delay(50); } HAL_Delay(500); for (index = 0; index < 41; index++) { /* calculate new picture position */ PicturesPosition(&Xpos2, &Ypos2, &Xpos1, &Ypos1, (index+1)); HAL_Delay(50); } HAL_Delay(500); } }
/** * @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(); } } }