STM32F769IDiscovery  1.00
uDANTE Audio Networking with STM32F7 DISCO board
stm32f7xx_hal_ltdc.c
Go to the documentation of this file.
1 
112 /* Includes ------------------------------------------------------------------*/
113 #include "stm32f7xx_hal.h"
114 
118 #if defined (STM32F746xx) || defined (STM32F756xx) || defined (STM32F767xx) || defined (STM32F769xx) || defined (STM32F777xx) || defined (STM32F779xx)
119 
125 #ifdef HAL_LTDC_MODULE_ENABLED
126 
127 /* Private typedef -----------------------------------------------------------*/
128 /* Private define ------------------------------------------------------------*/
129 /* Private macro -------------------------------------------------------------*/
130 /* Private variables ---------------------------------------------------------*/
131 /* Private function prototypes -----------------------------------------------*/
132 static void LTDC_SetConfig(LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgTypeDef *pLayerCfg, uint32_t LayerIdx);
133 /* Private functions ---------------------------------------------------------*/
134 
161 HAL_StatusTypeDef HAL_LTDC_Init(LTDC_HandleTypeDef *hltdc)
162 {
163  uint32_t tmp = 0, tmp1 = 0;
164 
165  /* Check the LTDC peripheral state */
166  if(hltdc == NULL)
167  {
168  return HAL_ERROR;
169  }
170 
171  /* Check function parameters */
172  assert_param(IS_LTDC_ALL_INSTANCE(hltdc->Instance));
173  assert_param(IS_LTDC_HSYNC(hltdc->Init.HorizontalSync));
174  assert_param(IS_LTDC_VSYNC(hltdc->Init.VerticalSync));
175  assert_param(IS_LTDC_AHBP(hltdc->Init.AccumulatedHBP));
176  assert_param(IS_LTDC_AVBP(hltdc->Init.AccumulatedVBP));
177  assert_param(IS_LTDC_AAH(hltdc->Init.AccumulatedActiveH));
178  assert_param(IS_LTDC_AAW(hltdc->Init.AccumulatedActiveW));
179  assert_param(IS_LTDC_TOTALH(hltdc->Init.TotalHeigh));
180  assert_param(IS_LTDC_TOTALW(hltdc->Init.TotalWidth));
181  assert_param(IS_LTDC_HSPOL(hltdc->Init.HSPolarity));
182  assert_param(IS_LTDC_VSPOL(hltdc->Init.VSPolarity));
183  assert_param(IS_LTDC_DEPOL(hltdc->Init.DEPolarity));
184  assert_param(IS_LTDC_PCPOL(hltdc->Init.PCPolarity));
185 
186  if(hltdc->State == HAL_LTDC_STATE_RESET)
187  {
188  /* Allocate lock resource and initialize it */
189  hltdc->Lock = HAL_UNLOCKED;
190  /* Init the low level hardware */
191  HAL_LTDC_MspInit(hltdc);
192  }
193 
194  /* Change LTDC peripheral state */
195  hltdc->State = HAL_LTDC_STATE_BUSY;
196 
197  /* Configures the HS, VS, DE and PC polarity */
198  hltdc->Instance->GCR &= ~(LTDC_GCR_HSPOL | LTDC_GCR_VSPOL | LTDC_GCR_DEPOL | LTDC_GCR_PCPOL);
199  hltdc->Instance->GCR |= (uint32_t)(hltdc->Init.HSPolarity | hltdc->Init.VSPolarity | \
200  hltdc->Init.DEPolarity | hltdc->Init.PCPolarity);
201 
202  /* Sets Synchronization size */
203  hltdc->Instance->SSCR &= ~(LTDC_SSCR_VSH | LTDC_SSCR_HSW);
204  tmp = (hltdc->Init.HorizontalSync << 16);
205  hltdc->Instance->SSCR |= (tmp | hltdc->Init.VerticalSync);
206 
207  /* Sets Accumulated Back porch */
208  hltdc->Instance->BPCR &= ~(LTDC_BPCR_AVBP | LTDC_BPCR_AHBP);
209  tmp = (hltdc->Init.AccumulatedHBP << 16);
210  hltdc->Instance->BPCR |= (tmp | hltdc->Init.AccumulatedVBP);
211 
212  /* Sets Accumulated Active Width */
213  hltdc->Instance->AWCR &= ~(LTDC_AWCR_AAH | LTDC_AWCR_AAW);
214  tmp = (hltdc->Init.AccumulatedActiveW << 16);
215  hltdc->Instance->AWCR |= (tmp | hltdc->Init.AccumulatedActiveH);
216 
217  /* Sets Total Width */
218  hltdc->Instance->TWCR &= ~(LTDC_TWCR_TOTALH | LTDC_TWCR_TOTALW);
219  tmp = (hltdc->Init.TotalWidth << 16);
220  hltdc->Instance->TWCR |= (tmp | hltdc->Init.TotalHeigh);
221 
222  /* Sets the background color value */
223  tmp = ((uint32_t)(hltdc->Init.Backcolor.Green) << 8);
224  tmp1 = ((uint32_t)(hltdc->Init.Backcolor.Red) << 16);
225  hltdc->Instance->BCCR &= ~(LTDC_BCCR_BCBLUE | LTDC_BCCR_BCGREEN | LTDC_BCCR_BCRED);
226  hltdc->Instance->BCCR |= (tmp1 | tmp | hltdc->Init.Backcolor.Blue);
227 
228  /* Enable the transfer Error interrupt */
229  __HAL_LTDC_ENABLE_IT(hltdc, LTDC_IT_TE);
230 
231  /* Enable the FIFO underrun interrupt */
232  __HAL_LTDC_ENABLE_IT(hltdc, LTDC_IT_FU);
233 
234  /* Enable LTDC by setting LTDCEN bit */
235  __HAL_LTDC_ENABLE(hltdc);
236 
237  /* Initialize the error code */
238  hltdc->ErrorCode = HAL_LTDC_ERROR_NONE;
239 
240  /* Initialize the LTDC state*/
241  hltdc->State = HAL_LTDC_STATE_READY;
242 
243  return HAL_OK;
244 }
245 
254 HAL_StatusTypeDef HAL_LTDC_DeInit(LTDC_HandleTypeDef *hltdc)
255 {
256  /* DeInit the low level hardware */
257  HAL_LTDC_MspDeInit(hltdc);
258 
259  /* Initialize the error code */
260  hltdc->ErrorCode = HAL_LTDC_ERROR_NONE;
261 
262  /* Initialize the LTDC state*/
263  hltdc->State = HAL_LTDC_STATE_RESET;
264 
265  /* Release Lock */
266  __HAL_UNLOCK(hltdc);
267 
268  return HAL_OK;
269 }
270 
277 __weak void HAL_LTDC_MspInit(LTDC_HandleTypeDef* hltdc)
278 {
279  /* Prevent unused argument(s) compilation warning */
280  UNUSED(hltdc);
281 
282  /* NOTE : This function Should not be modified, when the callback is needed,
283  the HAL_LTDC_MspInit could be implemented in the user file
284  */
285 }
286 
293 __weak void HAL_LTDC_MspDeInit(LTDC_HandleTypeDef* hltdc)
294 {
295  /* Prevent unused argument(s) compilation warning */
296  UNUSED(hltdc);
297 
298  /* NOTE : This function Should not be modified, when the callback is needed,
299  the HAL_LTDC_MspDeInit could be implemented in the user file
300  */
301 }
302 
326 void HAL_LTDC_IRQHandler(LTDC_HandleTypeDef *hltdc)
327 {
328  /* Transfer Error Interrupt management ***************************************/
329  if(__HAL_LTDC_GET_FLAG(hltdc, LTDC_FLAG_TE) != RESET)
330  {
331  if(__HAL_LTDC_GET_IT_SOURCE(hltdc, LTDC_IT_TE) != RESET)
332  {
333  /* Disable the transfer Error interrupt */
334  __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_TE);
335 
336  /* Clear the transfer error flag */
337  __HAL_LTDC_CLEAR_FLAG(hltdc, LTDC_FLAG_TE);
338 
339  /* Update error code */
340  hltdc->ErrorCode |= HAL_LTDC_ERROR_TE;
341 
342  /* Change LTDC state */
343  hltdc->State = HAL_LTDC_STATE_ERROR;
344 
345  /* Process unlocked */
346  __HAL_UNLOCK(hltdc);
347 
348  /* Transfer error Callback */
349  HAL_LTDC_ErrorCallback(hltdc);
350  }
351  }
352  /* FIFO underrun Interrupt management ***************************************/
353  if(__HAL_LTDC_GET_FLAG(hltdc, LTDC_FLAG_FU) != RESET)
354  {
355  if(__HAL_LTDC_GET_IT_SOURCE(hltdc, LTDC_IT_FU) != RESET)
356  {
357  /* Disable the FIFO underrun interrupt */
358  __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_FU);
359 
360  /* Clear the FIFO underrun flag */
361  __HAL_LTDC_CLEAR_FLAG(hltdc, LTDC_FLAG_FU);
362 
363  /* Update error code */
364  hltdc->ErrorCode |= HAL_LTDC_ERROR_FU;
365 
366  /* Change LTDC state */
367  hltdc->State = HAL_LTDC_STATE_ERROR;
368 
369  /* Process unlocked */
370  __HAL_UNLOCK(hltdc);
371 
372  /* Transfer error Callback */
373  HAL_LTDC_ErrorCallback(hltdc);
374  }
375  }
376  /* Line Interrupt management ************************************************/
377  if(__HAL_LTDC_GET_FLAG(hltdc, LTDC_FLAG_LI) != RESET)
378  {
379  if(__HAL_LTDC_GET_IT_SOURCE(hltdc, LTDC_IT_LI) != RESET)
380  {
381  /* Disable the Line interrupt */
382  __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_LI);
383 
384  /* Clear the Line interrupt flag */
385  __HAL_LTDC_CLEAR_FLAG(hltdc, LTDC_FLAG_LI);
386 
387  /* Change LTDC state */
388  hltdc->State = HAL_LTDC_STATE_READY;
389 
390  /* Process unlocked */
391  __HAL_UNLOCK(hltdc);
392 
393  /* Line interrupt Callback */
395  }
396  }
397  /* Register reload Interrupt management ***************************************/
398  if(__HAL_LTDC_GET_FLAG(hltdc, LTDC_FLAG_RR) != RESET)
399  {
400  if(__HAL_LTDC_GET_IT_SOURCE(hltdc, LTDC_IT_RR) != RESET)
401  {
402  /* Disable the register reload interrupt */
403  __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_RR);
404 
405  /* Clear the register reload flag */
406  __HAL_LTDC_CLEAR_FLAG(hltdc, LTDC_FLAG_RR);
407 
408  /* Change LTDC state */
409  hltdc->State = HAL_LTDC_STATE_READY;
410 
411  /* Process unlocked */
412  __HAL_UNLOCK(hltdc);
413 
414  /* Register reload interrupt Callback */
415  HAL_LTDC_ReloadEventCallback(hltdc);
416  }
417  }
418 }
419 
426 __weak void HAL_LTDC_ErrorCallback(LTDC_HandleTypeDef *hltdc)
427 {
428  /* Prevent unused argument(s) compilation warning */
429  UNUSED(hltdc);
430 
431  /* NOTE : This function Should not be modified, when the callback is needed,
432  the HAL_LTDC_ErrorCallback could be implemented in the user file
433  */
434 }
435 
442 __weak void HAL_LTDC_LineEvenCallback(LTDC_HandleTypeDef *hltdc)
443 {
444  /* Prevent unused argument(s) compilation warning */
445  UNUSED(hltdc);
446 
447  /* NOTE : This function Should not be modified, when the callback is needed,
448  the HAL_LTDC_LineEvenCallback could be implemented in the user file
449  */
450 }
451 
458 __weak void HAL_LTDC_ReloadEventCallback(LTDC_HandleTypeDef *hltdc)
459 {
460  /* Prevent unused argument(s) compilation warning */
461  UNUSED(hltdc);
462 
463  /* NOTE : This function Should not be modified, when the callback is needed,
464  the HAL_LTDC_ReloadEvenCallback could be implemented in the user file
465  */
466 }
467 
508 HAL_StatusTypeDef HAL_LTDC_ConfigLayer(LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgTypeDef *pLayerCfg, uint32_t LayerIdx)
509 {
510  /* Process locked */
511  __HAL_LOCK(hltdc);
512 
513  /* Change LTDC peripheral state */
514  hltdc->State = HAL_LTDC_STATE_BUSY;
515 
516  /* Check the parameters */
517  assert_param(IS_LTDC_LAYER(LayerIdx));
518  assert_param(IS_LTDC_PIXEL_FORMAT(pLayerCfg->PixelFormat));
519  assert_param(IS_LTDC_BLENDING_FACTOR1(pLayerCfg->BlendingFactor1));
520  assert_param(IS_LTDC_BLENDING_FACTOR2(pLayerCfg->BlendingFactor2));
521  assert_param(IS_LTDC_HCONFIGST(pLayerCfg->WindowX0));
522  assert_param(IS_LTDC_HCONFIGSP(pLayerCfg->WindowX1));
523  assert_param(IS_LTDC_VCONFIGST(pLayerCfg->WindowY0));
524  assert_param(IS_LTDC_VCONFIGSP(pLayerCfg->WindowY1));
525  assert_param(IS_LTDC_ALPHA(pLayerCfg->Alpha0));
526  assert_param(IS_LTDC_CFBLL(pLayerCfg->ImageWidth));
527  assert_param(IS_LTDC_CFBLNBR(pLayerCfg->ImageHeight));
528 
529  /* Copy new layer configuration into handle structure */
530  hltdc->LayerCfg[LayerIdx] = *pLayerCfg;
531 
532  /* Configure the LTDC Layer */
533  LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
534 
535  /* Sets the Reload type */
536  hltdc->Instance->SRCR = LTDC_SRCR_IMR;
537 
538  /* Initialize the LTDC state*/
539  hltdc->State = HAL_LTDC_STATE_READY;
540 
541  /* Process unlocked */
542  __HAL_UNLOCK(hltdc);
543 
544  return HAL_OK;
545 }
546 
557 HAL_StatusTypeDef HAL_LTDC_ConfigColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t RGBValue, uint32_t LayerIdx)
558 {
559  /* Process locked */
560  __HAL_LOCK(hltdc);
561 
562  /* Change LTDC peripheral state */
563  hltdc->State = HAL_LTDC_STATE_BUSY;
564 
565  /* Check the parameters */
566  assert_param(IS_LTDC_LAYER(LayerIdx));
567 
568  /* Configures the default color values */
569  LTDC_LAYER(hltdc, LayerIdx)->CKCR &= ~(LTDC_LxCKCR_CKBLUE | LTDC_LxCKCR_CKGREEN | LTDC_LxCKCR_CKRED);
570  LTDC_LAYER(hltdc, LayerIdx)->CKCR = RGBValue;
571 
572  /* Sets the Reload type */
573  hltdc->Instance->SRCR = LTDC_SRCR_IMR;
574 
575  /* Change the LTDC state*/
576  hltdc->State = HAL_LTDC_STATE_READY;
577 
578  /* Process unlocked */
579  __HAL_UNLOCK(hltdc);
580 
581  return HAL_OK;
582 }
583 
595 HAL_StatusTypeDef HAL_LTDC_ConfigCLUT(LTDC_HandleTypeDef *hltdc, uint32_t *pCLUT, uint32_t CLUTSize, uint32_t LayerIdx)
596 {
597  uint32_t tmp = 0;
598  uint32_t counter = 0;
599  uint32_t pcounter = 0;
600 
601  /* Process locked */
602  __HAL_LOCK(hltdc);
603 
604  /* Change LTDC peripheral state */
605  hltdc->State = HAL_LTDC_STATE_BUSY;
606 
607  /* Check the parameters */
608  assert_param(IS_LTDC_LAYER(LayerIdx));
609 
610  for(counter = 0; (counter < CLUTSize); counter++)
611  {
612  if(hltdc->LayerCfg[LayerIdx].PixelFormat == LTDC_PIXEL_FORMAT_AL44)
613  {
614  tmp = (((counter + 16*counter) << 24) | ((uint32_t)(*pCLUT) & 0xFF) | ((uint32_t)(*pCLUT) & 0xFF00) | ((uint32_t)(*pCLUT) & 0xFF0000));
615  }
616  else
617  {
618  tmp = ((counter << 24) | ((uint32_t)(*pCLUT) & 0xFF) | ((uint32_t)(*pCLUT) & 0xFF00) | ((uint32_t)(*pCLUT) & 0xFF0000));
619  }
620  pcounter = (uint32_t)pCLUT + sizeof(*pCLUT);
621  pCLUT = (uint32_t *)pcounter;
622 
623  /* Specifies the C-LUT address and RGB value */
624  LTDC_LAYER(hltdc, LayerIdx)->CLUTWR = tmp;
625  }
626 
627  /* Change the LTDC state*/
628  hltdc->State = HAL_LTDC_STATE_READY;
629 
630  /* Process unlocked */
631  __HAL_UNLOCK(hltdc);
632 
633  return HAL_OK;
634 }
635 
645 HAL_StatusTypeDef HAL_LTDC_EnableColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
646 {
647  /* Process locked */
648  __HAL_LOCK(hltdc);
649 
650  /* Change LTDC peripheral state */
651  hltdc->State = HAL_LTDC_STATE_BUSY;
652 
653  /* Check the parameters */
654  assert_param(IS_LTDC_LAYER(LayerIdx));
655 
656  /* Enable LTDC color keying by setting COLKEN bit */
657  LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_COLKEN;
658 
659  /* Sets the Reload type */
660  hltdc->Instance->SRCR = LTDC_SRCR_IMR;
661 
662  /* Change the LTDC state*/
663  hltdc->State = HAL_LTDC_STATE_READY;
664 
665  /* Process unlocked */
666  __HAL_UNLOCK(hltdc);
667 
668  return HAL_OK;
669 }
670 
680 HAL_StatusTypeDef HAL_LTDC_DisableColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
681 {
682  /* Process locked */
683  __HAL_LOCK(hltdc);
684 
685  /* Change LTDC peripheral state */
686  hltdc->State = HAL_LTDC_STATE_BUSY;
687 
688  /* Check the parameters */
689  assert_param(IS_LTDC_LAYER(LayerIdx));
690 
691  /* Disable LTDC color keying by setting COLKEN bit */
692  LTDC_LAYER(hltdc, LayerIdx)->CR &= ~(uint32_t)LTDC_LxCR_COLKEN;
693 
694  /* Sets the Reload type */
695  hltdc->Instance->SRCR = LTDC_SRCR_IMR;
696 
697  /* Change the LTDC state*/
698  hltdc->State = HAL_LTDC_STATE_READY;
699 
700  /* Process unlocked */
701  __HAL_UNLOCK(hltdc);
702 
703  return HAL_OK;
704 }
705 
715 HAL_StatusTypeDef HAL_LTDC_EnableCLUT(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
716 {
717 
718  /* Process locked */
719  __HAL_LOCK(hltdc);
720 
721  /* Change LTDC peripheral state */
722  hltdc->State = HAL_LTDC_STATE_BUSY;
723 
724  /* Check the parameters */
725  assert_param(IS_LTDC_LAYER(LayerIdx));
726 
727  /* Disable LTDC color lookup table by setting CLUTEN bit */
728  LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_CLUTEN;
729 
730  /* Sets the Reload type */
731  hltdc->Instance->SRCR = LTDC_SRCR_IMR;
732 
733  /* Change the LTDC state*/
734  hltdc->State = HAL_LTDC_STATE_READY;
735 
736  /* Process unlocked */
737  __HAL_UNLOCK(hltdc);
738 
739  return HAL_OK;
740 }
741 
751 HAL_StatusTypeDef HAL_LTDC_DisableCLUT(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
752 {
753 
754  /* Process locked */
755  __HAL_LOCK(hltdc);
756 
757  /* Change LTDC peripheral state */
758  hltdc->State = HAL_LTDC_STATE_BUSY;
759 
760  /* Check the parameters */
761  assert_param(IS_LTDC_LAYER(LayerIdx));
762 
763  /* Disable LTDC color lookup table by setting CLUTEN bit */
764  LTDC_LAYER(hltdc, LayerIdx)->CR &= ~(uint32_t)LTDC_LxCR_CLUTEN;
765 
766  /* Sets the Reload type */
767  hltdc->Instance->SRCR = LTDC_SRCR_IMR;
768 
769  /* Change the LTDC state*/
770  hltdc->State = HAL_LTDC_STATE_READY;
771 
772  /* Process unlocked */
773  __HAL_UNLOCK(hltdc);
774 
775  return HAL_OK;
776 }
777 
785 HAL_StatusTypeDef HAL_LTDC_EnableDither(LTDC_HandleTypeDef *hltdc)
786 {
787  /* Process locked */
788  __HAL_LOCK(hltdc);
789 
790  /* Change LTDC peripheral state */
791  hltdc->State = HAL_LTDC_STATE_BUSY;
792 
793  /* Enable Dither by setting DTEN bit */
794  LTDC->GCR |= (uint32_t)LTDC_GCR_DEN;
795 
796  /* Change the LTDC state*/
797  hltdc->State = HAL_LTDC_STATE_READY;
798 
799  /* Process unlocked */
800  __HAL_UNLOCK(hltdc);
801 
802  return HAL_OK;
803 }
804 
812 HAL_StatusTypeDef HAL_LTDC_DisableDither(LTDC_HandleTypeDef *hltdc)
813 {
814  /* Process locked */
815  __HAL_LOCK(hltdc);
816 
817  /* Change LTDC peripheral state */
818  hltdc->State = HAL_LTDC_STATE_BUSY;
819 
820  /* Disable Dither by setting DTEN bit */
821  LTDC->GCR &= ~(uint32_t)LTDC_GCR_DEN;
822 
823  /* Change the LTDC state*/
824  hltdc->State = HAL_LTDC_STATE_READY;
825 
826  /* Process unlocked */
827  __HAL_UNLOCK(hltdc);
828 
829  return HAL_OK;
830 }
831 
843 HAL_StatusTypeDef HAL_LTDC_SetWindowSize(LTDC_HandleTypeDef *hltdc, uint32_t XSize, uint32_t YSize, uint32_t LayerIdx)
844 {
845  LTDC_LayerCfgTypeDef *pLayerCfg;
846 
847  /* Process locked */
848  __HAL_LOCK(hltdc);
849 
850  /* Change LTDC peripheral state */
851  hltdc->State = HAL_LTDC_STATE_BUSY;
852 
853  /* Get layer configuration from handle structure */
854  pLayerCfg = &hltdc->LayerCfg[LayerIdx];
855 
856  /* Check the parameters (Layers parameters)*/
857  assert_param(IS_LTDC_LAYER(LayerIdx));
858  assert_param(IS_LTDC_HCONFIGST(pLayerCfg->WindowX0));
859  assert_param(IS_LTDC_HCONFIGSP(pLayerCfg->WindowX1));
860  assert_param(IS_LTDC_VCONFIGST(pLayerCfg->WindowY0));
861  assert_param(IS_LTDC_VCONFIGSP(pLayerCfg->WindowY1));
862  assert_param(IS_LTDC_CFBLL(XSize));
863  assert_param(IS_LTDC_CFBLNBR(YSize));
864 
865  /* update horizontal start/stop */
866  pLayerCfg->WindowX0 = 0;
867  pLayerCfg->WindowX1 = XSize + pLayerCfg->WindowX0;
868 
869  /* update vertical start/stop */
870  pLayerCfg->WindowY0 = 0;
871  pLayerCfg->WindowY1 = YSize + pLayerCfg->WindowY0;
872 
873  /* Reconfigures the color frame buffer pitch in byte */
874  pLayerCfg->ImageWidth = XSize;
875 
876  /* Reconfigures the frame buffer line number */
877  pLayerCfg->ImageHeight = YSize;
878 
879  /* Set LTDC parameters */
880  LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
881 
882  /* Sets the Reload type */
883  hltdc->Instance->SRCR = LTDC_SRCR_IMR;
884 
885  /* Change the LTDC state*/
886  hltdc->State = HAL_LTDC_STATE_READY;
887 
888  /* Process unlocked */
889  __HAL_UNLOCK(hltdc);
890 
891  return HAL_OK;
892 }
893 
905 HAL_StatusTypeDef HAL_LTDC_SetWindowPosition(LTDC_HandleTypeDef *hltdc, uint32_t X0, uint32_t Y0, uint32_t LayerIdx)
906 {
907  LTDC_LayerCfgTypeDef *pLayerCfg;
908 
909  /* Process locked */
910  __HAL_LOCK(hltdc);
911 
912  /* Change LTDC peripheral state */
913  hltdc->State = HAL_LTDC_STATE_BUSY;
914 
915  /* Get layer configuration from handle structure */
916  pLayerCfg = &hltdc->LayerCfg[LayerIdx];
917 
918  /* Check the parameters */
919  assert_param(IS_LTDC_LAYER(LayerIdx));
920  assert_param(IS_LTDC_HCONFIGST(pLayerCfg->WindowX0));
921  assert_param(IS_LTDC_HCONFIGSP(pLayerCfg->WindowX1));
922  assert_param(IS_LTDC_VCONFIGST(pLayerCfg->WindowY0));
923  assert_param(IS_LTDC_VCONFIGSP(pLayerCfg->WindowY1));
924 
925  /* update horizontal start/stop */
926  pLayerCfg->WindowX0 = X0;
927  pLayerCfg->WindowX1 = X0 + pLayerCfg->ImageWidth;
928 
929  /* update vertical start/stop */
930  pLayerCfg->WindowY0 = Y0;
931  pLayerCfg->WindowY1 = Y0 + pLayerCfg->ImageHeight;
932 
933  /* Set LTDC parameters */
934  LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
935 
936  /* Sets the Reload type */
937  hltdc->Instance->SRCR = LTDC_SRCR_IMR;
938 
939  /* Change the LTDC state*/
940  hltdc->State = HAL_LTDC_STATE_READY;
941 
942  /* Process unlocked */
943  __HAL_UNLOCK(hltdc);
944 
945  return HAL_OK;
946 }
947 
958 HAL_StatusTypeDef HAL_LTDC_SetPixelFormat(LTDC_HandleTypeDef *hltdc, uint32_t Pixelformat, uint32_t LayerIdx)
959 {
960  LTDC_LayerCfgTypeDef *pLayerCfg;
961 
962  /* Process locked */
963  __HAL_LOCK(hltdc);
964 
965  /* Change LTDC peripheral state */
966  hltdc->State = HAL_LTDC_STATE_BUSY;
967 
968  /* Check the parameters */
969  assert_param(IS_LTDC_LAYER(LayerIdx));
970  assert_param(IS_LTDC_PIXEL_FORMAT(Pixelformat));
971 
972  /* Get layer configuration from handle structure */
973  pLayerCfg = &hltdc->LayerCfg[LayerIdx];
974 
975  /* Reconfigure the pixel format */
976  pLayerCfg->PixelFormat = Pixelformat;
977 
978  /* Set LTDC parameters */
979  LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
980 
981  /* Sets the Reload type */
982  hltdc->Instance->SRCR = LTDC_SRCR_IMR;
983 
984  /* Change the LTDC state*/
985  hltdc->State = HAL_LTDC_STATE_READY;
986 
987  /* Process unlocked */
988  __HAL_UNLOCK(hltdc);
989 
990  return HAL_OK;
991 }
992 
1003 HAL_StatusTypeDef HAL_LTDC_SetAlpha(LTDC_HandleTypeDef *hltdc, uint32_t Alpha, uint32_t LayerIdx)
1004 {
1005  LTDC_LayerCfgTypeDef *pLayerCfg;
1006 
1007  /* Process locked */
1008  __HAL_LOCK(hltdc);
1009 
1010  /* Change LTDC peripheral state */
1011  hltdc->State = HAL_LTDC_STATE_BUSY;
1012 
1013  /* Check the parameters */
1014  assert_param(IS_LTDC_ALPHA(Alpha));
1015  assert_param(IS_LTDC_LAYER(LayerIdx));
1016 
1017  /* Get layer configuration from handle structure */
1018  pLayerCfg = &hltdc->LayerCfg[LayerIdx];
1019 
1020  /* Reconfigure the Alpha value */
1021  pLayerCfg->Alpha = Alpha;
1022 
1023  /* Set LTDC parameters */
1024  LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
1025 
1026  /* Sets the Reload type */
1027  hltdc->Instance->SRCR = LTDC_SRCR_IMR;
1028 
1029  /* Change the LTDC state*/
1030  hltdc->State = HAL_LTDC_STATE_READY;
1031 
1032  /* Process unlocked */
1033  __HAL_UNLOCK(hltdc);
1034 
1035  return HAL_OK;
1036 }
1047 HAL_StatusTypeDef HAL_LTDC_SetAddress(LTDC_HandleTypeDef *hltdc, uint32_t Address, uint32_t LayerIdx)
1048 {
1049  LTDC_LayerCfgTypeDef *pLayerCfg;
1050 
1051  /* Process locked */
1052  __HAL_LOCK(hltdc);
1053 
1054  /* Change LTDC peripheral state */
1055  hltdc->State = HAL_LTDC_STATE_BUSY;
1056 
1057  /* Check the parameters */
1058  assert_param(IS_LTDC_LAYER(LayerIdx));
1059 
1060  /* Get layer configuration from handle structure */
1061  pLayerCfg = &hltdc->LayerCfg[LayerIdx];
1062 
1063  /* Reconfigure the Address */
1064  pLayerCfg->FBStartAdress = Address;
1065 
1066  /* Set LTDC parameters */
1067  LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
1068 
1069  /* Sets the Reload type */
1070  hltdc->Instance->SRCR = LTDC_SRCR_IMR;
1071 
1072  /* Change the LTDC state*/
1073  hltdc->State = HAL_LTDC_STATE_READY;
1074 
1075  /* Process unlocked */
1076  __HAL_UNLOCK(hltdc);
1077 
1078  return HAL_OK;
1079 }
1080 
1094 HAL_StatusTypeDef HAL_LTDC_SetPitch(LTDC_HandleTypeDef *hltdc, uint32_t LinePitchInPixels, uint32_t LayerIdx)
1095 {
1096  uint32_t tmp = 0;
1097  uint32_t pitchUpdate = 0;
1098  uint32_t pixelFormat = 0;
1099 
1100  /* Process locked */
1101  __HAL_LOCK(hltdc);
1102 
1103  /* Change LTDC peripheral state */
1104  hltdc->State = HAL_LTDC_STATE_BUSY;
1105 
1106  /* Check the parameters */
1107  assert_param(IS_LTDC_LAYER(LayerIdx));
1108 
1109  /* get LayerIdx used pixel format */
1110  pixelFormat = hltdc->LayerCfg[LayerIdx].PixelFormat;
1111 
1112  if(pixelFormat == LTDC_PIXEL_FORMAT_ARGB8888)
1113  {
1114  tmp = 4;
1115  }
1116  else if (pixelFormat == LTDC_PIXEL_FORMAT_RGB888)
1117  {
1118  tmp = 3;
1119  }
1120  else if((pixelFormat == LTDC_PIXEL_FORMAT_ARGB4444) || \
1121  (pixelFormat == LTDC_PIXEL_FORMAT_RGB565) || \
1122  (pixelFormat == LTDC_PIXEL_FORMAT_ARGB1555) || \
1123  (pixelFormat == LTDC_PIXEL_FORMAT_AL88))
1124  {
1125  tmp = 2;
1126  }
1127  else
1128  {
1129  tmp = 1;
1130  }
1131 
1132  pitchUpdate = ((LinePitchInPixels * tmp) << 16);
1133 
1134  /* Clear previously set standard pitch */
1135  LTDC_LAYER(hltdc, LayerIdx)->CFBLR &= ~LTDC_LxCFBLR_CFBP;
1136 
1137  /* Sets the Reload type as immediate update of LTDC pitch configured above */
1138  LTDC->SRCR |= LTDC_SRCR_IMR;
1139 
1140  /* Set new line pitch value */
1141  LTDC_LAYER(hltdc, LayerIdx)->CFBLR |= pitchUpdate;
1142 
1143  /* Sets the Reload type as immediate update of LTDC pitch configured above */
1144  LTDC->SRCR |= LTDC_SRCR_IMR;
1145 
1146  /* Change the LTDC state*/
1147  hltdc->State = HAL_LTDC_STATE_READY;
1148 
1149  /* Process unlocked */
1150  __HAL_UNLOCK(hltdc);
1151 
1152  return HAL_OK;
1153 }
1154 
1162 HAL_StatusTypeDef HAL_LTDC_ProgramLineEvent(LTDC_HandleTypeDef *hltdc, uint32_t Line)
1163 {
1164  /* Process locked */
1165  __HAL_LOCK(hltdc);
1166 
1167  /* Change LTDC peripheral state */
1168  hltdc->State = HAL_LTDC_STATE_BUSY;
1169 
1170  /* Check the parameters */
1171  assert_param(IS_LTDC_LIPOS(Line));
1172 
1173  /* Enable the Line interrupt */
1174  __HAL_LTDC_ENABLE_IT(hltdc, LTDC_IT_LI);
1175 
1176  /* Sets the Line Interrupt position */
1177  LTDC->LIPCR = (uint32_t)Line;
1178 
1179  /* Change the LTDC state*/
1180  hltdc->State = HAL_LTDC_STATE_READY;
1181 
1182  /* Process unlocked */
1183  __HAL_UNLOCK(hltdc);
1184 
1185  return HAL_OK;
1186 }
1187 
1197 HAL_StatusTypeDef HAL_LTDC_Reload(LTDC_HandleTypeDef *hltdc, uint32_t ReloadType)
1198 {
1199  assert_param(IS_LTDC_RELAOD(ReloadType));
1200 
1201  /* Process locked */
1202  __HAL_LOCK(hltdc);
1203 
1204  /* Change LTDC peripheral state */
1205  hltdc->State = HAL_LTDC_STATE_BUSY;
1206 
1207  /* Enable the Reload interrupt */
1208  __HAL_LTDC_ENABLE_IT(hltdc, LTDC_IT_RR);
1209 
1210  /* Apply Reload type */
1211  hltdc->Instance->SRCR = ReloadType;
1212 
1213  /* Change the LTDC state*/
1214  hltdc->State = HAL_LTDC_STATE_READY;
1215 
1216  /* Process unlocked */
1217  __HAL_UNLOCK(hltdc);
1218 
1219  return HAL_OK;
1220 }
1221 
1235 HAL_StatusTypeDef HAL_LTDC_ConfigLayer_NoReload(LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgTypeDef *pLayerCfg, uint32_t LayerIdx)
1236 {
1237  /* Process locked */
1238  __HAL_LOCK(hltdc);
1239 
1240  /* Change LTDC peripheral state */
1241  hltdc->State = HAL_LTDC_STATE_BUSY;
1242 
1243  /* Check the parameters */
1244  assert_param(IS_LTDC_LAYER(LayerIdx));
1245  assert_param(IS_LTDC_PIXEL_FORMAT(pLayerCfg->PixelFormat));
1246  assert_param(IS_LTDC_BLENDING_FACTOR1(pLayerCfg->BlendingFactor1));
1247  assert_param(IS_LTDC_BLENDING_FACTOR2(pLayerCfg->BlendingFactor2));
1248  assert_param(IS_LTDC_HCONFIGST(pLayerCfg->WindowX0));
1249  assert_param(IS_LTDC_HCONFIGSP(pLayerCfg->WindowX1));
1250  assert_param(IS_LTDC_VCONFIGST(pLayerCfg->WindowY0));
1251  assert_param(IS_LTDC_VCONFIGSP(pLayerCfg->WindowY1));
1252  assert_param(IS_LTDC_ALPHA(pLayerCfg->Alpha0));
1253  assert_param(IS_LTDC_CFBLL(pLayerCfg->ImageWidth));
1254  assert_param(IS_LTDC_CFBLNBR(pLayerCfg->ImageHeight));
1255 
1256  /* Copy new layer configuration into handle structure */
1257  hltdc->LayerCfg[LayerIdx] = *pLayerCfg;
1258 
1259  /* Configure the LTDC Layer */
1260  LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
1261 
1262  /* Do not Sets the Reload */
1263 
1264  /* Initialize the LTDC state*/
1265  hltdc->State = HAL_LTDC_STATE_READY;
1266 
1267  /* Process unlocked */
1268  __HAL_UNLOCK(hltdc);
1269 
1270  return HAL_OK;
1271 }
1272 
1285 HAL_StatusTypeDef HAL_LTDC_SetWindowSize_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t XSize, uint32_t YSize, uint32_t LayerIdx)
1286 {
1287  LTDC_LayerCfgTypeDef *pLayerCfg;
1288 
1289  /* Process locked */
1290  __HAL_LOCK(hltdc);
1291 
1292  /* Change LTDC peripheral state */
1293  hltdc->State = HAL_LTDC_STATE_BUSY;
1294 
1295  /* Get layer configuration from handle structure */
1296  pLayerCfg = &hltdc->LayerCfg[LayerIdx];
1297 
1298  /* Check the parameters (Layers parameters)*/
1299  assert_param(IS_LTDC_LAYER(LayerIdx));
1300  assert_param(IS_LTDC_HCONFIGST(pLayerCfg->WindowX0));
1301  assert_param(IS_LTDC_HCONFIGSP(pLayerCfg->WindowX1));
1302  assert_param(IS_LTDC_VCONFIGST(pLayerCfg->WindowY0));
1303  assert_param(IS_LTDC_VCONFIGSP(pLayerCfg->WindowY1));
1304  assert_param(IS_LTDC_CFBLL(XSize));
1305  assert_param(IS_LTDC_CFBLNBR(YSize));
1306 
1307  /* update horizontal start/stop */
1308  pLayerCfg->WindowX0 = 0;
1309  pLayerCfg->WindowX1 = XSize + pLayerCfg->WindowX0;
1310 
1311  /* update vertical start/stop */
1312  pLayerCfg->WindowY0 = 0;
1313  pLayerCfg->WindowY1 = YSize + pLayerCfg->WindowY0;
1314 
1315  /* Reconfigures the color frame buffer pitch in byte */
1316  pLayerCfg->ImageWidth = XSize;
1317 
1318  /* Reconfigures the frame buffer line number */
1319  pLayerCfg->ImageHeight = YSize;
1320 
1321  /* Set LTDC parameters */
1322  LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
1323 
1324  /* Do not Sets the Reload */
1325 
1326  /* Change the LTDC state*/
1327  hltdc->State = HAL_LTDC_STATE_READY;
1328 
1329  /* Process unlocked */
1330  __HAL_UNLOCK(hltdc);
1331 
1332  return HAL_OK;
1333 }
1334 
1347 HAL_StatusTypeDef HAL_LTDC_SetWindowPosition_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t X0, uint32_t Y0, uint32_t LayerIdx)
1348 {
1349  LTDC_LayerCfgTypeDef *pLayerCfg;
1350 
1351  /* Process locked */
1352  __HAL_LOCK(hltdc);
1353 
1354  /* Change LTDC peripheral state */
1355  hltdc->State = HAL_LTDC_STATE_BUSY;
1356 
1357  /* Get layer configuration from handle structure */
1358  pLayerCfg = &hltdc->LayerCfg[LayerIdx];
1359 
1360  /* Check the parameters */
1361  assert_param(IS_LTDC_LAYER(LayerIdx));
1362  assert_param(IS_LTDC_HCONFIGST(pLayerCfg->WindowX0));
1363  assert_param(IS_LTDC_HCONFIGSP(pLayerCfg->WindowX1));
1364  assert_param(IS_LTDC_VCONFIGST(pLayerCfg->WindowY0));
1365  assert_param(IS_LTDC_VCONFIGSP(pLayerCfg->WindowY1));
1366 
1367  /* update horizontal start/stop */
1368  pLayerCfg->WindowX0 = X0;
1369  pLayerCfg->WindowX1 = X0 + pLayerCfg->ImageWidth;
1370 
1371  /* update vertical start/stop */
1372  pLayerCfg->WindowY0 = Y0;
1373  pLayerCfg->WindowY1 = Y0 + pLayerCfg->ImageHeight;
1374 
1375  /* Set LTDC parameters */
1376  LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
1377 
1378  /* Do not Sets the Reload */
1379 
1380  /* Change the LTDC state*/
1381  hltdc->State = HAL_LTDC_STATE_READY;
1382 
1383  /* Process unlocked */
1384  __HAL_UNLOCK(hltdc);
1385 
1386  return HAL_OK;
1387 }
1388 
1400 HAL_StatusTypeDef HAL_LTDC_SetPixelFormat_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t Pixelformat, uint32_t LayerIdx)
1401 {
1402  LTDC_LayerCfgTypeDef *pLayerCfg;
1403 
1404  /* Process locked */
1405  __HAL_LOCK(hltdc);
1406 
1407  /* Change LTDC peripheral state */
1408  hltdc->State = HAL_LTDC_STATE_BUSY;
1409 
1410  /* Check the parameters */
1411  assert_param(IS_LTDC_LAYER(LayerIdx));
1412  assert_param(IS_LTDC_PIXEL_FORMAT(Pixelformat));
1413 
1414  /* Get layer configuration from handle structure */
1415  pLayerCfg = &hltdc->LayerCfg[LayerIdx];
1416 
1417  /* Reconfigure the pixel format */
1418  pLayerCfg->PixelFormat = Pixelformat;
1419 
1420  /* Set LTDC parameters */
1421  LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
1422 
1423  /* Do not Sets the Reload */
1424 
1425  /* Change the LTDC state*/
1426  hltdc->State = HAL_LTDC_STATE_READY;
1427 
1428  /* Process unlocked */
1429  __HAL_UNLOCK(hltdc);
1430 
1431  return HAL_OK;
1432 }
1433 
1445 HAL_StatusTypeDef HAL_LTDC_SetAlpha_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t Alpha, uint32_t LayerIdx)
1446 {
1447  LTDC_LayerCfgTypeDef *pLayerCfg;
1448 
1449  /* Process locked */
1450  __HAL_LOCK(hltdc);
1451 
1452  /* Change LTDC peripheral state */
1453  hltdc->State = HAL_LTDC_STATE_BUSY;
1454 
1455  /* Check the parameters */
1456  assert_param(IS_LTDC_ALPHA(Alpha));
1457  assert_param(IS_LTDC_LAYER(LayerIdx));
1458 
1459  /* Get layer configuration from handle structure */
1460  pLayerCfg = &hltdc->LayerCfg[LayerIdx];
1461 
1462  /* Reconfigure the Alpha value */
1463  pLayerCfg->Alpha = Alpha;
1464 
1465  /* Set LTDC parameters */
1466  LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
1467 
1468  /* Do not Sets the Reload */
1469 
1470  /* Change the LTDC state*/
1471  hltdc->State = HAL_LTDC_STATE_READY;
1472 
1473  /* Process unlocked */
1474  __HAL_UNLOCK(hltdc);
1475 
1476  return HAL_OK;
1477 }
1478 
1490 HAL_StatusTypeDef HAL_LTDC_SetAddress_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t Address, uint32_t LayerIdx)
1491 {
1492  LTDC_LayerCfgTypeDef *pLayerCfg;
1493 
1494  /* Process locked */
1495  __HAL_LOCK(hltdc);
1496 
1497  /* Change LTDC peripheral state */
1498  hltdc->State = HAL_LTDC_STATE_BUSY;
1499 
1500  /* Check the parameters */
1501  assert_param(IS_LTDC_LAYER(LayerIdx));
1502 
1503  /* Get layer configuration from handle structure */
1504  pLayerCfg = &hltdc->LayerCfg[LayerIdx];
1505 
1506  /* Reconfigure the Address */
1507  pLayerCfg->FBStartAdress = Address;
1508 
1509  /* Set LTDC parameters */
1510  LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
1511 
1512  /* Do not Sets the Reload */
1513 
1514  /* Change the LTDC state*/
1515  hltdc->State = HAL_LTDC_STATE_READY;
1516 
1517  /* Process unlocked */
1518  __HAL_UNLOCK(hltdc);
1519 
1520  return HAL_OK;
1521 }
1522 
1537 HAL_StatusTypeDef HAL_LTDC_SetPitch_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t LinePitchInPixels, uint32_t LayerIdx)
1538 {
1539  uint32_t tmp = 0;
1540  uint32_t pitchUpdate = 0;
1541  uint32_t pixelFormat = 0;
1542 
1543  /* Process locked */
1544  __HAL_LOCK(hltdc);
1545 
1546  /* Change LTDC peripheral state */
1547  hltdc->State = HAL_LTDC_STATE_BUSY;
1548 
1549  /* Check the parameters */
1550  assert_param(IS_LTDC_LAYER(LayerIdx));
1551 
1552  /* get LayerIdx used pixel format */
1553  pixelFormat = hltdc->LayerCfg[LayerIdx].PixelFormat;
1554 
1555  if(pixelFormat == LTDC_PIXEL_FORMAT_ARGB8888)
1556  {
1557  tmp = 4;
1558  }
1559  else if (pixelFormat == LTDC_PIXEL_FORMAT_RGB888)
1560  {
1561  tmp = 3;
1562  }
1563  else if((pixelFormat == LTDC_PIXEL_FORMAT_ARGB4444) || \
1564  (pixelFormat == LTDC_PIXEL_FORMAT_RGB565) || \
1565  (pixelFormat == LTDC_PIXEL_FORMAT_ARGB1555) || \
1566  (pixelFormat == LTDC_PIXEL_FORMAT_AL88))
1567  {
1568  tmp = 2;
1569  }
1570  else
1571  {
1572  tmp = 1;
1573  }
1574 
1575  pitchUpdate = ((LinePitchInPixels * tmp) << 16);
1576 
1577  /* Clear previously set standard pitch */
1578  LTDC_LAYER(hltdc, LayerIdx)->CFBLR &= ~LTDC_LxCFBLR_CFBP;
1579 
1580  /* Set new line pitch value */
1581  LTDC_LAYER(hltdc, LayerIdx)->CFBLR |= pitchUpdate;
1582 
1583  /* Do not Sets the Reload */
1584 
1585  /* Change the LTDC state*/
1586  hltdc->State = HAL_LTDC_STATE_READY;
1587 
1588  /* Process unlocked */
1589  __HAL_UNLOCK(hltdc);
1590 
1591  return HAL_OK;
1592 }
1593 
1594 
1606 HAL_StatusTypeDef HAL_LTDC_ConfigColorKeying_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t RGBValue, uint32_t LayerIdx)
1607 {
1608  /* Process locked */
1609  __HAL_LOCK(hltdc);
1610 
1611  /* Change LTDC peripheral state */
1612  hltdc->State = HAL_LTDC_STATE_BUSY;
1613 
1614  /* Check the parameters */
1615  assert_param(IS_LTDC_LAYER(LayerIdx));
1616 
1617  /* Configures the default color values */
1618  LTDC_LAYER(hltdc, LayerIdx)->CKCR &= ~(LTDC_LxCKCR_CKBLUE | LTDC_LxCKCR_CKGREEN | LTDC_LxCKCR_CKRED);
1619  LTDC_LAYER(hltdc, LayerIdx)->CKCR = RGBValue;
1620 
1621  /* Do not Sets the Reload */
1622 
1623  /* Change the LTDC state*/
1624  hltdc->State = HAL_LTDC_STATE_READY;
1625 
1626  /* Process unlocked */
1627  __HAL_UNLOCK(hltdc);
1628 
1629  return HAL_OK;
1630 }
1631 
1642 HAL_StatusTypeDef HAL_LTDC_EnableColorKeying_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
1643 {
1644  /* Process locked */
1645  __HAL_LOCK(hltdc);
1646 
1647  /* Change LTDC peripheral state */
1648  hltdc->State = HAL_LTDC_STATE_BUSY;
1649 
1650  /* Check the parameters */
1651  assert_param(IS_LTDC_LAYER(LayerIdx));
1652 
1653  /* Enable LTDC color keying by setting COLKEN bit */
1654  LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_COLKEN;
1655 
1656  /* Do not Sets the Reload */
1657 
1658  /* Change the LTDC state*/
1659  hltdc->State = HAL_LTDC_STATE_READY;
1660 
1661  /* Process unlocked */
1662  __HAL_UNLOCK(hltdc);
1663 
1664  return HAL_OK;
1665 }
1666 
1677 HAL_StatusTypeDef HAL_LTDC_DisableColorKeying_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
1678 {
1679  /* Process locked */
1680  __HAL_LOCK(hltdc);
1681 
1682  /* Change LTDC peripheral state */
1683  hltdc->State = HAL_LTDC_STATE_BUSY;
1684 
1685  /* Check the parameters */
1686  assert_param(IS_LTDC_LAYER(LayerIdx));
1687 
1688  /* Disable LTDC color keying by setting COLKEN bit */
1689  LTDC_LAYER(hltdc, LayerIdx)->CR &= ~(uint32_t)LTDC_LxCR_COLKEN;
1690 
1691  /* Do not Sets the Reload */
1692 
1693  /* Change the LTDC state*/
1694  hltdc->State = HAL_LTDC_STATE_READY;
1695 
1696  /* Process unlocked */
1697  __HAL_UNLOCK(hltdc);
1698 
1699  return HAL_OK;
1700 }
1701 
1712 HAL_StatusTypeDef HAL_LTDC_EnableCLUT_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
1713 {
1714 
1715  /* Process locked */
1716  __HAL_LOCK(hltdc);
1717 
1718  /* Change LTDC peripheral state */
1719  hltdc->State = HAL_LTDC_STATE_BUSY;
1720 
1721  /* Check the parameters */
1722  assert_param(IS_LTDC_LAYER(LayerIdx));
1723 
1724  /* Disable LTDC color lookup table by setting CLUTEN bit */
1725  LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_CLUTEN;
1726 
1727  /* Do not Sets the Reload */
1728 
1729  /* Change the LTDC state*/
1730  hltdc->State = HAL_LTDC_STATE_READY;
1731 
1732  /* Process unlocked */
1733  __HAL_UNLOCK(hltdc);
1734 
1735  return HAL_OK;
1736 }
1737 
1748 HAL_StatusTypeDef HAL_LTDC_DisableCLUT_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
1749 {
1750 
1751  /* Process locked */
1752  __HAL_LOCK(hltdc);
1753 
1754  /* Change LTDC peripheral state */
1755  hltdc->State = HAL_LTDC_STATE_BUSY;
1756 
1757  /* Check the parameters */
1758  assert_param(IS_LTDC_LAYER(LayerIdx));
1759 
1760  /* Disable LTDC color lookup table by setting CLUTEN bit */
1761  LTDC_LAYER(hltdc, LayerIdx)->CR &= ~(uint32_t)LTDC_LxCR_CLUTEN;
1762 
1763  /* Do not Sets the Reload */
1764 
1765  /* Change the LTDC state*/
1766  hltdc->State = HAL_LTDC_STATE_READY;
1767 
1768  /* Process unlocked */
1769  __HAL_UNLOCK(hltdc);
1770 
1771  return HAL_OK;
1772 }
1773 
1800 HAL_LTDC_StateTypeDef HAL_LTDC_GetState(LTDC_HandleTypeDef *hltdc)
1801 {
1802  return hltdc->State;
1803 }
1804 
1811 uint32_t HAL_LTDC_GetError(LTDC_HandleTypeDef *hltdc)
1812 {
1813  return hltdc->ErrorCode;
1814 }
1815 
1829 static void LTDC_SetConfig(LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgTypeDef *pLayerCfg, uint32_t LayerIdx)
1830 {
1831  uint32_t tmp = 0;
1832  uint32_t tmp1 = 0;
1833  uint32_t tmp2 = 0;
1834 
1835  /* Configures the horizontal start and stop position */
1836  tmp = ((pLayerCfg->WindowX1 + ((hltdc->Instance->BPCR & LTDC_BPCR_AHBP) >> 16)) << 16);
1837  LTDC_LAYER(hltdc, LayerIdx)->WHPCR &= ~(LTDC_LxWHPCR_WHSTPOS | LTDC_LxWHPCR_WHSPPOS);
1838  LTDC_LAYER(hltdc, LayerIdx)->WHPCR = ((pLayerCfg->WindowX0 + ((hltdc->Instance->BPCR & LTDC_BPCR_AHBP) >> 16) + 1) | tmp);
1839 
1840  /* Configures the vertical start and stop position */
1841  tmp = ((pLayerCfg->WindowY1 + (hltdc->Instance->BPCR & LTDC_BPCR_AVBP)) << 16);
1842  LTDC_LAYER(hltdc, LayerIdx)->WVPCR &= ~(LTDC_LxWVPCR_WVSTPOS | LTDC_LxWVPCR_WVSPPOS);
1843  LTDC_LAYER(hltdc, LayerIdx)->WVPCR = ((pLayerCfg->WindowY0 + (hltdc->Instance->BPCR & LTDC_BPCR_AVBP) + 1) | tmp);
1844 
1845  /* Specifies the pixel format */
1846  LTDC_LAYER(hltdc, LayerIdx)->PFCR &= ~(LTDC_LxPFCR_PF);
1847  LTDC_LAYER(hltdc, LayerIdx)->PFCR = (pLayerCfg->PixelFormat);
1848 
1849  /* Configures the default color values */
1850  tmp = ((uint32_t)(pLayerCfg->Backcolor.Green) << 8);
1851  tmp1 = ((uint32_t)(pLayerCfg->Backcolor.Red) << 16);
1852  tmp2 = (pLayerCfg->Alpha0 << 24);
1853  LTDC_LAYER(hltdc, LayerIdx)->DCCR &= ~(LTDC_LxDCCR_DCBLUE | LTDC_LxDCCR_DCGREEN | LTDC_LxDCCR_DCRED | LTDC_LxDCCR_DCALPHA);
1854  LTDC_LAYER(hltdc, LayerIdx)->DCCR = (pLayerCfg->Backcolor.Blue | tmp | tmp1 | tmp2);
1855 
1856  /* Specifies the constant alpha value */
1857  LTDC_LAYER(hltdc, LayerIdx)->CACR &= ~(LTDC_LxCACR_CONSTA);
1858  LTDC_LAYER(hltdc, LayerIdx)->CACR = (pLayerCfg->Alpha);
1859 
1860  /* Specifies the blending factors */
1861  LTDC_LAYER(hltdc, LayerIdx)->BFCR &= ~(LTDC_LxBFCR_BF2 | LTDC_LxBFCR_BF1);
1862  LTDC_LAYER(hltdc, LayerIdx)->BFCR = (pLayerCfg->BlendingFactor1 | pLayerCfg->BlendingFactor2);
1863 
1864  /* Configures the color frame buffer start address */
1865  LTDC_LAYER(hltdc, LayerIdx)->CFBAR &= ~(LTDC_LxCFBAR_CFBADD);
1866  LTDC_LAYER(hltdc, LayerIdx)->CFBAR = (pLayerCfg->FBStartAdress);
1867 
1868  if(pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_ARGB8888)
1869  {
1870  tmp = 4;
1871  }
1872  else if (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_RGB888)
1873  {
1874  tmp = 3;
1875  }
1876  else if((pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_ARGB4444) || \
1877  (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_RGB565) || \
1878  (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_ARGB1555) || \
1879  (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_AL88))
1880  {
1881  tmp = 2;
1882  }
1883  else
1884  {
1885  tmp = 1;
1886  }
1887 
1888  /* Configures the color frame buffer pitch in byte */
1889  LTDC_LAYER(hltdc, LayerIdx)->CFBLR &= ~(LTDC_LxCFBLR_CFBLL | LTDC_LxCFBLR_CFBP);
1890  LTDC_LAYER(hltdc, LayerIdx)->CFBLR = (((pLayerCfg->ImageWidth * tmp) << 16) | (((pLayerCfg->WindowX1 - pLayerCfg->WindowX0) * tmp) + 3));
1891 
1892  /* Configures the frame buffer line number */
1893  LTDC_LAYER(hltdc, LayerIdx)->CFBLNR &= ~(LTDC_LxCFBLNR_CFBLNBR);
1894  LTDC_LAYER(hltdc, LayerIdx)->CFBLNR = (pLayerCfg->ImageHeight);
1895 
1896  /* Enable LTDC_Layer by setting LEN bit */
1897  LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_LEN;
1898 }
1899 
1904 #endif /* HAL_LTDC_MODULE_ENABLED */
1905 
1909 #endif /* STM32F746xx || STM32F756xx || STM32F767xx || STM32F769xx || STM32F777xx || STM32F779xx */
1910 
1915 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
#define LTDC_GCR_DEPOL
Definition: stm32f746xx.h:5043
#define LTDC_BCCR_BCGREEN
Definition: stm32f746xx.h:5058
#define LTDC
Definition: stm32f746xx.h:1365
#define LTDC_BCCR_BCRED
Definition: stm32f746xx.h:5059
#define assert_param(expr)
Include module&#39;s header file.
#define LTDC_LxDCCR_DCALPHA
Definition: stm32f746xx.h:5133
#define LTDC_TWCR_TOTALW
Definition: stm32f746xx.h:5033
#define LTDC_LxPFCR_PF
Definition: stm32f746xx.h:5122
#define __HAL_UNLOCK(__HANDLE__)
#define LTDC_LxDCCR_DCGREEN
Definition: stm32f746xx.h:5131
#define LTDC_LxWHPCR_WHSTPOS
Definition: stm32f746xx.h:5106
#define LTDC_LxDCCR_DCBLUE
Definition: stm32f746xx.h:5130
#define LTDC_AWCR_AAH
Definition: stm32f746xx.h:5027
#define LTDC_LxCR_CLUTEN
Definition: stm32f746xx.h:5102
#define LTDC_SSCR_VSH
Definition: stm32f746xx.h:5017
#define LTDC_GCR_DEN
Definition: stm32f746xx.h:5041
#define LTDC_BCCR_BCBLUE
Definition: stm32f746xx.h:5057
#define LTDC_AWCR_AAW
Definition: stm32f746xx.h:5028
#define LTDC_SRCR_IMR
Definition: stm32f746xx.h:5052
#define LTDC_GCR_HSPOL
Definition: stm32f746xx.h:5045
#define LTDC_LxCKCR_CKRED
Definition: stm32f746xx.h:5118
#define __HAL_LOCK(__HANDLE__)
#define LTDC_BPCR_AVBP
Definition: stm32f746xx.h:5022
#define NULL
Definition: usbd_def.h:53
#define LTDC_SSCR_HSW
Definition: stm32f746xx.h:5018
#define LTDC_LxCACR_CONSTA
Definition: stm32f746xx.h:5126
This file contains all the functions prototypes for the HAL module driver.
#define LTDC_LxCKCR_CKGREEN
Definition: stm32f746xx.h:5117
#define LTDC_LxCR_COLKEN
Definition: stm32f746xx.h:5101
void HAL_LTDC_LineEvenCallback(LTDC_HandleTypeDef *hltdc_eval)
Line Event callback.
Definition: LCDConf.c:738
#define LTDC_BPCR_AHBP
Definition: stm32f746xx.h:5023
#define UNUSED(x)
#define LTDC_GCR_VSPOL
Definition: stm32f746xx.h:5044
#define IS_LTDC_ALL_INSTANCE(__INSTANCE__)
Definition: stm32f746xx.h:9075
#define LTDC_LxCKCR_CKBLUE
Definition: stm32f746xx.h:5116
#define LTDC_LxCR_LEN
Definition: stm32f746xx.h:5100
#define LTDC_LxCFBLNR_CFBLNBR
Definition: stm32f746xx.h:5151
#define LTDC_LxDCCR_DCRED
Definition: stm32f746xx.h:5132
#define LTDC_LxCFBLR_CFBP
Definition: stm32f746xx.h:5147
#define LTDC_LxCFBLR_CFBLL
Definition: stm32f746xx.h:5146
#define LTDC_LxWHPCR_WHSPPOS
Definition: stm32f746xx.h:5107
#define LTDC_LxBFCR_BF1
Definition: stm32f746xx.h:5138
#define LTDC_LxWVPCR_WVSTPOS
Definition: stm32f746xx.h:5111
#define LTDC_LxBFCR_BF2
Definition: stm32f746xx.h:5137
#define LTDC_TWCR_TOTALH
Definition: stm32f746xx.h:5032
#define LTDC_GCR_PCPOL
Definition: stm32f746xx.h:5042
HAL_StatusTypeDef
HAL Status structures definition.
#define LTDC_LxCFBAR_CFBADD
Definition: stm32f746xx.h:5142
#define LTDC_LxWVPCR_WVSPPOS
Definition: stm32f746xx.h:5112