stm32h7xx_hal_ltdc.c
Go to the documentation of this file.
1 
162 /* Includes ------------------------------------------------------------------*/
163 #include "stm32h7xx_hal.h"
164 
169 #ifdef HAL_LTDC_MODULE_ENABLED
170 
171 #if defined (LTDC)
172 
179 /* Private typedef -----------------------------------------------------------*/
180 /* Private define ------------------------------------------------------------*/
181 /* Private macro -------------------------------------------------------------*/
182 /* Private variables ---------------------------------------------------------*/
183 /* Private function prototypes -----------------------------------------------*/
184 static void LTDC_SetConfig(LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgTypeDef *pLayerCfg, uint32_t LayerIdx);
185 /* Private functions ---------------------------------------------------------*/
186 
212 HAL_StatusTypeDef HAL_LTDC_Init(LTDC_HandleTypeDef *hltdc)
213 {
214  uint32_t tmp, tmp1;
215 
216  /* Check the LTDC peripheral state */
217  if (hltdc == NULL)
218  {
219  return HAL_ERROR;
220  }
221 
222  /* Check function parameters */
223  assert_param(IS_LTDC_ALL_INSTANCE(hltdc->Instance));
224  assert_param(IS_LTDC_HSYNC(hltdc->Init.HorizontalSync));
225  assert_param(IS_LTDC_VSYNC(hltdc->Init.VerticalSync));
226  assert_param(IS_LTDC_AHBP(hltdc->Init.AccumulatedHBP));
227  assert_param(IS_LTDC_AVBP(hltdc->Init.AccumulatedVBP));
228  assert_param(IS_LTDC_AAH(hltdc->Init.AccumulatedActiveH));
229  assert_param(IS_LTDC_AAW(hltdc->Init.AccumulatedActiveW));
230  assert_param(IS_LTDC_TOTALH(hltdc->Init.TotalHeigh));
231  assert_param(IS_LTDC_TOTALW(hltdc->Init.TotalWidth));
232  assert_param(IS_LTDC_HSPOL(hltdc->Init.HSPolarity));
233  assert_param(IS_LTDC_VSPOL(hltdc->Init.VSPolarity));
234  assert_param(IS_LTDC_DEPOL(hltdc->Init.DEPolarity));
235  assert_param(IS_LTDC_PCPOL(hltdc->Init.PCPolarity));
236 
237 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
238  if (hltdc->State == HAL_LTDC_STATE_RESET)
239  {
240  /* Allocate lock resource and initialize it */
241  hltdc->Lock = HAL_UNLOCKED;
242 
243  /* Reset the LTDC callback to the legacy weak callbacks */
244  hltdc->LineEventCallback = HAL_LTDC_LineEventCallback; /* Legacy weak LineEventCallback */
245  hltdc->ReloadEventCallback = HAL_LTDC_ReloadEventCallback; /* Legacy weak ReloadEventCallback */
246  hltdc->ErrorCallback = HAL_LTDC_ErrorCallback; /* Legacy weak ErrorCallback */
247 
248  if (hltdc->MspInitCallback == NULL)
249  {
250  hltdc->MspInitCallback = HAL_LTDC_MspInit;
251  }
252  /* Init the low level hardware */
253  hltdc->MspInitCallback(hltdc);
254  }
255 #else
256  if (hltdc->State == HAL_LTDC_STATE_RESET)
257  {
258  /* Allocate lock resource and initialize it */
259  hltdc->Lock = HAL_UNLOCKED;
260  /* Init the low level hardware */
261  HAL_LTDC_MspInit(hltdc);
262  }
263 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
264 
265  /* Change LTDC peripheral state */
266  hltdc->State = HAL_LTDC_STATE_BUSY;
267 
268  /* Configure the HS, VS, DE and PC polarity */
269  hltdc->Instance->GCR &= ~(LTDC_GCR_HSPOL | LTDC_GCR_VSPOL | LTDC_GCR_DEPOL | LTDC_GCR_PCPOL);
270  hltdc->Instance->GCR |= (uint32_t)(hltdc->Init.HSPolarity | hltdc->Init.VSPolarity | \
271  hltdc->Init.DEPolarity | hltdc->Init.PCPolarity);
272 
273  /* Set Synchronization size */
274  hltdc->Instance->SSCR &= ~(LTDC_SSCR_VSH | LTDC_SSCR_HSW);
275  tmp = (hltdc->Init.HorizontalSync << 16U);
276  hltdc->Instance->SSCR |= (tmp | hltdc->Init.VerticalSync);
277 
278  /* Set Accumulated Back porch */
279  hltdc->Instance->BPCR &= ~(LTDC_BPCR_AVBP | LTDC_BPCR_AHBP);
280  tmp = (hltdc->Init.AccumulatedHBP << 16U);
281  hltdc->Instance->BPCR |= (tmp | hltdc->Init.AccumulatedVBP);
282 
283  /* Set Accumulated Active Width */
284  hltdc->Instance->AWCR &= ~(LTDC_AWCR_AAH | LTDC_AWCR_AAW);
285  tmp = (hltdc->Init.AccumulatedActiveW << 16U);
286  hltdc->Instance->AWCR |= (tmp | hltdc->Init.AccumulatedActiveH);
287 
288  /* Set Total Width */
289  hltdc->Instance->TWCR &= ~(LTDC_TWCR_TOTALH | LTDC_TWCR_TOTALW);
290  tmp = (hltdc->Init.TotalWidth << 16U);
291  hltdc->Instance->TWCR |= (tmp | hltdc->Init.TotalHeigh);
292 
293  /* Set the background color value */
294  tmp = ((uint32_t)(hltdc->Init.Backcolor.Green) << 8U);
295  tmp1 = ((uint32_t)(hltdc->Init.Backcolor.Red) << 16U);
296  hltdc->Instance->BCCR &= ~(LTDC_BCCR_BCBLUE | LTDC_BCCR_BCGREEN | LTDC_BCCR_BCRED);
297  hltdc->Instance->BCCR |= (tmp1 | tmp | hltdc->Init.Backcolor.Blue);
298 
299  /* Enable the Transfer Error and FIFO underrun interrupts */
300  __HAL_LTDC_ENABLE_IT(hltdc, LTDC_IT_TE | LTDC_IT_FU);
301 
302  /* Enable LTDC by setting LTDCEN bit */
303  __HAL_LTDC_ENABLE(hltdc);
304 
305  /* Initialize the error code */
306  hltdc->ErrorCode = HAL_LTDC_ERROR_NONE;
307 
308  /* Initialize the LTDC state*/
309  hltdc->State = HAL_LTDC_STATE_READY;
310 
311  return HAL_OK;
312 }
313 
321 HAL_StatusTypeDef HAL_LTDC_DeInit(LTDC_HandleTypeDef *hltdc)
322 {
323 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
324  if (hltdc->MspDeInitCallback == NULL)
325  {
326  hltdc->MspDeInitCallback = HAL_LTDC_MspDeInit;
327  }
328  /* DeInit the low level hardware */
329  hltdc->MspDeInitCallback(hltdc);
330 #else
331  /* DeInit the low level hardware */
332  HAL_LTDC_MspDeInit(hltdc);
333 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
334 
335  /* Initialize the error code */
336  hltdc->ErrorCode = HAL_LTDC_ERROR_NONE;
337 
338  /* Initialize the LTDC state*/
339  hltdc->State = HAL_LTDC_STATE_RESET;
340 
341  /* Release Lock */
342  __HAL_UNLOCK(hltdc);
343 
344  return HAL_OK;
345 }
346 
353 __weak void HAL_LTDC_MspInit(LTDC_HandleTypeDef *hltdc)
354 {
355  /* Prevent unused argument(s) compilation warning */
356  UNUSED(hltdc);
357 
358  /* NOTE : This function should not be modified, when the callback is needed,
359  the HAL_LTDC_MspInit could be implemented in the user file
360  */
361 }
362 
369 __weak void HAL_LTDC_MspDeInit(LTDC_HandleTypeDef *hltdc)
370 {
371  /* Prevent unused argument(s) compilation warning */
372  UNUSED(hltdc);
373 
374  /* NOTE : This function should not be modified, when the callback is needed,
375  the HAL_LTDC_MspDeInit could be implemented in the user file
376  */
377 }
378 
379 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
380 
394 HAL_StatusTypeDef HAL_LTDC_RegisterCallback(LTDC_HandleTypeDef *hltdc, HAL_LTDC_CallbackIDTypeDef CallbackID, pLTDC_CallbackTypeDef pCallback)
395 {
396  HAL_StatusTypeDef status = HAL_OK;
397 
398  if (pCallback == NULL)
399  {
400  /* Update the error code */
401  hltdc->ErrorCode |= HAL_LTDC_ERROR_INVALID_CALLBACK;
402 
403  return HAL_ERROR;
404  }
405  /* Process locked */
406  __HAL_LOCK(hltdc);
407 
408  if (hltdc->State == HAL_LTDC_STATE_READY)
409  {
410  switch (CallbackID)
411  {
412  case HAL_LTDC_LINE_EVENT_CB_ID :
413  hltdc->LineEventCallback = pCallback;
414  break;
415 
416  case HAL_LTDC_RELOAD_EVENT_CB_ID :
417  hltdc->ReloadEventCallback = pCallback;
418  break;
419 
420  case HAL_LTDC_ERROR_CB_ID :
421  hltdc->ErrorCallback = pCallback;
422  break;
423 
424  case HAL_LTDC_MSPINIT_CB_ID :
425  hltdc->MspInitCallback = pCallback;
426  break;
427 
428  case HAL_LTDC_MSPDEINIT_CB_ID :
429  hltdc->MspDeInitCallback = pCallback;
430  break;
431 
432  default :
433  /* Update the error code */
434  hltdc->ErrorCode |= HAL_LTDC_ERROR_INVALID_CALLBACK;
435  /* Return error status */
436  status = HAL_ERROR;
437  break;
438  }
439  }
440  else if (hltdc->State == HAL_LTDC_STATE_RESET)
441  {
442  switch (CallbackID)
443  {
444  case HAL_LTDC_MSPINIT_CB_ID :
445  hltdc->MspInitCallback = pCallback;
446  break;
447 
448  case HAL_LTDC_MSPDEINIT_CB_ID :
449  hltdc->MspDeInitCallback = pCallback;
450  break;
451 
452  default :
453  /* Update the error code */
454  hltdc->ErrorCode |= HAL_LTDC_ERROR_INVALID_CALLBACK;
455  /* Return error status */
456  status = HAL_ERROR;
457  break;
458  }
459  }
460  else
461  {
462  /* Update the error code */
463  hltdc->ErrorCode |= HAL_LTDC_ERROR_INVALID_CALLBACK;
464  /* Return error status */
465  status = HAL_ERROR;
466  }
467 
468  /* Release Lock */
469  __HAL_UNLOCK(hltdc);
470 
471  return status;
472 }
473 
487 HAL_StatusTypeDef HAL_LTDC_UnRegisterCallback(LTDC_HandleTypeDef *hltdc, HAL_LTDC_CallbackIDTypeDef CallbackID)
488 {
489  HAL_StatusTypeDef status = HAL_OK;
490 
491  /* Process locked */
492  __HAL_LOCK(hltdc);
493 
494  if (hltdc->State == HAL_LTDC_STATE_READY)
495  {
496  switch (CallbackID)
497  {
498  case HAL_LTDC_LINE_EVENT_CB_ID :
499  hltdc->LineEventCallback = HAL_LTDC_LineEventCallback; /* Legacy weak LineEventCallback */
500  break;
501 
502  case HAL_LTDC_RELOAD_EVENT_CB_ID :
503  hltdc->ReloadEventCallback = HAL_LTDC_ReloadEventCallback; /* Legacy weak ReloadEventCallback */
504  break;
505 
506  case HAL_LTDC_ERROR_CB_ID :
507  hltdc->ErrorCallback = HAL_LTDC_ErrorCallback; /* Legacy weak ErrorCallback */
508  break;
509 
510  case HAL_LTDC_MSPINIT_CB_ID :
511  hltdc->MspInitCallback = HAL_LTDC_MspInit; /* Legcay weak MspInit Callback */
512  break;
513 
514  case HAL_LTDC_MSPDEINIT_CB_ID :
515  hltdc->MspDeInitCallback = HAL_LTDC_MspDeInit; /* Legcay weak MspDeInit Callback */
516  break;
517 
518  default :
519  /* Update the error code */
520  hltdc->ErrorCode |= HAL_LTDC_ERROR_INVALID_CALLBACK;
521  /* Return error status */
522  status = HAL_ERROR;
523  break;
524  }
525  }
526  else if (hltdc->State == HAL_LTDC_STATE_RESET)
527  {
528  switch (CallbackID)
529  {
530  case HAL_LTDC_MSPINIT_CB_ID :
531  hltdc->MspInitCallback = HAL_LTDC_MspInit; /* Legcay weak MspInit Callback */
532  break;
533 
534  case HAL_LTDC_MSPDEINIT_CB_ID :
535  hltdc->MspDeInitCallback = HAL_LTDC_MspDeInit; /* Legcay weak MspDeInit Callback */
536  break;
537 
538  default :
539  /* Update the error code */
540  hltdc->ErrorCode |= HAL_LTDC_ERROR_INVALID_CALLBACK;
541  /* Return error status */
542  status = HAL_ERROR;
543  break;
544  }
545  }
546  else
547  {
548  /* Update the error code */
549  hltdc->ErrorCode |= HAL_LTDC_ERROR_INVALID_CALLBACK;
550  /* Return error status */
551  status = HAL_ERROR;
552  }
553 
554  /* Release Lock */
555  __HAL_UNLOCK(hltdc);
556 
557  return status;
558 }
559 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
560 
584 void HAL_LTDC_IRQHandler(LTDC_HandleTypeDef *hltdc)
585 {
586  uint32_t isrflags = READ_REG(hltdc->Instance->ISR);
587  uint32_t itsources = READ_REG(hltdc->Instance->IER);
588 
589  /* Transfer Error Interrupt management ***************************************/
590  if (((isrflags & LTDC_ISR_TERRIF) != 0U) && ((itsources & LTDC_IER_TERRIE) != 0U))
591  {
592  /* Disable the transfer Error interrupt */
593  __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_TE);
594 
595  /* Clear the transfer error flag */
596  __HAL_LTDC_CLEAR_FLAG(hltdc, LTDC_FLAG_TE);
597 
598  /* Update error code */
599  hltdc->ErrorCode |= HAL_LTDC_ERROR_TE;
600 
601  /* Change LTDC state */
602  hltdc->State = HAL_LTDC_STATE_ERROR;
603 
604  /* Process unlocked */
605  __HAL_UNLOCK(hltdc);
606 
607  /* Transfer error Callback */
608 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
609  /*Call registered error callback*/
610  hltdc->ErrorCallback(hltdc);
611 #else
612  /* Call legacy error callback*/
613  HAL_LTDC_ErrorCallback(hltdc);
614 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
615  }
616 
617  /* FIFO underrun Interrupt management ***************************************/
618  if (((isrflags & LTDC_ISR_FUIF) != 0U) && ((itsources & LTDC_IER_FUIE) != 0U))
619  {
620  /* Disable the FIFO underrun interrupt */
621  __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_FU);
622 
623  /* Clear the FIFO underrun flag */
624  __HAL_LTDC_CLEAR_FLAG(hltdc, LTDC_FLAG_FU);
625 
626  /* Update error code */
627  hltdc->ErrorCode |= HAL_LTDC_ERROR_FU;
628 
629  /* Change LTDC state */
630  hltdc->State = HAL_LTDC_STATE_ERROR;
631 
632  /* Process unlocked */
633  __HAL_UNLOCK(hltdc);
634 
635  /* Transfer error Callback */
636 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
637  /*Call registered error callback*/
638  hltdc->ErrorCallback(hltdc);
639 #else
640  /* Call legacy error callback*/
641  HAL_LTDC_ErrorCallback(hltdc);
642 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
643  }
644 
645  /* Line Interrupt management ************************************************/
646  if (((isrflags & LTDC_ISR_LIF) != 0U) && ((itsources & LTDC_IER_LIE) != 0U))
647  {
648  /* Disable the Line interrupt */
649  __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_LI);
650 
651  /* Clear the Line interrupt flag */
652  __HAL_LTDC_CLEAR_FLAG(hltdc, LTDC_FLAG_LI);
653 
654  /* Change LTDC state */
655  hltdc->State = HAL_LTDC_STATE_READY;
656 
657  /* Process unlocked */
658  __HAL_UNLOCK(hltdc);
659 
660  /* Line interrupt Callback */
661 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
662  /*Call registered Line Event callback */
663  hltdc->LineEventCallback(hltdc);
664 #else
665  /*Call Legacy Line Event callback */
666  HAL_LTDC_LineEventCallback(hltdc);
667 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
668  }
669 
670  /* Register reload Interrupt management ***************************************/
671  if (((isrflags & LTDC_ISR_RRIF) != 0U) && ((itsources & LTDC_IER_RRIE) != 0U))
672  {
673  /* Disable the register reload interrupt */
674  __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_RR);
675 
676  /* Clear the register reload flag */
677  __HAL_LTDC_CLEAR_FLAG(hltdc, LTDC_FLAG_RR);
678 
679  /* Change LTDC state */
680  hltdc->State = HAL_LTDC_STATE_READY;
681 
682  /* Process unlocked */
683  __HAL_UNLOCK(hltdc);
684 
685  /* Reload interrupt Callback */
686 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
687  /*Call registered reload Event callback */
688  hltdc->ReloadEventCallback(hltdc);
689 #else
690  /*Call Legacy Reload Event callback */
691  HAL_LTDC_ReloadEventCallback(hltdc);
692 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
693  }
694 }
695 
702 __weak void HAL_LTDC_ErrorCallback(LTDC_HandleTypeDef *hltdc)
703 {
704  /* Prevent unused argument(s) compilation warning */
705  UNUSED(hltdc);
706 
707  /* NOTE : This function should not be modified, when the callback is needed,
708  the HAL_LTDC_ErrorCallback could be implemented in the user file
709  */
710 }
711 
718 __weak void HAL_LTDC_LineEventCallback(LTDC_HandleTypeDef *hltdc)
719 {
720  /* Prevent unused argument(s) compilation warning */
721  UNUSED(hltdc);
722 
723  /* NOTE : This function should not be modified, when the callback is needed,
724  the HAL_LTDC_LineEventCallback could be implemented in the user file
725  */
726 }
727 
734 __weak void HAL_LTDC_ReloadEventCallback(LTDC_HandleTypeDef *hltdc)
735 {
736  /* Prevent unused argument(s) compilation warning */
737  UNUSED(hltdc);
738 
739  /* NOTE : This function should not be modified, when the callback is needed,
740  the HAL_LTDC_ReloadEvenCallback could be implemented in the user file
741  */
742 }
743 
784 HAL_StatusTypeDef HAL_LTDC_ConfigLayer(LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgTypeDef *pLayerCfg, uint32_t LayerIdx)
785 {
786  /* Check the parameters */
787  assert_param(IS_LTDC_LAYER(LayerIdx));
788  assert_param(IS_LTDC_HCONFIGST(pLayerCfg->WindowX0));
789  assert_param(IS_LTDC_HCONFIGSP(pLayerCfg->WindowX1));
790  assert_param(IS_LTDC_VCONFIGST(pLayerCfg->WindowY0));
791  assert_param(IS_LTDC_VCONFIGSP(pLayerCfg->WindowY1));
792  assert_param(IS_LTDC_PIXEL_FORMAT(pLayerCfg->PixelFormat));
793  assert_param(IS_LTDC_ALPHA(pLayerCfg->Alpha));
794  assert_param(IS_LTDC_ALPHA(pLayerCfg->Alpha0));
795  assert_param(IS_LTDC_BLENDING_FACTOR1(pLayerCfg->BlendingFactor1));
796  assert_param(IS_LTDC_BLENDING_FACTOR2(pLayerCfg->BlendingFactor2));
797  assert_param(IS_LTDC_CFBLL(pLayerCfg->ImageWidth));
798  assert_param(IS_LTDC_CFBLNBR(pLayerCfg->ImageHeight));
799 
800  /* Process locked */
801  __HAL_LOCK(hltdc);
802 
803  /* Change LTDC peripheral state */
804  hltdc->State = HAL_LTDC_STATE_BUSY;
805 
806  /* Copy new layer configuration into handle structure */
807  hltdc->LayerCfg[LayerIdx] = *pLayerCfg;
808 
809  /* Configure the LTDC Layer */
810  LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
811 
812  /* Set the Immediate Reload type */
813  hltdc->Instance->SRCR = LTDC_SRCR_IMR;
814 
815  /* Initialize the LTDC state*/
816  hltdc->State = HAL_LTDC_STATE_READY;
817 
818  /* Process unlocked */
819  __HAL_UNLOCK(hltdc);
820 
821  return HAL_OK;
822 }
823 
834 HAL_StatusTypeDef HAL_LTDC_ConfigColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t RGBValue, uint32_t LayerIdx)
835 {
836  /* Check the parameters */
837  assert_param(IS_LTDC_LAYER(LayerIdx));
838 
839  /* Process locked */
840  __HAL_LOCK(hltdc);
841 
842  /* Change LTDC peripheral state */
843  hltdc->State = HAL_LTDC_STATE_BUSY;
844 
845  /* Configure the default color values */
846  LTDC_LAYER(hltdc, LayerIdx)->CKCR &= ~(LTDC_LxCKCR_CKBLUE | LTDC_LxCKCR_CKGREEN | LTDC_LxCKCR_CKRED);
847  LTDC_LAYER(hltdc, LayerIdx)->CKCR = RGBValue;
848 
849  /* Set the Immediate Reload type */
850  hltdc->Instance->SRCR = LTDC_SRCR_IMR;
851 
852  /* Change the LTDC state*/
853  hltdc->State = HAL_LTDC_STATE_READY;
854 
855  /* Process unlocked */
856  __HAL_UNLOCK(hltdc);
857 
858  return HAL_OK;
859 }
860 
872 HAL_StatusTypeDef HAL_LTDC_ConfigCLUT(LTDC_HandleTypeDef *hltdc, uint32_t *pCLUT, uint32_t CLUTSize, uint32_t LayerIdx)
873 {
874  uint32_t tmp;
875  uint32_t counter;
876  uint32_t *pcolorlut = pCLUT;
877  /* Check the parameters */
878  assert_param(IS_LTDC_LAYER(LayerIdx));
879 
880  /* Process locked */
881  __HAL_LOCK(hltdc);
882 
883  /* Change LTDC peripheral state */
884  hltdc->State = HAL_LTDC_STATE_BUSY;
885 
886  for (counter = 0U; (counter < CLUTSize); counter++)
887  {
888  if (hltdc->LayerCfg[LayerIdx].PixelFormat == LTDC_PIXEL_FORMAT_AL44)
889  {
890  tmp = (((counter + (16U*counter)) << 24U) | ((uint32_t)(*pcolorlut) & 0xFFU) | ((uint32_t)(*pcolorlut) & 0xFF00U) | ((uint32_t)(*pcolorlut) & 0xFF0000U));
891  }
892  else
893  {
894  tmp = ((counter << 24U) | ((uint32_t)(*pcolorlut) & 0xFFU) | ((uint32_t)(*pcolorlut) & 0xFF00U) | ((uint32_t)(*pcolorlut) & 0xFF0000U));
895  }
896 
897  pcolorlut++;
898 
899  /* Specifies the C-LUT address and RGB value */
900  LTDC_LAYER(hltdc, LayerIdx)->CLUTWR = tmp;
901  }
902 
903  /* Change the LTDC state*/
904  hltdc->State = HAL_LTDC_STATE_READY;
905 
906  /* Process unlocked */
907  __HAL_UNLOCK(hltdc);
908 
909  return HAL_OK;
910 }
911 
921 HAL_StatusTypeDef HAL_LTDC_EnableColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
922 {
923  /* Check the parameters */
924  assert_param(IS_LTDC_LAYER(LayerIdx));
925 
926  /* Process locked */
927  __HAL_LOCK(hltdc);
928 
929  /* Change LTDC peripheral state */
930  hltdc->State = HAL_LTDC_STATE_BUSY;
931 
932  /* Enable LTDC color keying by setting COLKEN bit */
933  LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_COLKEN;
934 
935  /* Set the Immediate Reload type */
936  hltdc->Instance->SRCR = LTDC_SRCR_IMR;
937 
938  /* Change the LTDC state*/
939  hltdc->State = HAL_LTDC_STATE_READY;
940 
941  /* Process unlocked */
942  __HAL_UNLOCK(hltdc);
943 
944  return HAL_OK;
945 }
946 
956 HAL_StatusTypeDef HAL_LTDC_DisableColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
957 {
958  /* Check the parameters */
959  assert_param(IS_LTDC_LAYER(LayerIdx));
960 
961  /* Process locked */
962  __HAL_LOCK(hltdc);
963 
964  /* Change LTDC peripheral state */
965  hltdc->State = HAL_LTDC_STATE_BUSY;
966 
967  /* Disable LTDC color keying by setting COLKEN bit */
968  LTDC_LAYER(hltdc, LayerIdx)->CR &= ~(uint32_t)LTDC_LxCR_COLKEN;
969 
970  /* Set the Immediate Reload type */
971  hltdc->Instance->SRCR = LTDC_SRCR_IMR;
972 
973  /* Change the LTDC state*/
974  hltdc->State = HAL_LTDC_STATE_READY;
975 
976  /* Process unlocked */
977  __HAL_UNLOCK(hltdc);
978 
979  return HAL_OK;
980 }
981 
991 HAL_StatusTypeDef HAL_LTDC_EnableCLUT(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
992 {
993  /* Check the parameters */
994  assert_param(IS_LTDC_LAYER(LayerIdx));
995 
996  /* Process locked */
997  __HAL_LOCK(hltdc);
998 
999  /* Change LTDC peripheral state */
1000  hltdc->State = HAL_LTDC_STATE_BUSY;
1001 
1002  /* Enable LTDC color lookup table by setting CLUTEN bit */
1003  LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_CLUTEN;
1004 
1005  /* Set the Immediate Reload type */
1006  hltdc->Instance->SRCR = LTDC_SRCR_IMR;
1007 
1008  /* Change the LTDC state*/
1009  hltdc->State = HAL_LTDC_STATE_READY;
1010 
1011  /* Process unlocked */
1012  __HAL_UNLOCK(hltdc);
1013 
1014  return HAL_OK;
1015 }
1016 
1026 HAL_StatusTypeDef HAL_LTDC_DisableCLUT(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
1027 {
1028  /* Check the parameters */
1029  assert_param(IS_LTDC_LAYER(LayerIdx));
1030 
1031  /* Process locked */
1032  __HAL_LOCK(hltdc);
1033 
1034  /* Change LTDC peripheral state */
1035  hltdc->State = HAL_LTDC_STATE_BUSY;
1036 
1037  /* Disable LTDC color lookup table by setting CLUTEN bit */
1038  LTDC_LAYER(hltdc, LayerIdx)->CR &= ~(uint32_t)LTDC_LxCR_CLUTEN;
1039 
1040  /* Set the Immediate Reload type */
1041  hltdc->Instance->SRCR = LTDC_SRCR_IMR;
1042 
1043  /* Change the LTDC state*/
1044  hltdc->State = HAL_LTDC_STATE_READY;
1045 
1046  /* Process unlocked */
1047  __HAL_UNLOCK(hltdc);
1048 
1049  return HAL_OK;
1050 }
1051 
1059 HAL_StatusTypeDef HAL_LTDC_EnableDither(LTDC_HandleTypeDef *hltdc)
1060 {
1061  /* Process locked */
1062  __HAL_LOCK(hltdc);
1063 
1064  /* Change LTDC peripheral state */
1065  hltdc->State = HAL_LTDC_STATE_BUSY;
1066 
1067  /* Enable Dither by setting DTEN bit */
1068  LTDC->GCR |= (uint32_t)LTDC_GCR_DEN;
1069 
1070  /* Change the LTDC state*/
1071  hltdc->State = HAL_LTDC_STATE_READY;
1072 
1073  /* Process unlocked */
1074  __HAL_UNLOCK(hltdc);
1075 
1076  return HAL_OK;
1077 }
1078 
1086 HAL_StatusTypeDef HAL_LTDC_DisableDither(LTDC_HandleTypeDef *hltdc)
1087 {
1088  /* Process locked */
1089  __HAL_LOCK(hltdc);
1090 
1091  /* Change LTDC peripheral state */
1092  hltdc->State = HAL_LTDC_STATE_BUSY;
1093 
1094  /* Disable Dither by setting DTEN bit */
1095  LTDC->GCR &= ~(uint32_t)LTDC_GCR_DEN;
1096 
1097  /* Change the LTDC state*/
1098  hltdc->State = HAL_LTDC_STATE_READY;
1099 
1100  /* Process unlocked */
1101  __HAL_UNLOCK(hltdc);
1102 
1103  return HAL_OK;
1104 }
1105 
1117 HAL_StatusTypeDef HAL_LTDC_SetWindowSize(LTDC_HandleTypeDef *hltdc, uint32_t XSize, uint32_t YSize, uint32_t LayerIdx)
1118 {
1119  LTDC_LayerCfgTypeDef *pLayerCfg;
1120 
1121  /* Check the parameters (Layers parameters)*/
1122  assert_param(IS_LTDC_LAYER(LayerIdx));
1123  assert_param(IS_LTDC_CFBLL(XSize));
1124  assert_param(IS_LTDC_CFBLNBR(YSize));
1125 
1126  /* Process locked */
1127  __HAL_LOCK(hltdc);
1128 
1129  /* Change LTDC peripheral state */
1130  hltdc->State = HAL_LTDC_STATE_BUSY;
1131 
1132  /* Get layer configuration from handle structure */
1133  pLayerCfg = &hltdc->LayerCfg[LayerIdx];
1134 
1135  /* update horizontal stop */
1136  pLayerCfg->WindowX1 = XSize + pLayerCfg->WindowX0;
1137 
1138  /* update vertical stop */
1139  pLayerCfg->WindowY1 = YSize + pLayerCfg->WindowY0;
1140 
1141  /* Reconfigures the color frame buffer pitch in byte */
1142  pLayerCfg->ImageWidth = XSize;
1143 
1144  /* Reconfigures the frame buffer line number */
1145  pLayerCfg->ImageHeight = YSize;
1146 
1147  /* Set LTDC parameters */
1148  LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
1149 
1150  /* Set the Immediate Reload type */
1151  hltdc->Instance->SRCR = LTDC_SRCR_IMR;
1152 
1153  /* Change the LTDC state*/
1154  hltdc->State = HAL_LTDC_STATE_READY;
1155 
1156  /* Process unlocked */
1157  __HAL_UNLOCK(hltdc);
1158 
1159  return HAL_OK;
1160 }
1161 
1173 HAL_StatusTypeDef HAL_LTDC_SetWindowPosition(LTDC_HandleTypeDef *hltdc, uint32_t X0, uint32_t Y0, uint32_t LayerIdx)
1174 {
1175  LTDC_LayerCfgTypeDef *pLayerCfg;
1176 
1177  /* Check the parameters */
1178  assert_param(IS_LTDC_LAYER(LayerIdx));
1179  assert_param(IS_LTDC_CFBLL(X0));
1180  assert_param(IS_LTDC_CFBLNBR(Y0));
1181 
1182  /* Process locked */
1183  __HAL_LOCK(hltdc);
1184 
1185  /* Change LTDC peripheral state */
1186  hltdc->State = HAL_LTDC_STATE_BUSY;
1187 
1188  /* Get layer configuration from handle structure */
1189  pLayerCfg = &hltdc->LayerCfg[LayerIdx];
1190 
1191  /* update horizontal start/stop */
1192  pLayerCfg->WindowX0 = X0;
1193  pLayerCfg->WindowX1 = X0 + pLayerCfg->ImageWidth;
1194 
1195  /* update vertical start/stop */
1196  pLayerCfg->WindowY0 = Y0;
1197  pLayerCfg->WindowY1 = Y0 + pLayerCfg->ImageHeight;
1198 
1199  /* Set LTDC parameters */
1200  LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
1201 
1202  /* Set the Immediate Reload type */
1203  hltdc->Instance->SRCR = LTDC_SRCR_IMR;
1204 
1205  /* Change the LTDC state*/
1206  hltdc->State = HAL_LTDC_STATE_READY;
1207 
1208  /* Process unlocked */
1209  __HAL_UNLOCK(hltdc);
1210 
1211  return HAL_OK;
1212 }
1213 
1224 HAL_StatusTypeDef HAL_LTDC_SetPixelFormat(LTDC_HandleTypeDef *hltdc, uint32_t Pixelformat, uint32_t LayerIdx)
1225 {
1226  LTDC_LayerCfgTypeDef *pLayerCfg;
1227 
1228  /* Check the parameters */
1229  assert_param(IS_LTDC_PIXEL_FORMAT(Pixelformat));
1230  assert_param(IS_LTDC_LAYER(LayerIdx));
1231 
1232  /* Process locked */
1233  __HAL_LOCK(hltdc);
1234 
1235  /* Change LTDC peripheral state */
1236  hltdc->State = HAL_LTDC_STATE_BUSY;
1237 
1238  /* Get layer configuration from handle structure */
1239  pLayerCfg = &hltdc->LayerCfg[LayerIdx];
1240 
1241  /* Reconfigure the pixel format */
1242  pLayerCfg->PixelFormat = Pixelformat;
1243 
1244  /* Set LTDC parameters */
1245  LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
1246 
1247  /* Set the Immediate Reload type */
1248  hltdc->Instance->SRCR = LTDC_SRCR_IMR;
1249 
1250  /* Change the LTDC state*/
1251  hltdc->State = HAL_LTDC_STATE_READY;
1252 
1253  /* Process unlocked */
1254  __HAL_UNLOCK(hltdc);
1255 
1256  return HAL_OK;
1257 }
1258 
1269 HAL_StatusTypeDef HAL_LTDC_SetAlpha(LTDC_HandleTypeDef *hltdc, uint32_t Alpha, uint32_t LayerIdx)
1270 {
1271  LTDC_LayerCfgTypeDef *pLayerCfg;
1272 
1273  /* Check the parameters */
1274  assert_param(IS_LTDC_ALPHA(Alpha));
1275  assert_param(IS_LTDC_LAYER(LayerIdx));
1276 
1277  /* Process locked */
1278  __HAL_LOCK(hltdc);
1279 
1280  /* Change LTDC peripheral state */
1281  hltdc->State = HAL_LTDC_STATE_BUSY;
1282 
1283  /* Get layer configuration from handle structure */
1284  pLayerCfg = &hltdc->LayerCfg[LayerIdx];
1285 
1286  /* Reconfigure the Alpha value */
1287  pLayerCfg->Alpha = Alpha;
1288 
1289  /* Set LTDC parameters */
1290  LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
1291 
1292  /* Set the Immediate Reload type */
1293  hltdc->Instance->SRCR = LTDC_SRCR_IMR;
1294 
1295  /* Change the LTDC state*/
1296  hltdc->State = HAL_LTDC_STATE_READY;
1297 
1298  /* Process unlocked */
1299  __HAL_UNLOCK(hltdc);
1300 
1301  return HAL_OK;
1302 }
1313 HAL_StatusTypeDef HAL_LTDC_SetAddress(LTDC_HandleTypeDef *hltdc, uint32_t Address, uint32_t LayerIdx)
1314 {
1315  LTDC_LayerCfgTypeDef *pLayerCfg;
1316 
1317  /* Check the parameters */
1318  assert_param(IS_LTDC_LAYER(LayerIdx));
1319 
1320  /* Process locked */
1321  __HAL_LOCK(hltdc);
1322 
1323  /* Change LTDC peripheral state */
1324  hltdc->State = HAL_LTDC_STATE_BUSY;
1325 
1326  /* Get layer configuration from handle structure */
1327  pLayerCfg = &hltdc->LayerCfg[LayerIdx];
1328 
1329  /* Reconfigure the Address */
1330  pLayerCfg->FBStartAdress = Address;
1331 
1332  /* Set LTDC parameters */
1333  LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
1334 
1335  /* Set the Immediate Reload type */
1336  hltdc->Instance->SRCR = LTDC_SRCR_IMR;
1337 
1338  /* Change the LTDC state*/
1339  hltdc->State = HAL_LTDC_STATE_READY;
1340 
1341  /* Process unlocked */
1342  __HAL_UNLOCK(hltdc);
1343 
1344  return HAL_OK;
1345 }
1346 
1360 HAL_StatusTypeDef HAL_LTDC_SetPitch(LTDC_HandleTypeDef *hltdc, uint32_t LinePitchInPixels, uint32_t LayerIdx)
1361 {
1362  uint32_t tmp;
1363  uint32_t pitchUpdate;
1364  uint32_t pixelFormat;
1365 
1366  /* Check the parameters */
1367  assert_param(IS_LTDC_LAYER(LayerIdx));
1368 
1369  /* Process locked */
1370  __HAL_LOCK(hltdc);
1371 
1372  /* Change LTDC peripheral state */
1373  hltdc->State = HAL_LTDC_STATE_BUSY;
1374 
1375  /* get LayerIdx used pixel format */
1376  pixelFormat = hltdc->LayerCfg[LayerIdx].PixelFormat;
1377 
1378  if (pixelFormat == LTDC_PIXEL_FORMAT_ARGB8888)
1379  {
1380  tmp = 4U;
1381  }
1382  else if (pixelFormat == LTDC_PIXEL_FORMAT_RGB888)
1383  {
1384  tmp = 3U;
1385  }
1386  else if ((pixelFormat == LTDC_PIXEL_FORMAT_ARGB4444) || \
1387  (pixelFormat == LTDC_PIXEL_FORMAT_RGB565) || \
1388  (pixelFormat == LTDC_PIXEL_FORMAT_ARGB1555) || \
1389  (pixelFormat == LTDC_PIXEL_FORMAT_AL88))
1390  {
1391  tmp = 2U;
1392  }
1393  else
1394  {
1395  tmp = 1U;
1396  }
1397 
1398  pitchUpdate = ((LinePitchInPixels * tmp) << 16U);
1399 
1400  /* Clear previously set standard pitch */
1401  LTDC_LAYER(hltdc, LayerIdx)->CFBLR &= ~LTDC_LxCFBLR_CFBP;
1402 
1403  /* Set the Reload type as immediate update of LTDC pitch configured above */
1404  LTDC->SRCR |= LTDC_SRCR_IMR;
1405 
1406  /* Set new line pitch value */
1407  LTDC_LAYER(hltdc, LayerIdx)->CFBLR |= pitchUpdate;
1408 
1409  /* Set the Reload type as immediate update of LTDC pitch configured above */
1410  LTDC->SRCR |= LTDC_SRCR_IMR;
1411 
1412  /* Change the LTDC state*/
1413  hltdc->State = HAL_LTDC_STATE_READY;
1414 
1415  /* Process unlocked */
1416  __HAL_UNLOCK(hltdc);
1417 
1418  return HAL_OK;
1419 }
1420 
1429 HAL_StatusTypeDef HAL_LTDC_ProgramLineEvent(LTDC_HandleTypeDef *hltdc, uint32_t Line)
1430 {
1431  /* Check the parameters */
1432  assert_param(IS_LTDC_LIPOS(Line));
1433 
1434  /* Process locked */
1435  __HAL_LOCK(hltdc);
1436 
1437  /* Change LTDC peripheral state */
1438  hltdc->State = HAL_LTDC_STATE_BUSY;
1439 
1440  /* Disable the Line interrupt */
1441  __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_LI);
1442 
1443  /* Set the Line Interrupt position */
1444  LTDC->LIPCR = (uint32_t)Line;
1445 
1446  /* Enable the Line interrupt */
1447  __HAL_LTDC_ENABLE_IT(hltdc, LTDC_IT_LI);
1448 
1449  /* Change the LTDC state*/
1450  hltdc->State = HAL_LTDC_STATE_READY;
1451 
1452  /* Process unlocked */
1453  __HAL_UNLOCK(hltdc);
1454 
1455  return HAL_OK;
1456 }
1457 
1468 HAL_StatusTypeDef HAL_LTDC_Reload(LTDC_HandleTypeDef *hltdc, uint32_t ReloadType)
1469 {
1470  /* Check the parameters */
1471  assert_param(IS_LTDC_RELOAD(ReloadType));
1472 
1473  /* Process locked */
1474  __HAL_LOCK(hltdc);
1475 
1476  /* Change LTDC peripheral state */
1477  hltdc->State = HAL_LTDC_STATE_BUSY;
1478 
1479  /* Enable the Reload interrupt */
1480  __HAL_LTDC_ENABLE_IT(hltdc, LTDC_IT_RR);
1481 
1482  /* Apply Reload type */
1483  hltdc->Instance->SRCR = ReloadType;
1484 
1485  /* Change the LTDC state*/
1486  hltdc->State = HAL_LTDC_STATE_READY;
1487 
1488  /* Process unlocked */
1489  __HAL_UNLOCK(hltdc);
1490 
1491  return HAL_OK;
1492 }
1493 
1507 HAL_StatusTypeDef HAL_LTDC_ConfigLayer_NoReload(LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgTypeDef *pLayerCfg, uint32_t LayerIdx)
1508 {
1509  /* Check the parameters */
1510  assert_param(IS_LTDC_LAYER(LayerIdx));
1511  assert_param(IS_LTDC_HCONFIGST(pLayerCfg->WindowX0));
1512  assert_param(IS_LTDC_HCONFIGSP(pLayerCfg->WindowX1));
1513  assert_param(IS_LTDC_VCONFIGST(pLayerCfg->WindowY0));
1514  assert_param(IS_LTDC_VCONFIGSP(pLayerCfg->WindowY1));
1515  assert_param(IS_LTDC_PIXEL_FORMAT(pLayerCfg->PixelFormat));
1516  assert_param(IS_LTDC_ALPHA(pLayerCfg->Alpha));
1517  assert_param(IS_LTDC_ALPHA(pLayerCfg->Alpha0));
1518  assert_param(IS_LTDC_BLENDING_FACTOR1(pLayerCfg->BlendingFactor1));
1519  assert_param(IS_LTDC_BLENDING_FACTOR2(pLayerCfg->BlendingFactor2));
1520  assert_param(IS_LTDC_CFBLL(pLayerCfg->ImageWidth));
1521  assert_param(IS_LTDC_CFBLNBR(pLayerCfg->ImageHeight));
1522 
1523  /* Process locked */
1524  __HAL_LOCK(hltdc);
1525 
1526  /* Change LTDC peripheral state */
1527  hltdc->State = HAL_LTDC_STATE_BUSY;
1528 
1529  /* Copy new layer configuration into handle structure */
1530  hltdc->LayerCfg[LayerIdx] = *pLayerCfg;
1531 
1532  /* Configure the LTDC Layer */
1533  LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
1534 
1535  /* Initialize the LTDC state*/
1536  hltdc->State = HAL_LTDC_STATE_READY;
1537 
1538  /* Process unlocked */
1539  __HAL_UNLOCK(hltdc);
1540 
1541  return HAL_OK;
1542 }
1543 
1556 HAL_StatusTypeDef HAL_LTDC_SetWindowSize_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t XSize, uint32_t YSize, uint32_t LayerIdx)
1557 {
1558  LTDC_LayerCfgTypeDef *pLayerCfg;
1559 
1560  /* Check the parameters (Layers parameters)*/
1561  assert_param(IS_LTDC_LAYER(LayerIdx));
1562  assert_param(IS_LTDC_CFBLL(XSize));
1563  assert_param(IS_LTDC_CFBLNBR(YSize));
1564 
1565  /* Process locked */
1566  __HAL_LOCK(hltdc);
1567 
1568  /* Change LTDC peripheral state */
1569  hltdc->State = HAL_LTDC_STATE_BUSY;
1570 
1571  /* Get layer configuration from handle structure */
1572  pLayerCfg = &hltdc->LayerCfg[LayerIdx];
1573 
1574  /* update horizontal stop */
1575  pLayerCfg->WindowX1 = XSize + pLayerCfg->WindowX0;
1576 
1577  /* update vertical stop */
1578  pLayerCfg->WindowY1 = YSize + pLayerCfg->WindowY0;
1579 
1580  /* Reconfigures the color frame buffer pitch in byte */
1581  pLayerCfg->ImageWidth = XSize;
1582 
1583  /* Reconfigures the frame buffer line number */
1584  pLayerCfg->ImageHeight = YSize;
1585 
1586  /* Set LTDC parameters */
1587  LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
1588 
1589  /* Change the LTDC state*/
1590  hltdc->State = HAL_LTDC_STATE_READY;
1591 
1592  /* Process unlocked */
1593  __HAL_UNLOCK(hltdc);
1594 
1595  return HAL_OK;
1596 }
1597 
1610 HAL_StatusTypeDef HAL_LTDC_SetWindowPosition_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t X0, uint32_t Y0, uint32_t LayerIdx)
1611 {
1612  LTDC_LayerCfgTypeDef *pLayerCfg;
1613 
1614  /* Check the parameters */
1615  assert_param(IS_LTDC_LAYER(LayerIdx));
1616  assert_param(IS_LTDC_CFBLL(X0));
1617  assert_param(IS_LTDC_CFBLNBR(Y0));
1618 
1619  /* Process locked */
1620  __HAL_LOCK(hltdc);
1621 
1622  /* Change LTDC peripheral state */
1623  hltdc->State = HAL_LTDC_STATE_BUSY;
1624 
1625  /* Get layer configuration from handle structure */
1626  pLayerCfg = &hltdc->LayerCfg[LayerIdx];
1627 
1628  /* update horizontal start/stop */
1629  pLayerCfg->WindowX0 = X0;
1630  pLayerCfg->WindowX1 = X0 + pLayerCfg->ImageWidth;
1631 
1632  /* update vertical start/stop */
1633  pLayerCfg->WindowY0 = Y0;
1634  pLayerCfg->WindowY1 = Y0 + pLayerCfg->ImageHeight;
1635 
1636  /* Set LTDC parameters */
1637  LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
1638 
1639  /* Change the LTDC state*/
1640  hltdc->State = HAL_LTDC_STATE_READY;
1641 
1642  /* Process unlocked */
1643  __HAL_UNLOCK(hltdc);
1644 
1645  return HAL_OK;
1646 }
1647 
1659 HAL_StatusTypeDef HAL_LTDC_SetPixelFormat_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t Pixelformat, uint32_t LayerIdx)
1660 {
1661  LTDC_LayerCfgTypeDef *pLayerCfg;
1662 
1663  /* Check the parameters */
1664  assert_param(IS_LTDC_PIXEL_FORMAT(Pixelformat));
1665  assert_param(IS_LTDC_LAYER(LayerIdx));
1666 
1667  /* Process locked */
1668  __HAL_LOCK(hltdc);
1669 
1670  /* Change LTDC peripheral state */
1671  hltdc->State = HAL_LTDC_STATE_BUSY;
1672 
1673  /* Get layer configuration from handle structure */
1674  pLayerCfg = &hltdc->LayerCfg[LayerIdx];
1675 
1676  /* Reconfigure the pixel format */
1677  pLayerCfg->PixelFormat = Pixelformat;
1678 
1679  /* Set LTDC parameters */
1680  LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
1681 
1682  /* Change the LTDC state*/
1683  hltdc->State = HAL_LTDC_STATE_READY;
1684 
1685  /* Process unlocked */
1686  __HAL_UNLOCK(hltdc);
1687 
1688  return HAL_OK;
1689 }
1690 
1702 HAL_StatusTypeDef HAL_LTDC_SetAlpha_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t Alpha, uint32_t LayerIdx)
1703 {
1704  LTDC_LayerCfgTypeDef *pLayerCfg;
1705 
1706  /* Check the parameters */
1707  assert_param(IS_LTDC_ALPHA(Alpha));
1708  assert_param(IS_LTDC_LAYER(LayerIdx));
1709 
1710  /* Process locked */
1711  __HAL_LOCK(hltdc);
1712 
1713  /* Change LTDC peripheral state */
1714  hltdc->State = HAL_LTDC_STATE_BUSY;
1715 
1716  /* Get layer configuration from handle structure */
1717  pLayerCfg = &hltdc->LayerCfg[LayerIdx];
1718 
1719  /* Reconfigure the Alpha value */
1720  pLayerCfg->Alpha = Alpha;
1721 
1722  /* Set LTDC parameters */
1723  LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
1724 
1725  /* Change the LTDC state*/
1726  hltdc->State = HAL_LTDC_STATE_READY;
1727 
1728  /* Process unlocked */
1729  __HAL_UNLOCK(hltdc);
1730 
1731  return HAL_OK;
1732 }
1733 
1745 HAL_StatusTypeDef HAL_LTDC_SetAddress_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t Address, uint32_t LayerIdx)
1746 {
1747  LTDC_LayerCfgTypeDef *pLayerCfg;
1748 
1749  /* Check the parameters */
1750  assert_param(IS_LTDC_LAYER(LayerIdx));
1751 
1752  /* Process locked */
1753  __HAL_LOCK(hltdc);
1754 
1755  /* Change LTDC peripheral state */
1756  hltdc->State = HAL_LTDC_STATE_BUSY;
1757 
1758  /* Get layer configuration from handle structure */
1759  pLayerCfg = &hltdc->LayerCfg[LayerIdx];
1760 
1761  /* Reconfigure the Address */
1762  pLayerCfg->FBStartAdress = Address;
1763 
1764  /* Set LTDC parameters */
1765  LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
1766 
1767  /* Change the LTDC state*/
1768  hltdc->State = HAL_LTDC_STATE_READY;
1769 
1770  /* Process unlocked */
1771  __HAL_UNLOCK(hltdc);
1772 
1773  return HAL_OK;
1774 }
1775 
1790 HAL_StatusTypeDef HAL_LTDC_SetPitch_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t LinePitchInPixels, uint32_t LayerIdx)
1791 {
1792  uint32_t tmp;
1793  uint32_t pitchUpdate;
1794  uint32_t pixelFormat;
1795 
1796  /* Check the parameters */
1797  assert_param(IS_LTDC_LAYER(LayerIdx));
1798 
1799  /* Process locked */
1800  __HAL_LOCK(hltdc);
1801 
1802  /* Change LTDC peripheral state */
1803  hltdc->State = HAL_LTDC_STATE_BUSY;
1804 
1805  /* get LayerIdx used pixel format */
1806  pixelFormat = hltdc->LayerCfg[LayerIdx].PixelFormat;
1807 
1808  if (pixelFormat == LTDC_PIXEL_FORMAT_ARGB8888)
1809  {
1810  tmp = 4U;
1811  }
1812  else if (pixelFormat == LTDC_PIXEL_FORMAT_RGB888)
1813  {
1814  tmp = 3U;
1815  }
1816  else if ((pixelFormat == LTDC_PIXEL_FORMAT_ARGB4444) || \
1817  (pixelFormat == LTDC_PIXEL_FORMAT_RGB565) || \
1818  (pixelFormat == LTDC_PIXEL_FORMAT_ARGB1555) || \
1819  (pixelFormat == LTDC_PIXEL_FORMAT_AL88))
1820  {
1821  tmp = 2U;
1822  }
1823  else
1824  {
1825  tmp = 1U;
1826  }
1827 
1828  pitchUpdate = ((LinePitchInPixels * tmp) << 16U);
1829 
1830  /* Clear previously set standard pitch */
1831  LTDC_LAYER(hltdc, LayerIdx)->CFBLR &= ~LTDC_LxCFBLR_CFBP;
1832 
1833  /* Set new line pitch value */
1834  LTDC_LAYER(hltdc, LayerIdx)->CFBLR |= pitchUpdate;
1835 
1836  /* Change the LTDC state*/
1837  hltdc->State = HAL_LTDC_STATE_READY;
1838 
1839  /* Process unlocked */
1840  __HAL_UNLOCK(hltdc);
1841 
1842  return HAL_OK;
1843 }
1844 
1845 
1857 HAL_StatusTypeDef HAL_LTDC_ConfigColorKeying_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t RGBValue, uint32_t LayerIdx)
1858 {
1859  /* Check the parameters */
1860  assert_param(IS_LTDC_LAYER(LayerIdx));
1861 
1862  /* Process locked */
1863  __HAL_LOCK(hltdc);
1864 
1865  /* Change LTDC peripheral state */
1866  hltdc->State = HAL_LTDC_STATE_BUSY;
1867 
1868  /* Configure the default color values */
1869  LTDC_LAYER(hltdc, LayerIdx)->CKCR &= ~(LTDC_LxCKCR_CKBLUE | LTDC_LxCKCR_CKGREEN | LTDC_LxCKCR_CKRED);
1870  LTDC_LAYER(hltdc, LayerIdx)->CKCR = RGBValue;
1871 
1872  /* Change the LTDC state*/
1873  hltdc->State = HAL_LTDC_STATE_READY;
1874 
1875  /* Process unlocked */
1876  __HAL_UNLOCK(hltdc);
1877 
1878  return HAL_OK;
1879 }
1880 
1891 HAL_StatusTypeDef HAL_LTDC_EnableColorKeying_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
1892 {
1893  /* Check the parameters */
1894  assert_param(IS_LTDC_LAYER(LayerIdx));
1895 
1896  /* Process locked */
1897  __HAL_LOCK(hltdc);
1898 
1899  /* Change LTDC peripheral state */
1900  hltdc->State = HAL_LTDC_STATE_BUSY;
1901 
1902  /* Enable LTDC color keying by setting COLKEN bit */
1903  LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_COLKEN;
1904 
1905  /* Change the LTDC state*/
1906  hltdc->State = HAL_LTDC_STATE_READY;
1907 
1908  /* Process unlocked */
1909  __HAL_UNLOCK(hltdc);
1910 
1911  return HAL_OK;
1912 }
1913 
1924 HAL_StatusTypeDef HAL_LTDC_DisableColorKeying_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
1925 {
1926  /* Check the parameters */
1927  assert_param(IS_LTDC_LAYER(LayerIdx));
1928 
1929  /* Process locked */
1930  __HAL_LOCK(hltdc);
1931 
1932  /* Change LTDC peripheral state */
1933  hltdc->State = HAL_LTDC_STATE_BUSY;
1934 
1935  /* Disable LTDC color keying by setting COLKEN bit */
1936  LTDC_LAYER(hltdc, LayerIdx)->CR &= ~(uint32_t)LTDC_LxCR_COLKEN;
1937 
1938  /* Change the LTDC state*/
1939  hltdc->State = HAL_LTDC_STATE_READY;
1940 
1941  /* Process unlocked */
1942  __HAL_UNLOCK(hltdc);
1943 
1944  return HAL_OK;
1945 }
1946 
1957 HAL_StatusTypeDef HAL_LTDC_EnableCLUT_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
1958 {
1959  /* Check the parameters */
1960  assert_param(IS_LTDC_LAYER(LayerIdx));
1961 
1962  /* Process locked */
1963  __HAL_LOCK(hltdc);
1964 
1965  /* Change LTDC peripheral state */
1966  hltdc->State = HAL_LTDC_STATE_BUSY;
1967 
1968  /* Disable LTDC color lookup table by setting CLUTEN bit */
1969  LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_CLUTEN;
1970 
1971  /* Change the LTDC state*/
1972  hltdc->State = HAL_LTDC_STATE_READY;
1973 
1974  /* Process unlocked */
1975  __HAL_UNLOCK(hltdc);
1976 
1977  return HAL_OK;
1978 }
1979 
1990 HAL_StatusTypeDef HAL_LTDC_DisableCLUT_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
1991 {
1992  /* Check the parameters */
1993  assert_param(IS_LTDC_LAYER(LayerIdx));
1994 
1995  /* Process locked */
1996  __HAL_LOCK(hltdc);
1997 
1998  /* Change LTDC peripheral state */
1999  hltdc->State = HAL_LTDC_STATE_BUSY;
2000 
2001  /* Disable LTDC color lookup table by setting CLUTEN bit */
2002  LTDC_LAYER(hltdc, LayerIdx)->CR &= ~(uint32_t)LTDC_LxCR_CLUTEN;
2003 
2004  /* Change the LTDC state*/
2005  hltdc->State = HAL_LTDC_STATE_READY;
2006 
2007  /* Process unlocked */
2008  __HAL_UNLOCK(hltdc);
2009 
2010  return HAL_OK;
2011 }
2012 
2039 HAL_LTDC_StateTypeDef HAL_LTDC_GetState(LTDC_HandleTypeDef *hltdc)
2040 {
2041  return hltdc->State;
2042 }
2043 
2050 uint32_t HAL_LTDC_GetError(LTDC_HandleTypeDef *hltdc)
2051 {
2052  return hltdc->ErrorCode;
2053 }
2054 
2076 static void LTDC_SetConfig(LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgTypeDef *pLayerCfg, uint32_t LayerIdx)
2077 {
2078  uint32_t tmp;
2079  uint32_t tmp1;
2080  uint32_t tmp2;
2081 
2082  /* Configure the horizontal start and stop position */
2083  tmp = ((pLayerCfg->WindowX1 + ((hltdc->Instance->BPCR & LTDC_BPCR_AHBP) >> 16U)) << 16U);
2084  LTDC_LAYER(hltdc, LayerIdx)->WHPCR &= ~(LTDC_LxWHPCR_WHSTPOS | LTDC_LxWHPCR_WHSPPOS);
2085  LTDC_LAYER(hltdc, LayerIdx)->WHPCR = ((pLayerCfg->WindowX0 + ((hltdc->Instance->BPCR & LTDC_BPCR_AHBP) >> 16U) + 1U) | tmp);
2086 
2087  /* Configure the vertical start and stop position */
2088  tmp = ((pLayerCfg->WindowY1 + (hltdc->Instance->BPCR & LTDC_BPCR_AVBP)) << 16U);
2089  LTDC_LAYER(hltdc, LayerIdx)->WVPCR &= ~(LTDC_LxWVPCR_WVSTPOS | LTDC_LxWVPCR_WVSPPOS);
2090  LTDC_LAYER(hltdc, LayerIdx)->WVPCR = ((pLayerCfg->WindowY0 + (hltdc->Instance->BPCR & LTDC_BPCR_AVBP) + 1U) | tmp);
2091 
2092  /* Specifies the pixel format */
2093  LTDC_LAYER(hltdc, LayerIdx)->PFCR &= ~(LTDC_LxPFCR_PF);
2094  LTDC_LAYER(hltdc, LayerIdx)->PFCR = (pLayerCfg->PixelFormat);
2095 
2096  /* Configure the default color values */
2097  tmp = ((uint32_t)(pLayerCfg->Backcolor.Green) << 8U);
2098  tmp1 = ((uint32_t)(pLayerCfg->Backcolor.Red) << 16U);
2099  tmp2 = (pLayerCfg->Alpha0 << 24U);
2100  LTDC_LAYER(hltdc, LayerIdx)->DCCR &= ~(LTDC_LxDCCR_DCBLUE | LTDC_LxDCCR_DCGREEN | LTDC_LxDCCR_DCRED | LTDC_LxDCCR_DCALPHA);
2101  LTDC_LAYER(hltdc, LayerIdx)->DCCR = (pLayerCfg->Backcolor.Blue | tmp | tmp1 | tmp2);
2102 
2103  /* Specifies the constant alpha value */
2104  LTDC_LAYER(hltdc, LayerIdx)->CACR &= ~(LTDC_LxCACR_CONSTA);
2105  LTDC_LAYER(hltdc, LayerIdx)->CACR = (pLayerCfg->Alpha);
2106 
2107  /* Specifies the blending factors */
2108  LTDC_LAYER(hltdc, LayerIdx)->BFCR &= ~(LTDC_LxBFCR_BF2 | LTDC_LxBFCR_BF1);
2109  LTDC_LAYER(hltdc, LayerIdx)->BFCR = (pLayerCfg->BlendingFactor1 | pLayerCfg->BlendingFactor2);
2110 
2111  /* Configure the color frame buffer start address */
2112  LTDC_LAYER(hltdc, LayerIdx)->CFBAR &= ~(LTDC_LxCFBAR_CFBADD);
2113  LTDC_LAYER(hltdc, LayerIdx)->CFBAR = (pLayerCfg->FBStartAdress);
2114 
2115  if (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_ARGB8888)
2116  {
2117  tmp = 4U;
2118  }
2119  else if (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_RGB888)
2120  {
2121  tmp = 3U;
2122  }
2123  else if ((pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_ARGB4444) || \
2124  (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_RGB565) || \
2125  (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_ARGB1555) || \
2126  (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_AL88))
2127  {
2128  tmp = 2U;
2129  }
2130  else
2131  {
2132  tmp = 1U;
2133  }
2134 
2135  /* Configure the color frame buffer pitch in byte */
2136  LTDC_LAYER(hltdc, LayerIdx)->CFBLR &= ~(LTDC_LxCFBLR_CFBLL | LTDC_LxCFBLR_CFBP);
2137  LTDC_LAYER(hltdc, LayerIdx)->CFBLR = (((pLayerCfg->ImageWidth * tmp) << 16U) | (((pLayerCfg->WindowX1 - pLayerCfg->WindowX0) * tmp) + 7U));
2138  /* Configure the frame buffer line number */
2139  LTDC_LAYER(hltdc, LayerIdx)->CFBLNR &= ~(LTDC_LxCFBLNR_CFBLNBR);
2140  LTDC_LAYER(hltdc, LayerIdx)->CFBLNR = (pLayerCfg->ImageHeight);
2141 
2142  /* Enable LTDC_Layer by setting LEN bit */
2143  LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_LEN;
2144 }
2145 
2155 #endif /* LTDC */
2156 
2157 #endif /* HAL_LTDC_MODULE_ENABLED */
2158 
2163 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
LTDC_LxWVPCR_WVSPPOS
#define LTDC_LxWVPCR_WVSPPOS
Definition: stm32f469xx.h:13037
assert_param
#define assert_param(expr)
Include module's header file.
Definition: stm32f407/stm32f407g-disc1/Inc/stm32f4xx_hal_conf.h:353
LTDC_IER_FUIE
#define LTDC_IER_FUIE
Definition: stm32f469xx.h:12941
LTDC_AWCR_AAW
#define LTDC_AWCR_AAW
Definition: stm32f469xx.h:12869
LTDC_AWCR_AAH
#define LTDC_AWCR_AAH
Definition: stm32f469xx.h:12866
HAL_StatusTypeDef
HAL_StatusTypeDef
HAL Status structures definition
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:40
LTDC_LxWHPCR_WHSTPOS
#define LTDC_LxWHPCR_WHSTPOS
Definition: stm32f469xx.h:13025
LTDC_LxDCCR_DCBLUE
#define LTDC_LxDCCR_DCBLUE
Definition: stm32f469xx.h:13067
LTDC_GCR_DEN
#define LTDC_GCR_DEN
Definition: stm32f469xx.h:12896
LTDC_LxBFCR_BF2
#define LTDC_LxBFCR_BF2
Definition: stm32f469xx.h:13082
LTDC_TWCR_TOTALH
#define LTDC_TWCR_TOTALH
Definition: stm32f469xx.h:12875
NULL
#define NULL
Definition: porcupine/demo/c/dr_libs/tests/external/miniaudio/extras/speex_resampler/thirdparty/resample.c:92
LTDC_LxCR_CLUTEN
#define LTDC_LxCR_CLUTEN
Definition: stm32f469xx.h:13019
LTDC_IER_RRIE
#define LTDC_IER_RRIE
Definition: stm32f469xx.h:12947
LTDC_TWCR_TOTALW
#define LTDC_TWCR_TOTALW
Definition: stm32f469xx.h:12878
LTDC_GCR_DEPOL
#define LTDC_GCR_DEPOL
Definition: stm32f469xx.h:12902
HAL_UNLOCKED
@ HAL_UNLOCKED
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:53
LTDC_GCR_VSPOL
#define LTDC_GCR_VSPOL
Definition: stm32f469xx.h:12905
LTDC_BCCR_BCBLUE
#define LTDC_BCCR_BCBLUE
Definition: stm32f469xx.h:12926
HAL_ERROR
@ HAL_ERROR
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:43
LTDC_LxCACR_CONSTA
#define LTDC_LxCACR_CONSTA
Definition: stm32f469xx.h:13061
LTDC_ISR_RRIF
#define LTDC_ISR_RRIF
Definition: stm32f469xx.h:12962
LTDC
#define LTDC
Definition: stm32f469xx.h:1336
LTDC_GCR_HSPOL
#define LTDC_GCR_HSPOL
Definition: stm32f469xx.h:12908
LTDC_LxPFCR_PF
#define LTDC_LxPFCR_PF
Definition: stm32f469xx.h:13055
HAL_OK
@ HAL_OK
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:42
LTDC_LxDCCR_DCALPHA
#define LTDC_LxDCCR_DCALPHA
Definition: stm32f469xx.h:13076
LTDC_IER_TERRIE
#define LTDC_IER_TERRIE
Definition: stm32f469xx.h:12944
UNUSED
#define UNUSED(x)
Definition: porcupine/demo/c/dr_libs/old/dr.h:92
LTDC_LxWVPCR_WVSTPOS
#define LTDC_LxWVPCR_WVSTPOS
Definition: stm32f469xx.h:13034
LTDC_GCR_PCPOL
#define LTDC_GCR_PCPOL
Definition: stm32f469xx.h:12899
LTDC_BCCR_BCRED
#define LTDC_BCCR_BCRED
Definition: stm32f469xx.h:12932
LTDC_SRCR_IMR
#define LTDC_SRCR_IMR
Definition: stm32f469xx.h:12917
LTDC_BPCR_AHBP
#define LTDC_BPCR_AHBP
Definition: stm32f469xx.h:12860
LTDC_LxBFCR_BF1
#define LTDC_LxBFCR_BF1
Definition: stm32f469xx.h:13085
__HAL_LOCK
#define __HAL_LOCK(__HANDLE__)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:93
LTDC_LxCKCR_CKGREEN
#define LTDC_LxCKCR_CKGREEN
Definition: stm32f469xx.h:13046
LTDC_LxCR_COLKEN
#define LTDC_LxCR_COLKEN
Definition: stm32f469xx.h:13016
LTDC_LxCFBLNR_CFBLNBR
#define LTDC_LxCFBLNR_CFBLNBR
Definition: stm32f469xx.h:13106
LTDC_LxCR_LEN
#define LTDC_LxCR_LEN
Definition: stm32f469xx.h:13013
LTDC_LxDCCR_DCGREEN
#define LTDC_LxDCCR_DCGREEN
Definition: stm32f469xx.h:13070
LTDC_ISR_TERRIF
#define LTDC_ISR_TERRIF
Definition: stm32f469xx.h:12959
__HAL_UNLOCK
#define __HAL_UNLOCK(__HANDLE__)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:105
LTDC_IER_LIE
#define LTDC_IER_LIE
Definition: stm32f469xx.h:12938
LTDC_LxCFBLR_CFBP
#define LTDC_LxCFBLR_CFBP
Definition: stm32f469xx.h:13100
LTDC_LxCKCR_CKRED
#define LTDC_LxCKCR_CKRED
Definition: stm32f469xx.h:13049
LTDC_SSCR_VSH
#define LTDC_SSCR_VSH
Definition: stm32f469xx.h:12848
LTDC_LxCFBLR_CFBLL
#define LTDC_LxCFBLR_CFBLL
Definition: stm32f469xx.h:13097
LTDC_ISR_LIF
#define LTDC_ISR_LIF
Definition: stm32f469xx.h:12953
LTDC_LxCKCR_CKBLUE
#define LTDC_LxCKCR_CKBLUE
Definition: stm32f469xx.h:13043
LTDC_SSCR_HSW
#define LTDC_SSCR_HSW
Definition: stm32f469xx.h:12851
LTDC_BCCR_BCGREEN
#define LTDC_BCCR_BCGREEN
Definition: stm32f469xx.h:12929
LTDC_ISR_FUIF
#define LTDC_ISR_FUIF
Definition: stm32f469xx.h:12956
LTDC_BPCR_AVBP
#define LTDC_BPCR_AVBP
Definition: stm32f469xx.h:12857
LTDC_LxDCCR_DCRED
#define LTDC_LxDCCR_DCRED
Definition: stm32f469xx.h:13073
LTDC_LxCFBAR_CFBADD
#define LTDC_LxCFBAR_CFBADD
Definition: stm32f469xx.h:13091
READ_REG
#define READ_REG(REG)
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:222
IS_LTDC_ALL_INSTANCE
#define IS_LTDC_ALL_INSTANCE(INSTANCE)
Definition: stm32f469xx.h:19795
LTDC_LxWHPCR_WHSPPOS
#define LTDC_LxWHPCR_WHSPPOS
Definition: stm32f469xx.h:13028


picovoice_driver
Author(s):
autogenerated on Fri Apr 1 2022 02:14:54