STM32F4xx_HAL_Driver  1.8.3
stm32f4xx_hal_dma2d.c
Go to the documentation of this file.
1 
163 /* Includes ------------------------------------------------------------------*/
164 #include "stm32f4xx_hal.h"
165 
166 #ifdef HAL_DMA2D_MODULE_ENABLED
167 #if defined (DMA2D)
168 
178 /* Private types -------------------------------------------------------------*/
179 /* Private define ------------------------------------------------------------*/
187 #define DMA2D_TIMEOUT_ABORT (1000U)
188 #define DMA2D_TIMEOUT_SUSPEND (1000U)
197 /* Private variables ---------------------------------------------------------*/
198 /* Private constants ---------------------------------------------------------*/
199 /* Private macro -------------------------------------------------------------*/
200 /* Private function prototypes -----------------------------------------------*/
204 static void DMA2D_SetConfig(DMA2D_HandleTypeDef *hdma2d, uint32_t pdata, uint32_t DstAddress, uint32_t Width,
205  uint32_t Height);
210 /* Private functions ---------------------------------------------------------*/
211 /* Exported functions --------------------------------------------------------*/
238 HAL_StatusTypeDef HAL_DMA2D_Init(DMA2D_HandleTypeDef *hdma2d)
239 {
240  /* Check the DMA2D peripheral state */
241  if (hdma2d == NULL)
242  {
243  return HAL_ERROR;
244  }
245 
246  /* Check the parameters */
247  assert_param(IS_DMA2D_ALL_INSTANCE(hdma2d->Instance));
248  assert_param(IS_DMA2D_MODE(hdma2d->Init.Mode));
249  assert_param(IS_DMA2D_CMODE(hdma2d->Init.ColorMode));
250  assert_param(IS_DMA2D_OFFSET(hdma2d->Init.OutputOffset));
251 
252 #if (USE_HAL_DMA2D_REGISTER_CALLBACKS == 1)
253  if (hdma2d->State == HAL_DMA2D_STATE_RESET)
254  {
255  /* Reset Callback pointers in HAL_DMA2D_STATE_RESET only */
258  if (hdma2d->MspInitCallback == NULL)
259  {
261  }
262 
263  /* Init the low level hardware */
264  hdma2d->MspInitCallback(hdma2d);
265  }
266 #else
267  if (hdma2d->State == HAL_DMA2D_STATE_RESET)
268  {
269  /* Allocate lock resource and initialize it */
270  hdma2d->Lock = HAL_UNLOCKED;
271  /* Init the low level hardware */
272  HAL_DMA2D_MspInit(hdma2d);
273  }
274 #endif /* (USE_HAL_DMA2D_REGISTER_CALLBACKS) */
275 
276  /* Change DMA2D peripheral state */
277  hdma2d->State = HAL_DMA2D_STATE_BUSY;
278 
279  /* DMA2D CR register configuration -------------------------------------------*/
280  MODIFY_REG(hdma2d->Instance->CR, DMA2D_CR_MODE, hdma2d->Init.Mode);
281 
282  /* DMA2D OPFCCR register configuration ---------------------------------------*/
283  MODIFY_REG(hdma2d->Instance->OPFCCR, DMA2D_OPFCCR_CM, hdma2d->Init.ColorMode);
284 
285  /* DMA2D OOR register configuration ------------------------------------------*/
286  MODIFY_REG(hdma2d->Instance->OOR, DMA2D_OOR_LO, hdma2d->Init.OutputOffset);
287 
288 
289  /* Update error code */
290  hdma2d->ErrorCode = HAL_DMA2D_ERROR_NONE;
291 
292  /* Initialize the DMA2D state*/
293  hdma2d->State = HAL_DMA2D_STATE_READY;
294 
295  return HAL_OK;
296 }
297 
306 HAL_StatusTypeDef HAL_DMA2D_DeInit(DMA2D_HandleTypeDef *hdma2d)
307 {
308 
309  /* Check the DMA2D peripheral state */
310  if (hdma2d == NULL)
311  {
312  return HAL_ERROR;
313  }
314 
315  /* Before aborting any DMA2D transfer or CLUT loading, check
316  first whether or not DMA2D clock is enabled */
317  if (__HAL_RCC_DMA2D_IS_CLK_ENABLED())
318  {
319  /* Abort DMA2D transfer if any */
320  if ((hdma2d->Instance->CR & DMA2D_CR_START) == DMA2D_CR_START)
321  {
322  if (HAL_DMA2D_Abort(hdma2d) != HAL_OK)
323  {
324  /* Issue when aborting DMA2D transfer */
325  return HAL_ERROR;
326  }
327  }
328  else
329  {
330  /* Abort background CLUT loading if any */
331  if ((hdma2d->Instance->BGPFCCR & DMA2D_BGPFCCR_START) == DMA2D_BGPFCCR_START)
332  {
333  if (HAL_DMA2D_CLUTLoading_Abort(hdma2d, 0U) != HAL_OK)
334  {
335  /* Issue when aborting background CLUT loading */
336  return HAL_ERROR;
337  }
338  }
339  else
340  {
341  /* Abort foreground CLUT loading if any */
342  if ((hdma2d->Instance->FGPFCCR & DMA2D_FGPFCCR_START) == DMA2D_FGPFCCR_START)
343  {
344  if (HAL_DMA2D_CLUTLoading_Abort(hdma2d, 1U) != HAL_OK)
345  {
346  /* Issue when aborting foreground CLUT loading */
347  return HAL_ERROR;
348  }
349  }
350  }
351  }
352  }
353 
354  /* Reset DMA2D control registers*/
355  hdma2d->Instance->CR = 0U;
356  hdma2d->Instance->IFCR = 0x3FU;
357  hdma2d->Instance->FGOR = 0U;
358  hdma2d->Instance->BGOR = 0U;
359  hdma2d->Instance->FGPFCCR = 0U;
360  hdma2d->Instance->BGPFCCR = 0U;
361  hdma2d->Instance->OPFCCR = 0U;
362 
363 #if (USE_HAL_DMA2D_REGISTER_CALLBACKS == 1)
364 
365  if (hdma2d->MspDeInitCallback == NULL)
366  {
368  }
369 
370  /* DeInit the low level hardware */
371  hdma2d->MspDeInitCallback(hdma2d);
372 
373 #else
374  /* Carry on with de-initialization of low level hardware */
375  HAL_DMA2D_MspDeInit(hdma2d);
376 #endif /* (USE_HAL_DMA2D_REGISTER_CALLBACKS) */
377 
378  /* Update error code */
379  hdma2d->ErrorCode = HAL_DMA2D_ERROR_NONE;
380 
381  /* Initialize the DMA2D state*/
382  hdma2d->State = HAL_DMA2D_STATE_RESET;
383 
384  /* Release Lock */
385  __HAL_UNLOCK(hdma2d);
386 
387  return HAL_OK;
388 }
389 
397 {
398  /* Prevent unused argument(s) compilation warning */
399  UNUSED(hdma2d);
400 
401  /* NOTE : This function should not be modified; when the callback is needed,
402  the HAL_DMA2D_MspInit can be implemented in the user file.
403  */
404 }
405 
413 {
414  /* Prevent unused argument(s) compilation warning */
415  UNUSED(hdma2d);
416 
417  /* NOTE : This function should not be modified; when the callback is needed,
418  the HAL_DMA2D_MspDeInit can be implemented in the user file.
419  */
420 }
421 
422 #if (USE_HAL_DMA2D_REGISTER_CALLBACKS == 1)
440  pDMA2D_CallbackTypeDef pCallback)
441 {
442  HAL_StatusTypeDef status = HAL_OK;
443 
444  if (pCallback == NULL)
445  {
446  /* Update the error code */
447  hdma2d->ErrorCode |= HAL_DMA2D_ERROR_INVALID_CALLBACK;
448  return HAL_ERROR;
449  }
450  /* Process locked */
451  __HAL_LOCK(hdma2d);
452 
453  if (HAL_DMA2D_STATE_READY == hdma2d->State)
454  {
455  switch (CallbackID)
456  {
458  hdma2d->XferCpltCallback = pCallback;
459  break;
460 
462  hdma2d->XferErrorCallback = pCallback;
463  break;
464 
466  hdma2d->LineEventCallback = pCallback;
467  break;
468 
470  hdma2d->CLUTLoadingCpltCallback = pCallback;
471  break;
472 
474  hdma2d->MspInitCallback = pCallback;
475  break;
476 
478  hdma2d->MspDeInitCallback = pCallback;
479  break;
480 
481  default :
482  /* Update the error code */
483  hdma2d->ErrorCode |= HAL_DMA2D_ERROR_INVALID_CALLBACK;
484  /* update return status */
485  status = HAL_ERROR;
486  break;
487  }
488  }
489  else if (HAL_DMA2D_STATE_RESET == hdma2d->State)
490  {
491  switch (CallbackID)
492  {
494  hdma2d->MspInitCallback = pCallback;
495  break;
496 
498  hdma2d->MspDeInitCallback = pCallback;
499  break;
500 
501  default :
502  /* Update the error code */
503  hdma2d->ErrorCode |= HAL_DMA2D_ERROR_INVALID_CALLBACK;
504  /* update return status */
505  status = HAL_ERROR;
506  break;
507  }
508  }
509  else
510  {
511  /* Update the error code */
512  hdma2d->ErrorCode |= HAL_DMA2D_ERROR_INVALID_CALLBACK;
513  /* update return status */
514  status = HAL_ERROR;
515  }
516 
517  /* Release Lock */
518  __HAL_UNLOCK(hdma2d);
519  return status;
520 }
521 
538 {
539  HAL_StatusTypeDef status = HAL_OK;
540 
541  /* Process locked */
542  __HAL_LOCK(hdma2d);
543 
544  if (HAL_DMA2D_STATE_READY == hdma2d->State)
545  {
546  switch (CallbackID)
547  {
549  hdma2d->XferCpltCallback = NULL;
550  break;
551 
553  hdma2d->XferErrorCallback = NULL;
554  break;
555 
558  break;
559 
562  break;
563 
565  hdma2d->MspInitCallback = HAL_DMA2D_MspInit; /* Legacy weak (overridden) Msp Init */
566  break;
567 
569  hdma2d->MspDeInitCallback = HAL_DMA2D_MspDeInit; /* Legacy weak (overridden) Msp DeInit */
570  break;
571 
572  default :
573  /* Update the error code */
574  hdma2d->ErrorCode |= HAL_DMA2D_ERROR_INVALID_CALLBACK;
575  /* update return status */
576  status = HAL_ERROR;
577  break;
578  }
579  }
580  else if (HAL_DMA2D_STATE_RESET == hdma2d->State)
581  {
582  switch (CallbackID)
583  {
585  hdma2d->MspInitCallback = HAL_DMA2D_MspInit; /* Legacy weak (overridden) Msp Init */
586  break;
587 
589  hdma2d->MspDeInitCallback = HAL_DMA2D_MspDeInit; /* Legacy weak (overridden) Msp DeInit */
590  break;
591 
592  default :
593  /* Update the error code */
594  hdma2d->ErrorCode |= HAL_DMA2D_ERROR_INVALID_CALLBACK;
595  /* update return status */
596  status = HAL_ERROR;
597  break;
598  }
599  }
600  else
601  {
602  /* Update the error code */
603  hdma2d->ErrorCode |= HAL_DMA2D_ERROR_INVALID_CALLBACK;
604  /* update return status */
605  status = HAL_ERROR;
606  }
607 
608  /* Release Lock */
609  __HAL_UNLOCK(hdma2d);
610  return status;
611 }
612 #endif /* USE_HAL_DMA2D_REGISTER_CALLBACKS */
613 
668 HAL_StatusTypeDef HAL_DMA2D_Start(DMA2D_HandleTypeDef *hdma2d, uint32_t pdata, uint32_t DstAddress, uint32_t Width,
669  uint32_t Height)
670 {
671  /* Check the parameters */
672  assert_param(IS_DMA2D_LINE(Height));
673  assert_param(IS_DMA2D_PIXEL(Width));
674 
675  /* Process locked */
676  __HAL_LOCK(hdma2d);
677 
678  /* Change DMA2D peripheral state */
679  hdma2d->State = HAL_DMA2D_STATE_BUSY;
680 
681  /* Configure the source, destination address and the data size */
682  DMA2D_SetConfig(hdma2d, pdata, DstAddress, Width, Height);
683 
684  /* Enable the Peripheral */
685  __HAL_DMA2D_ENABLE(hdma2d);
686 
687  return HAL_OK;
688 }
689 
704 HAL_StatusTypeDef HAL_DMA2D_Start_IT(DMA2D_HandleTypeDef *hdma2d, uint32_t pdata, uint32_t DstAddress, uint32_t Width,
705  uint32_t Height)
706 {
707  /* Check the parameters */
708  assert_param(IS_DMA2D_LINE(Height));
709  assert_param(IS_DMA2D_PIXEL(Width));
710 
711  /* Process locked */
712  __HAL_LOCK(hdma2d);
713 
714  /* Change DMA2D peripheral state */
715  hdma2d->State = HAL_DMA2D_STATE_BUSY;
716 
717  /* Configure the source, destination address and the data size */
718  DMA2D_SetConfig(hdma2d, pdata, DstAddress, Width, Height);
719 
720  /* Enable the transfer complete, transfer error and configuration error interrupts */
721  __HAL_DMA2D_ENABLE_IT(hdma2d, DMA2D_IT_TC | DMA2D_IT_TE | DMA2D_IT_CE);
722 
723  /* Enable the Peripheral */
724  __HAL_DMA2D_ENABLE(hdma2d);
725 
726  return HAL_OK;
727 }
728 
741 HAL_StatusTypeDef HAL_DMA2D_BlendingStart(DMA2D_HandleTypeDef *hdma2d, uint32_t SrcAddress1, uint32_t SrcAddress2,
742  uint32_t DstAddress, uint32_t Width, uint32_t Height)
743 {
744  /* Check the parameters */
745  assert_param(IS_DMA2D_LINE(Height));
746  assert_param(IS_DMA2D_PIXEL(Width));
747 
748  /* Process locked */
749  __HAL_LOCK(hdma2d);
750 
751  /* Change DMA2D peripheral state */
752  hdma2d->State = HAL_DMA2D_STATE_BUSY;
753 
754  /* Configure DMA2D Stream source2 address */
755  WRITE_REG(hdma2d->Instance->BGMAR, SrcAddress2);
756 
757  /* Configure the source, destination address and the data size */
758  DMA2D_SetConfig(hdma2d, SrcAddress1, DstAddress, Width, Height);
759 
760  /* Enable the Peripheral */
761  __HAL_DMA2D_ENABLE(hdma2d);
762 
763  return HAL_OK;
764 }
765 
778 HAL_StatusTypeDef HAL_DMA2D_BlendingStart_IT(DMA2D_HandleTypeDef *hdma2d, uint32_t SrcAddress1, uint32_t SrcAddress2,
779  uint32_t DstAddress, uint32_t Width, uint32_t Height)
780 {
781  /* Check the parameters */
782  assert_param(IS_DMA2D_LINE(Height));
783  assert_param(IS_DMA2D_PIXEL(Width));
784 
785  /* Process locked */
786  __HAL_LOCK(hdma2d);
787 
788  /* Change DMA2D peripheral state */
789  hdma2d->State = HAL_DMA2D_STATE_BUSY;
790 
791  /* Configure DMA2D Stream source2 address */
792  WRITE_REG(hdma2d->Instance->BGMAR, SrcAddress2);
793 
794  /* Configure the source, destination address and the data size */
795  DMA2D_SetConfig(hdma2d, SrcAddress1, DstAddress, Width, Height);
796 
797  /* Enable the transfer complete, transfer error and configuration error interrupts */
798  __HAL_DMA2D_ENABLE_IT(hdma2d, DMA2D_IT_TC | DMA2D_IT_TE | DMA2D_IT_CE);
799 
800  /* Enable the Peripheral */
801  __HAL_DMA2D_ENABLE(hdma2d);
802 
803  return HAL_OK;
804 }
805 
812 HAL_StatusTypeDef HAL_DMA2D_Abort(DMA2D_HandleTypeDef *hdma2d)
813 {
814  uint32_t tickstart;
815 
816  /* Abort the DMA2D transfer */
817  /* START bit is reset to make sure not to set it again, in the event the HW clears it
818  between the register read and the register write by the CPU (writing 0 has no
819  effect on START bitvalue) */
820  MODIFY_REG(hdma2d->Instance->CR, DMA2D_CR_ABORT | DMA2D_CR_START, DMA2D_CR_ABORT);
821 
822  /* Get tick */
823  tickstart = HAL_GetTick();
824 
825  /* Check if the DMA2D is effectively disabled */
826  while ((hdma2d->Instance->CR & DMA2D_CR_START) != 0U)
827  {
828  if ((HAL_GetTick() - tickstart) > DMA2D_TIMEOUT_ABORT)
829  {
830  /* Update error code */
831  hdma2d->ErrorCode |= HAL_DMA2D_ERROR_TIMEOUT;
832 
833  /* Change the DMA2D state */
834  hdma2d->State = HAL_DMA2D_STATE_TIMEOUT;
835 
836  /* Process Unlocked */
837  __HAL_UNLOCK(hdma2d);
838 
839  return HAL_TIMEOUT;
840  }
841  }
842 
843  /* Disable the Transfer Complete, Transfer Error and Configuration Error interrupts */
844  __HAL_DMA2D_DISABLE_IT(hdma2d, DMA2D_IT_TC | DMA2D_IT_TE | DMA2D_IT_CE);
845 
846  /* Change the DMA2D state*/
847  hdma2d->State = HAL_DMA2D_STATE_READY;
848 
849  /* Process Unlocked */
850  __HAL_UNLOCK(hdma2d);
851 
852  return HAL_OK;
853 }
854 
861 HAL_StatusTypeDef HAL_DMA2D_Suspend(DMA2D_HandleTypeDef *hdma2d)
862 {
863  uint32_t tickstart;
864 
865  /* Suspend the DMA2D transfer */
866  /* START bit is reset to make sure not to set it again, in the event the HW clears it
867  between the register read and the register write by the CPU (writing 0 has no
868  effect on START bitvalue). */
869  MODIFY_REG(hdma2d->Instance->CR, DMA2D_CR_SUSP | DMA2D_CR_START, DMA2D_CR_SUSP);
870 
871  /* Get tick */
872  tickstart = HAL_GetTick();
873 
874  /* Check if the DMA2D is effectively suspended */
875  while ((hdma2d->Instance->CR & (DMA2D_CR_SUSP | DMA2D_CR_START)) == DMA2D_CR_START)
876  {
877  if ((HAL_GetTick() - tickstart) > DMA2D_TIMEOUT_SUSPEND)
878  {
879  /* Update error code */
880  hdma2d->ErrorCode |= HAL_DMA2D_ERROR_TIMEOUT;
881 
882  /* Change the DMA2D state */
883  hdma2d->State = HAL_DMA2D_STATE_TIMEOUT;
884 
885  return HAL_TIMEOUT;
886  }
887  }
888 
889  /* Check whether or not a transfer is actually suspended and change the DMA2D state accordingly */
890  if ((hdma2d->Instance->CR & DMA2D_CR_START) != 0U)
891  {
892  hdma2d->State = HAL_DMA2D_STATE_SUSPEND;
893  }
894  else
895  {
896  /* Make sure SUSP bit is cleared since it is meaningless
897  when no transfer is on-going */
898  CLEAR_BIT(hdma2d->Instance->CR, DMA2D_CR_SUSP);
899  }
900 
901  return HAL_OK;
902 }
903 
910 HAL_StatusTypeDef HAL_DMA2D_Resume(DMA2D_HandleTypeDef *hdma2d)
911 {
912  /* Check the SUSP and START bits */
913  if ((hdma2d->Instance->CR & (DMA2D_CR_SUSP | DMA2D_CR_START)) == (DMA2D_CR_SUSP | DMA2D_CR_START))
914  {
915  /* Ongoing transfer is suspended: change the DMA2D state before resuming */
916  hdma2d->State = HAL_DMA2D_STATE_BUSY;
917  }
918 
919  /* Resume the DMA2D transfer */
920  /* START bit is reset to make sure not to set it again, in the event the HW clears it
921  between the register read and the register write by the CPU (writing 0 has no
922  effect on START bitvalue). */
923  CLEAR_BIT(hdma2d->Instance->CR, (DMA2D_CR_SUSP | DMA2D_CR_START));
924 
925  return HAL_OK;
926 }
927 
928 
938 HAL_StatusTypeDef HAL_DMA2D_EnableCLUT(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx)
939 {
940  /* Check the parameters */
941  assert_param(IS_DMA2D_LAYER(LayerIdx));
942 
943  /* Process locked */
944  __HAL_LOCK(hdma2d);
945 
946  /* Change DMA2D peripheral state */
947  hdma2d->State = HAL_DMA2D_STATE_BUSY;
948 
949  if (LayerIdx == DMA2D_BACKGROUND_LAYER)
950  {
951  /* Enable the background CLUT loading */
952  SET_BIT(hdma2d->Instance->BGPFCCR, DMA2D_BGPFCCR_START);
953  }
954  else
955  {
956  /* Enable the foreground CLUT loading */
957  SET_BIT(hdma2d->Instance->FGPFCCR, DMA2D_FGPFCCR_START);
958  }
959 
960  return HAL_OK;
961 }
962 
974 HAL_StatusTypeDef HAL_DMA2D_CLUTStartLoad(DMA2D_HandleTypeDef *hdma2d, DMA2D_CLUTCfgTypeDef *CLUTCfg, uint32_t LayerIdx)
975 {
976  /* Check the parameters */
977  assert_param(IS_DMA2D_LAYER(LayerIdx));
978  assert_param(IS_DMA2D_CLUT_CM(CLUTCfg->CLUTColorMode));
979  assert_param(IS_DMA2D_CLUT_SIZE(CLUTCfg->Size));
980 
981  /* Process locked */
982  __HAL_LOCK(hdma2d);
983 
984  /* Change DMA2D peripheral state */
985  hdma2d->State = HAL_DMA2D_STATE_BUSY;
986 
987  /* Configure the CLUT of the background DMA2D layer */
988  if (LayerIdx == DMA2D_BACKGROUND_LAYER)
989  {
990  /* Write background CLUT memory address */
991  WRITE_REG(hdma2d->Instance->BGCMAR, (uint32_t)CLUTCfg->pCLUT);
992 
993  /* Write background CLUT size and CLUT color mode */
994  MODIFY_REG(hdma2d->Instance->BGPFCCR, (DMA2D_BGPFCCR_CS | DMA2D_BGPFCCR_CCM),
995  ((CLUTCfg->Size << DMA2D_BGPFCCR_CS_Pos) | (CLUTCfg->CLUTColorMode << DMA2D_BGPFCCR_CCM_Pos)));
996 
997  /* Enable the CLUT loading for the background */
998  SET_BIT(hdma2d->Instance->BGPFCCR, DMA2D_BGPFCCR_START);
999  }
1000  /* Configure the CLUT of the foreground DMA2D layer */
1001  else
1002  {
1003  /* Write foreground CLUT memory address */
1004  WRITE_REG(hdma2d->Instance->FGCMAR, (uint32_t)CLUTCfg->pCLUT);
1005 
1006  /* Write foreground CLUT size and CLUT color mode */
1007  MODIFY_REG(hdma2d->Instance->FGPFCCR, (DMA2D_FGPFCCR_CS | DMA2D_FGPFCCR_CCM),
1008  ((CLUTCfg->Size << DMA2D_FGPFCCR_CS_Pos) | (CLUTCfg->CLUTColorMode << DMA2D_FGPFCCR_CCM_Pos)));
1009 
1010  /* Enable the CLUT loading for the foreground */
1011  SET_BIT(hdma2d->Instance->FGPFCCR, DMA2D_FGPFCCR_START);
1012  }
1013 
1014  return HAL_OK;
1015 }
1016 
1029  uint32_t LayerIdx)
1030 {
1031  /* Check the parameters */
1032  assert_param(IS_DMA2D_LAYER(LayerIdx));
1033  assert_param(IS_DMA2D_CLUT_CM(CLUTCfg->CLUTColorMode));
1034  assert_param(IS_DMA2D_CLUT_SIZE(CLUTCfg->Size));
1035 
1036  /* Process locked */
1037  __HAL_LOCK(hdma2d);
1038 
1039  /* Change DMA2D peripheral state */
1040  hdma2d->State = HAL_DMA2D_STATE_BUSY;
1041 
1042  /* Configure the CLUT of the background DMA2D layer */
1043  if (LayerIdx == DMA2D_BACKGROUND_LAYER)
1044  {
1045  /* Write background CLUT memory address */
1046  WRITE_REG(hdma2d->Instance->BGCMAR, (uint32_t)CLUTCfg->pCLUT);
1047 
1048  /* Write background CLUT size and CLUT color mode */
1049  MODIFY_REG(hdma2d->Instance->BGPFCCR, (DMA2D_BGPFCCR_CS | DMA2D_BGPFCCR_CCM),
1050  ((CLUTCfg->Size << DMA2D_BGPFCCR_CS_Pos) | (CLUTCfg->CLUTColorMode << DMA2D_BGPFCCR_CCM_Pos)));
1051 
1052  /* Enable the CLUT Transfer Complete, transfer Error, configuration Error and CLUT Access Error interrupts */
1053  __HAL_DMA2D_ENABLE_IT(hdma2d, DMA2D_IT_CTC | DMA2D_IT_TE | DMA2D_IT_CE | DMA2D_IT_CAE);
1054 
1055  /* Enable the CLUT loading for the background */
1056  SET_BIT(hdma2d->Instance->BGPFCCR, DMA2D_BGPFCCR_START);
1057  }
1058  /* Configure the CLUT of the foreground DMA2D layer */
1059  else
1060  {
1061  /* Write foreground CLUT memory address */
1062  WRITE_REG(hdma2d->Instance->FGCMAR, (uint32_t)CLUTCfg->pCLUT);
1063 
1064  /* Write foreground CLUT size and CLUT color mode */
1065  MODIFY_REG(hdma2d->Instance->FGPFCCR, (DMA2D_FGPFCCR_CS | DMA2D_FGPFCCR_CCM),
1066  ((CLUTCfg->Size << DMA2D_FGPFCCR_CS_Pos) | (CLUTCfg->CLUTColorMode << DMA2D_FGPFCCR_CCM_Pos)));
1067 
1068  /* Enable the CLUT Transfer Complete, transfer Error, configuration Error and CLUT Access Error interrupts */
1069  __HAL_DMA2D_ENABLE_IT(hdma2d, DMA2D_IT_CTC | DMA2D_IT_TE | DMA2D_IT_CE | DMA2D_IT_CAE);
1070 
1071  /* Enable the CLUT loading for the foreground */
1072  SET_BIT(hdma2d->Instance->FGPFCCR, DMA2D_FGPFCCR_START);
1073  }
1074 
1075  return HAL_OK;
1076 }
1077 
1092 HAL_StatusTypeDef HAL_DMA2D_CLUTLoad(DMA2D_HandleTypeDef *hdma2d, DMA2D_CLUTCfgTypeDef CLUTCfg, uint32_t LayerIdx)
1093 {
1094  /* Check the parameters */
1095  assert_param(IS_DMA2D_LAYER(LayerIdx));
1096  assert_param(IS_DMA2D_CLUT_CM(CLUTCfg.CLUTColorMode));
1097  assert_param(IS_DMA2D_CLUT_SIZE(CLUTCfg.Size));
1098 
1099  /* Process locked */
1100  __HAL_LOCK(hdma2d);
1101 
1102  /* Change DMA2D peripheral state */
1103  hdma2d->State = HAL_DMA2D_STATE_BUSY;
1104 
1105  /* Configure the CLUT of the background DMA2D layer */
1106  if (LayerIdx == DMA2D_BACKGROUND_LAYER)
1107  {
1108  /* Write background CLUT memory address */
1109  WRITE_REG(hdma2d->Instance->BGCMAR, (uint32_t)CLUTCfg.pCLUT);
1110 
1111  /* Write background CLUT size and CLUT color mode */
1112  MODIFY_REG(hdma2d->Instance->BGPFCCR, (DMA2D_BGPFCCR_CS | DMA2D_BGPFCCR_CCM),
1113  ((CLUTCfg.Size << DMA2D_BGPFCCR_CS_Pos) | (CLUTCfg.CLUTColorMode << DMA2D_BGPFCCR_CCM_Pos)));
1114 
1115  /* Enable the CLUT loading for the background */
1116  SET_BIT(hdma2d->Instance->BGPFCCR, DMA2D_BGPFCCR_START);
1117  }
1118  /* Configure the CLUT of the foreground DMA2D layer */
1119  else
1120  {
1121  /* Write foreground CLUT memory address */
1122  WRITE_REG(hdma2d->Instance->FGCMAR, (uint32_t)CLUTCfg.pCLUT);
1123 
1124  /* Write foreground CLUT size and CLUT color mode */
1125  MODIFY_REG(hdma2d->Instance->FGPFCCR, (DMA2D_FGPFCCR_CS | DMA2D_FGPFCCR_CCM),
1126  ((CLUTCfg.Size << DMA2D_FGPFCCR_CS_Pos) | (CLUTCfg.CLUTColorMode << DMA2D_FGPFCCR_CCM_Pos)));
1127 
1128  /* Enable the CLUT loading for the foreground */
1129  SET_BIT(hdma2d->Instance->FGPFCCR, DMA2D_FGPFCCR_START);
1130  }
1131 
1132  return HAL_OK;
1133 }
1134 
1149 HAL_StatusTypeDef HAL_DMA2D_CLUTLoad_IT(DMA2D_HandleTypeDef *hdma2d, DMA2D_CLUTCfgTypeDef CLUTCfg, uint32_t LayerIdx)
1150 {
1151  /* Check the parameters */
1152  assert_param(IS_DMA2D_LAYER(LayerIdx));
1153  assert_param(IS_DMA2D_CLUT_CM(CLUTCfg.CLUTColorMode));
1154  assert_param(IS_DMA2D_CLUT_SIZE(CLUTCfg.Size));
1155 
1156  /* Process locked */
1157  __HAL_LOCK(hdma2d);
1158 
1159  /* Change DMA2D peripheral state */
1160  hdma2d->State = HAL_DMA2D_STATE_BUSY;
1161 
1162  /* Configure the CLUT of the background DMA2D layer */
1163  if (LayerIdx == DMA2D_BACKGROUND_LAYER)
1164  {
1165  /* Write background CLUT memory address */
1166  WRITE_REG(hdma2d->Instance->BGCMAR, (uint32_t)CLUTCfg.pCLUT);
1167 
1168  /* Write background CLUT size and CLUT color mode */
1169  MODIFY_REG(hdma2d->Instance->BGPFCCR, (DMA2D_BGPFCCR_CS | DMA2D_BGPFCCR_CCM),
1170  ((CLUTCfg.Size << DMA2D_BGPFCCR_CS_Pos) | (CLUTCfg.CLUTColorMode << DMA2D_BGPFCCR_CCM_Pos)));
1171 
1172  /* Enable the CLUT Transfer Complete, transfer Error, configuration Error and CLUT Access Error interrupts */
1173  __HAL_DMA2D_ENABLE_IT(hdma2d, DMA2D_IT_CTC | DMA2D_IT_TE | DMA2D_IT_CE | DMA2D_IT_CAE);
1174 
1175  /* Enable the CLUT loading for the background */
1176  SET_BIT(hdma2d->Instance->BGPFCCR, DMA2D_BGPFCCR_START);
1177  }
1178  /* Configure the CLUT of the foreground DMA2D layer */
1179  else
1180  {
1181  /* Write foreground CLUT memory address */
1182  WRITE_REG(hdma2d->Instance->FGCMAR, (uint32_t)CLUTCfg.pCLUT);
1183 
1184  /* Write foreground CLUT size and CLUT color mode */
1185  MODIFY_REG(hdma2d->Instance->FGPFCCR, (DMA2D_FGPFCCR_CS | DMA2D_FGPFCCR_CCM),
1186  ((CLUTCfg.Size << DMA2D_FGPFCCR_CS_Pos) | (CLUTCfg.CLUTColorMode << DMA2D_FGPFCCR_CCM_Pos)));
1187 
1188  /* Enable the CLUT Transfer Complete, transfer Error, configuration Error and CLUT Access Error interrupts */
1189  __HAL_DMA2D_ENABLE_IT(hdma2d, DMA2D_IT_CTC | DMA2D_IT_TE | DMA2D_IT_CE | DMA2D_IT_CAE);
1190 
1191  /* Enable the CLUT loading for the foreground */
1192  SET_BIT(hdma2d->Instance->FGPFCCR, DMA2D_FGPFCCR_START);
1193  }
1194 
1195  return HAL_OK;
1196 }
1197 
1207 HAL_StatusTypeDef HAL_DMA2D_CLUTLoading_Abort(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx)
1208 {
1209  uint32_t tickstart;
1210  const __IO uint32_t *reg = &(hdma2d->Instance->BGPFCCR); /* by default, point at background register */
1211 
1212  /* Abort the CLUT loading */
1213  SET_BIT(hdma2d->Instance->CR, DMA2D_CR_ABORT);
1214 
1215  /* If foreground CLUT loading is considered, update local variables */
1216  if (LayerIdx == DMA2D_FOREGROUND_LAYER)
1217  {
1218  reg = &(hdma2d->Instance->FGPFCCR);
1219  }
1220 
1221 
1222  /* Get tick */
1223  tickstart = HAL_GetTick();
1224 
1225  /* Check if the CLUT loading is aborted */
1226  while ((*reg & DMA2D_BGPFCCR_START) != 0U)
1227  {
1228  if ((HAL_GetTick() - tickstart) > DMA2D_TIMEOUT_ABORT)
1229  {
1230  /* Update error code */
1231  hdma2d->ErrorCode |= HAL_DMA2D_ERROR_TIMEOUT;
1232 
1233  /* Change the DMA2D state */
1234  hdma2d->State = HAL_DMA2D_STATE_TIMEOUT;
1235 
1236  /* Process Unlocked */
1237  __HAL_UNLOCK(hdma2d);
1238 
1239  return HAL_TIMEOUT;
1240  }
1241  }
1242 
1243  /* Disable the CLUT Transfer Complete, Transfer Error, Configuration Error and CLUT Access Error interrupts */
1244  __HAL_DMA2D_DISABLE_IT(hdma2d, DMA2D_IT_CTC | DMA2D_IT_TE | DMA2D_IT_CE | DMA2D_IT_CAE);
1245 
1246  /* Change the DMA2D state*/
1247  hdma2d->State = HAL_DMA2D_STATE_READY;
1248 
1249  /* Process Unlocked */
1250  __HAL_UNLOCK(hdma2d);
1251 
1252  return HAL_OK;
1253 }
1254 
1264 HAL_StatusTypeDef HAL_DMA2D_CLUTLoading_Suspend(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx)
1265 {
1266  uint32_t tickstart;
1267  uint32_t loadsuspended;
1268  const __IO uint32_t *reg = &(hdma2d->Instance->BGPFCCR); /* by default, point at background register */
1269 
1270  /* Suspend the CLUT loading */
1271  SET_BIT(hdma2d->Instance->CR, DMA2D_CR_SUSP);
1272 
1273  /* If foreground CLUT loading is considered, update local variables */
1274  if (LayerIdx == DMA2D_FOREGROUND_LAYER)
1275  {
1276  reg = &(hdma2d->Instance->FGPFCCR);
1277  }
1278 
1279  /* Get tick */
1280  tickstart = HAL_GetTick();
1281 
1282  /* Check if the CLUT loading is suspended */
1283  /* 1st condition: Suspend Check */
1284  loadsuspended = ((hdma2d->Instance->CR & DMA2D_CR_SUSP) == DMA2D_CR_SUSP) ? 1UL : 0UL;
1285  /* 2nd condition: Not Start Check */
1286  loadsuspended |= ((*reg & DMA2D_BGPFCCR_START) != DMA2D_BGPFCCR_START) ? 1UL : 0UL;
1287  while (loadsuspended == 0UL)
1288  {
1289  if ((HAL_GetTick() - tickstart) > DMA2D_TIMEOUT_SUSPEND)
1290  {
1291  /* Update error code */
1292  hdma2d->ErrorCode |= HAL_DMA2D_ERROR_TIMEOUT;
1293 
1294  /* Change the DMA2D state */
1295  hdma2d->State = HAL_DMA2D_STATE_TIMEOUT;
1296 
1297  return HAL_TIMEOUT;
1298  }
1299  /* 1st condition: Suspend Check */
1300  loadsuspended = ((hdma2d->Instance->CR & DMA2D_CR_SUSP) == DMA2D_CR_SUSP) ? 1UL : 0UL;
1301  /* 2nd condition: Not Start Check */
1302  loadsuspended |= ((*reg & DMA2D_BGPFCCR_START) != DMA2D_BGPFCCR_START) ? 1UL : 0UL;
1303  }
1304 
1305  /* Check whether or not a transfer is actually suspended and change the DMA2D state accordingly */
1306  if ((*reg & DMA2D_BGPFCCR_START) != 0U)
1307  {
1308  hdma2d->State = HAL_DMA2D_STATE_SUSPEND;
1309  }
1310  else
1311  {
1312  /* Make sure SUSP bit is cleared since it is meaningless
1313  when no transfer is on-going */
1314  CLEAR_BIT(hdma2d->Instance->CR, DMA2D_CR_SUSP);
1315  }
1316 
1317  return HAL_OK;
1318 }
1319 
1329 HAL_StatusTypeDef HAL_DMA2D_CLUTLoading_Resume(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx)
1330 {
1331  /* Check the SUSP and START bits for background or foreground CLUT loading */
1332  if (LayerIdx == DMA2D_BACKGROUND_LAYER)
1333  {
1334  /* Background CLUT loading suspension check */
1335  if ((hdma2d->Instance->CR & DMA2D_CR_SUSP) == DMA2D_CR_SUSP)
1336  {
1337  if ((hdma2d->Instance->BGPFCCR & DMA2D_BGPFCCR_START) == DMA2D_BGPFCCR_START)
1338  {
1339  /* Ongoing CLUT loading is suspended: change the DMA2D state before resuming */
1340  hdma2d->State = HAL_DMA2D_STATE_BUSY;
1341  }
1342  }
1343  }
1344  else
1345  {
1346  /* Foreground CLUT loading suspension check */
1347  if ((hdma2d->Instance->CR & DMA2D_CR_SUSP) == DMA2D_CR_SUSP)
1348  {
1349  if ((hdma2d->Instance->FGPFCCR & DMA2D_FGPFCCR_START) == DMA2D_FGPFCCR_START)
1350  {
1351  /* Ongoing CLUT loading is suspended: change the DMA2D state before resuming */
1352  hdma2d->State = HAL_DMA2D_STATE_BUSY;
1353  }
1354  }
1355  }
1356 
1357  /* Resume the CLUT loading */
1358  CLEAR_BIT(hdma2d->Instance->CR, DMA2D_CR_SUSP);
1359 
1360  return HAL_OK;
1361 }
1362 
1363 
1372 HAL_StatusTypeDef HAL_DMA2D_PollForTransfer(DMA2D_HandleTypeDef *hdma2d, uint32_t Timeout)
1373 {
1374  uint32_t tickstart;
1375  uint32_t layer_start;
1376  __IO uint32_t isrflags = 0x0U;
1377 
1378  /* Polling for DMA2D transfer */
1379  if ((hdma2d->Instance->CR & DMA2D_CR_START) != 0U)
1380  {
1381  /* Get tick */
1382  tickstart = HAL_GetTick();
1383 
1384  while (__HAL_DMA2D_GET_FLAG(hdma2d, DMA2D_FLAG_TC) == 0U)
1385  {
1386  isrflags = READ_REG(hdma2d->Instance->ISR);
1387  if ((isrflags & (DMA2D_FLAG_CE | DMA2D_FLAG_TE)) != 0U)
1388  {
1389  if ((isrflags & DMA2D_FLAG_CE) != 0U)
1390  {
1391  hdma2d->ErrorCode |= HAL_DMA2D_ERROR_CE;
1392  }
1393  if ((isrflags & DMA2D_FLAG_TE) != 0U)
1394  {
1395  hdma2d->ErrorCode |= HAL_DMA2D_ERROR_TE;
1396  }
1397  /* Clear the transfer and configuration error flags */
1398  __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_CE | DMA2D_FLAG_TE);
1399 
1400  /* Change DMA2D state */
1401  hdma2d->State = HAL_DMA2D_STATE_ERROR;
1402 
1403  /* Process unlocked */
1404  __HAL_UNLOCK(hdma2d);
1405 
1406  return HAL_ERROR;
1407  }
1408  /* Check for the Timeout */
1409  if (Timeout != HAL_MAX_DELAY)
1410  {
1411  if (((HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
1412  {
1413  /* Update error code */
1414  hdma2d->ErrorCode |= HAL_DMA2D_ERROR_TIMEOUT;
1415 
1416  /* Change the DMA2D state */
1417  hdma2d->State = HAL_DMA2D_STATE_TIMEOUT;
1418 
1419  /* Process unlocked */
1420  __HAL_UNLOCK(hdma2d);
1421 
1422  return HAL_TIMEOUT;
1423  }
1424  }
1425  }
1426  }
1427  /* Polling for CLUT loading (foreground or background) */
1428  layer_start = hdma2d->Instance->FGPFCCR & DMA2D_FGPFCCR_START;
1429  layer_start |= hdma2d->Instance->BGPFCCR & DMA2D_BGPFCCR_START;
1430  if (layer_start != 0U)
1431  {
1432  /* Get tick */
1433  tickstart = HAL_GetTick();
1434 
1435  while (__HAL_DMA2D_GET_FLAG(hdma2d, DMA2D_FLAG_CTC) == 0U)
1436  {
1437  isrflags = READ_REG(hdma2d->Instance->ISR);
1438  if ((isrflags & (DMA2D_FLAG_CAE | DMA2D_FLAG_CE | DMA2D_FLAG_TE)) != 0U)
1439  {
1440  if ((isrflags & DMA2D_FLAG_CAE) != 0U)
1441  {
1442  hdma2d->ErrorCode |= HAL_DMA2D_ERROR_CAE;
1443  }
1444  if ((isrflags & DMA2D_FLAG_CE) != 0U)
1445  {
1446  hdma2d->ErrorCode |= HAL_DMA2D_ERROR_CE;
1447  }
1448  if ((isrflags & DMA2D_FLAG_TE) != 0U)
1449  {
1450  hdma2d->ErrorCode |= HAL_DMA2D_ERROR_TE;
1451  }
1452  /* Clear the CLUT Access Error, Configuration Error and Transfer Error flags */
1453  __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_CAE | DMA2D_FLAG_CE | DMA2D_FLAG_TE);
1454 
1455  /* Change DMA2D state */
1456  hdma2d->State = HAL_DMA2D_STATE_ERROR;
1457 
1458  /* Process unlocked */
1459  __HAL_UNLOCK(hdma2d);
1460 
1461  return HAL_ERROR;
1462  }
1463  /* Check for the Timeout */
1464  if (Timeout != HAL_MAX_DELAY)
1465  {
1466  if (((HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
1467  {
1468  /* Update error code */
1469  hdma2d->ErrorCode |= HAL_DMA2D_ERROR_TIMEOUT;
1470 
1471  /* Change the DMA2D state */
1472  hdma2d->State = HAL_DMA2D_STATE_TIMEOUT;
1473 
1474  /* Process unlocked */
1475  __HAL_UNLOCK(hdma2d);
1476 
1477  return HAL_TIMEOUT;
1478  }
1479  }
1480  }
1481  }
1482 
1483  /* Clear the transfer complete and CLUT loading flags */
1484  __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_TC | DMA2D_FLAG_CTC);
1485 
1486  /* Change DMA2D state */
1487  hdma2d->State = HAL_DMA2D_STATE_READY;
1488 
1489  /* Process unlocked */
1490  __HAL_UNLOCK(hdma2d);
1491 
1492  return HAL_OK;
1493 }
1501 {
1502  uint32_t isrflags = READ_REG(hdma2d->Instance->ISR);
1503  uint32_t crflags = READ_REG(hdma2d->Instance->CR);
1504 
1505  /* Transfer Error Interrupt management ***************************************/
1506  if ((isrflags & DMA2D_FLAG_TE) != 0U)
1507  {
1508  if ((crflags & DMA2D_IT_TE) != 0U)
1509  {
1510  /* Disable the transfer Error interrupt */
1511  __HAL_DMA2D_DISABLE_IT(hdma2d, DMA2D_IT_TE);
1512 
1513  /* Update error code */
1514  hdma2d->ErrorCode |= HAL_DMA2D_ERROR_TE;
1515 
1516  /* Clear the transfer error flag */
1517  __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_TE);
1518 
1519  /* Change DMA2D state */
1520  hdma2d->State = HAL_DMA2D_STATE_ERROR;
1521 
1522  /* Process Unlocked */
1523  __HAL_UNLOCK(hdma2d);
1524 
1525  if (hdma2d->XferErrorCallback != NULL)
1526  {
1527  /* Transfer error Callback */
1528  hdma2d->XferErrorCallback(hdma2d);
1529  }
1530  }
1531  }
1532  /* Configuration Error Interrupt management **********************************/
1533  if ((isrflags & DMA2D_FLAG_CE) != 0U)
1534  {
1535  if ((crflags & DMA2D_IT_CE) != 0U)
1536  {
1537  /* Disable the Configuration Error interrupt */
1538  __HAL_DMA2D_DISABLE_IT(hdma2d, DMA2D_IT_CE);
1539 
1540  /* Clear the Configuration error flag */
1541  __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_CE);
1542 
1543  /* Update error code */
1544  hdma2d->ErrorCode |= HAL_DMA2D_ERROR_CE;
1545 
1546  /* Change DMA2D state */
1547  hdma2d->State = HAL_DMA2D_STATE_ERROR;
1548 
1549  /* Process Unlocked */
1550  __HAL_UNLOCK(hdma2d);
1551 
1552  if (hdma2d->XferErrorCallback != NULL)
1553  {
1554  /* Transfer error Callback */
1555  hdma2d->XferErrorCallback(hdma2d);
1556  }
1557  }
1558  }
1559  /* CLUT access Error Interrupt management ***********************************/
1560  if ((isrflags & DMA2D_FLAG_CAE) != 0U)
1561  {
1562  if ((crflags & DMA2D_IT_CAE) != 0U)
1563  {
1564  /* Disable the CLUT access error interrupt */
1565  __HAL_DMA2D_DISABLE_IT(hdma2d, DMA2D_IT_CAE);
1566 
1567  /* Clear the CLUT access error flag */
1568  __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_CAE);
1569 
1570  /* Update error code */
1571  hdma2d->ErrorCode |= HAL_DMA2D_ERROR_CAE;
1572 
1573  /* Change DMA2D state */
1574  hdma2d->State = HAL_DMA2D_STATE_ERROR;
1575 
1576  /* Process Unlocked */
1577  __HAL_UNLOCK(hdma2d);
1578 
1579  if (hdma2d->XferErrorCallback != NULL)
1580  {
1581  /* Transfer error Callback */
1582  hdma2d->XferErrorCallback(hdma2d);
1583  }
1584  }
1585  }
1586  /* Transfer watermark Interrupt management **********************************/
1587  if ((isrflags & DMA2D_FLAG_TW) != 0U)
1588  {
1589  if ((crflags & DMA2D_IT_TW) != 0U)
1590  {
1591  /* Disable the transfer watermark interrupt */
1592  __HAL_DMA2D_DISABLE_IT(hdma2d, DMA2D_IT_TW);
1593 
1594  /* Clear the transfer watermark flag */
1595  __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_TW);
1596 
1597  /* Transfer watermark Callback */
1598 #if (USE_HAL_DMA2D_REGISTER_CALLBACKS == 1)
1599  hdma2d->LineEventCallback(hdma2d);
1600 #else
1602 #endif /* USE_HAL_DMA2D_REGISTER_CALLBACKS */
1603 
1604  }
1605  }
1606  /* Transfer Complete Interrupt management ************************************/
1607  if ((isrflags & DMA2D_FLAG_TC) != 0U)
1608  {
1609  if ((crflags & DMA2D_IT_TC) != 0U)
1610  {
1611  /* Disable the transfer complete interrupt */
1612  __HAL_DMA2D_DISABLE_IT(hdma2d, DMA2D_IT_TC);
1613 
1614  /* Clear the transfer complete flag */
1615  __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_TC);
1616 
1617  /* Update error code */
1618  hdma2d->ErrorCode |= HAL_DMA2D_ERROR_NONE;
1619 
1620  /* Change DMA2D state */
1621  hdma2d->State = HAL_DMA2D_STATE_READY;
1622 
1623  /* Process Unlocked */
1624  __HAL_UNLOCK(hdma2d);
1625 
1626  if (hdma2d->XferCpltCallback != NULL)
1627  {
1628  /* Transfer complete Callback */
1629  hdma2d->XferCpltCallback(hdma2d);
1630  }
1631  }
1632  }
1633  /* CLUT Transfer Complete Interrupt management ******************************/
1634  if ((isrflags & DMA2D_FLAG_CTC) != 0U)
1635  {
1636  if ((crflags & DMA2D_IT_CTC) != 0U)
1637  {
1638  /* Disable the CLUT transfer complete interrupt */
1639  __HAL_DMA2D_DISABLE_IT(hdma2d, DMA2D_IT_CTC);
1640 
1641  /* Clear the CLUT transfer complete flag */
1642  __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_CTC);
1643 
1644  /* Update error code */
1645  hdma2d->ErrorCode |= HAL_DMA2D_ERROR_NONE;
1646 
1647  /* Change DMA2D state */
1648  hdma2d->State = HAL_DMA2D_STATE_READY;
1649 
1650  /* Process Unlocked */
1651  __HAL_UNLOCK(hdma2d);
1652 
1653  /* CLUT Transfer complete Callback */
1654 #if (USE_HAL_DMA2D_REGISTER_CALLBACKS == 1)
1655  hdma2d->CLUTLoadingCpltCallback(hdma2d);
1656 #else
1658 #endif /* USE_HAL_DMA2D_REGISTER_CALLBACKS */
1659  }
1660  }
1661 
1662 }
1663 
1671 {
1672  /* Prevent unused argument(s) compilation warning */
1673  UNUSED(hdma2d);
1674 
1675  /* NOTE : This function should not be modified; when the callback is needed,
1676  the HAL_DMA2D_LineEventCallback can be implemented in the user file.
1677  */
1678 }
1679 
1687 {
1688  /* Prevent unused argument(s) compilation warning */
1689  UNUSED(hdma2d);
1690 
1691  /* NOTE : This function should not be modified; when the callback is needed,
1692  the HAL_DMA2D_CLUTLoadingCpltCallback can be implemented in the user file.
1693  */
1694 }
1695 
1729 HAL_StatusTypeDef HAL_DMA2D_ConfigLayer(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx)
1730 {
1731  DMA2D_LayerCfgTypeDef *pLayerCfg;
1732  uint32_t regMask;
1733  uint32_t regValue;
1734 
1735  /* Check the parameters */
1736  assert_param(IS_DMA2D_LAYER(LayerIdx));
1737  assert_param(IS_DMA2D_OFFSET(hdma2d->LayerCfg[LayerIdx].InputOffset));
1738  if (hdma2d->Init.Mode != DMA2D_R2M)
1739  {
1740  assert_param(IS_DMA2D_INPUT_COLOR_MODE(hdma2d->LayerCfg[LayerIdx].InputColorMode));
1741  if (hdma2d->Init.Mode != DMA2D_M2M)
1742  {
1743  assert_param(IS_DMA2D_ALPHA_MODE(hdma2d->LayerCfg[LayerIdx].AlphaMode));
1744  }
1745  }
1746 
1747  /* Process locked */
1748  __HAL_LOCK(hdma2d);
1749 
1750  /* Change DMA2D peripheral state */
1751  hdma2d->State = HAL_DMA2D_STATE_BUSY;
1752 
1753  pLayerCfg = &hdma2d->LayerCfg[LayerIdx];
1754 
1755  /* Prepare the value to be written to the BGPFCCR or FGPFCCR register */
1756  regValue = pLayerCfg->InputColorMode | (pLayerCfg->AlphaMode << DMA2D_BGPFCCR_AM_Pos);
1757  regMask = DMA2D_BGPFCCR_CM | DMA2D_BGPFCCR_AM | DMA2D_BGPFCCR_ALPHA;
1758 
1759 
1760  if ((pLayerCfg->InputColorMode == DMA2D_INPUT_A4) || (pLayerCfg->InputColorMode == DMA2D_INPUT_A8))
1761  {
1762  regValue |= (pLayerCfg->InputAlpha & DMA2D_BGPFCCR_ALPHA);
1763  }
1764  else
1765  {
1766  regValue |= (pLayerCfg->InputAlpha << DMA2D_BGPFCCR_ALPHA_Pos);
1767  }
1768 
1769  /* Configure the background DMA2D layer */
1770  if (LayerIdx == DMA2D_BACKGROUND_LAYER)
1771  {
1772  /* Write DMA2D BGPFCCR register */
1773  MODIFY_REG(hdma2d->Instance->BGPFCCR, regMask, regValue);
1774 
1775  /* DMA2D BGOR register configuration -------------------------------------*/
1776  WRITE_REG(hdma2d->Instance->BGOR, pLayerCfg->InputOffset);
1777 
1778  /* DMA2D BGCOLR register configuration -------------------------------------*/
1779  if ((pLayerCfg->InputColorMode == DMA2D_INPUT_A4) || (pLayerCfg->InputColorMode == DMA2D_INPUT_A8))
1780  {
1781  WRITE_REG(hdma2d->Instance->BGCOLR, pLayerCfg->InputAlpha & (DMA2D_BGCOLR_BLUE | DMA2D_BGCOLR_GREEN | \
1782  DMA2D_BGCOLR_RED));
1783  }
1784  }
1785  /* Configure the foreground DMA2D layer */
1786  else
1787  {
1788 
1789 
1790  /* Write DMA2D FGPFCCR register */
1791  MODIFY_REG(hdma2d->Instance->FGPFCCR, regMask, regValue);
1792 
1793  /* DMA2D FGOR register configuration -------------------------------------*/
1794  WRITE_REG(hdma2d->Instance->FGOR, pLayerCfg->InputOffset);
1795 
1796  /* DMA2D FGCOLR register configuration -------------------------------------*/
1797  if ((pLayerCfg->InputColorMode == DMA2D_INPUT_A4) || (pLayerCfg->InputColorMode == DMA2D_INPUT_A8))
1798  {
1799  WRITE_REG(hdma2d->Instance->FGCOLR, pLayerCfg->InputAlpha & (DMA2D_FGCOLR_BLUE | DMA2D_FGCOLR_GREEN | \
1800  DMA2D_FGCOLR_RED));
1801  }
1802  }
1803  /* Initialize the DMA2D state*/
1804  hdma2d->State = HAL_DMA2D_STATE_READY;
1805 
1806  /* Process unlocked */
1807  __HAL_UNLOCK(hdma2d);
1808 
1809  return HAL_OK;
1810 }
1811 
1826 HAL_StatusTypeDef HAL_DMA2D_ConfigCLUT(DMA2D_HandleTypeDef *hdma2d, DMA2D_CLUTCfgTypeDef CLUTCfg, uint32_t LayerIdx)
1827 {
1828  /* Check the parameters */
1829  assert_param(IS_DMA2D_LAYER(LayerIdx));
1830  assert_param(IS_DMA2D_CLUT_CM(CLUTCfg.CLUTColorMode));
1831  assert_param(IS_DMA2D_CLUT_SIZE(CLUTCfg.Size));
1832 
1833  /* Process locked */
1834  __HAL_LOCK(hdma2d);
1835 
1836  /* Change DMA2D peripheral state */
1837  hdma2d->State = HAL_DMA2D_STATE_BUSY;
1838 
1839  /* Configure the CLUT of the background DMA2D layer */
1840  if (LayerIdx == DMA2D_BACKGROUND_LAYER)
1841  {
1842  /* Write background CLUT memory address */
1843  WRITE_REG(hdma2d->Instance->BGCMAR, (uint32_t)CLUTCfg.pCLUT);
1844 
1845  /* Write background CLUT size and CLUT color mode */
1846  MODIFY_REG(hdma2d->Instance->BGPFCCR, (DMA2D_BGPFCCR_CS | DMA2D_BGPFCCR_CCM),
1847  ((CLUTCfg.Size << DMA2D_BGPFCCR_CS_Pos) | (CLUTCfg.CLUTColorMode << DMA2D_BGPFCCR_CCM_Pos)));
1848  }
1849  /* Configure the CLUT of the foreground DMA2D layer */
1850  else
1851  {
1852  /* Write foreground CLUT memory address */
1853  WRITE_REG(hdma2d->Instance->FGCMAR, (uint32_t)CLUTCfg.pCLUT);
1854 
1855  /* Write foreground CLUT size and CLUT color mode */
1856  MODIFY_REG(hdma2d->Instance->FGPFCCR, (DMA2D_FGPFCCR_CS | DMA2D_FGPFCCR_CCM),
1857  ((CLUTCfg.Size << DMA2D_FGPFCCR_CS_Pos) | (CLUTCfg.CLUTColorMode << DMA2D_FGPFCCR_CCM_Pos)));
1858  }
1859 
1860  /* Set the DMA2D state to Ready*/
1861  hdma2d->State = HAL_DMA2D_STATE_READY;
1862 
1863  /* Process unlocked */
1864  __HAL_UNLOCK(hdma2d);
1865 
1866  return HAL_OK;
1867 }
1868 
1869 
1880 HAL_StatusTypeDef HAL_DMA2D_ProgramLineEvent(DMA2D_HandleTypeDef *hdma2d, uint32_t Line)
1881 {
1882  /* Check the parameters */
1883  if (Line > DMA2D_LWR_LW)
1884  {
1885  return HAL_ERROR;
1886  }
1887  else
1888  {
1889  /* Process locked */
1890  __HAL_LOCK(hdma2d);
1891 
1892  /* Change DMA2D peripheral state */
1893  hdma2d->State = HAL_DMA2D_STATE_BUSY;
1894 
1895  /* Sets the Line watermark configuration */
1896  WRITE_REG(hdma2d->Instance->LWR, Line);
1897 
1898  /* Enable the Line interrupt */
1899  __HAL_DMA2D_ENABLE_IT(hdma2d, DMA2D_IT_TW);
1900 
1901  /* Initialize the DMA2D state*/
1902  hdma2d->State = HAL_DMA2D_STATE_READY;
1903 
1904  /* Process unlocked */
1905  __HAL_UNLOCK(hdma2d);
1906 
1907  return HAL_OK;
1908  }
1909 }
1910 
1917 {
1918  /* Process Locked */
1919  __HAL_LOCK(hdma2d);
1920 
1921  hdma2d->State = HAL_DMA2D_STATE_BUSY;
1922 
1923  /* Set DMA2D_AMTCR EN bit */
1924  SET_BIT(hdma2d->Instance->AMTCR, DMA2D_AMTCR_EN);
1925 
1926  hdma2d->State = HAL_DMA2D_STATE_READY;
1927 
1928  /* Process Unlocked */
1929  __HAL_UNLOCK(hdma2d);
1930 
1931  return HAL_OK;
1932 }
1933 
1940 {
1941  /* Process Locked */
1942  __HAL_LOCK(hdma2d);
1943 
1944  hdma2d->State = HAL_DMA2D_STATE_BUSY;
1945 
1946  /* Clear DMA2D_AMTCR EN bit */
1947  CLEAR_BIT(hdma2d->Instance->AMTCR, DMA2D_AMTCR_EN);
1948 
1949  hdma2d->State = HAL_DMA2D_STATE_READY;
1950 
1951  /* Process Unlocked */
1952  __HAL_UNLOCK(hdma2d);
1953 
1954  return HAL_OK;
1955 }
1956 
1965 HAL_StatusTypeDef HAL_DMA2D_ConfigDeadTime(DMA2D_HandleTypeDef *hdma2d, uint8_t DeadTime)
1966 {
1967  /* Process Locked */
1968  __HAL_LOCK(hdma2d);
1969 
1970  hdma2d->State = HAL_DMA2D_STATE_BUSY;
1971 
1972  /* Set DMA2D_AMTCR DT field */
1973  MODIFY_REG(hdma2d->Instance->AMTCR, DMA2D_AMTCR_DT, (((uint32_t) DeadTime) << DMA2D_AMTCR_DT_Pos));
1974 
1975  hdma2d->State = HAL_DMA2D_STATE_READY;
1976 
1977  /* Process Unlocked */
1978  __HAL_UNLOCK(hdma2d);
1979 
1980  return HAL_OK;
1981 }
1982 
2011 {
2012  return hdma2d->State;
2013 }
2014 
2022 {
2023  return hdma2d->ErrorCode;
2024 }
2025 
2049 static void DMA2D_SetConfig(DMA2D_HandleTypeDef *hdma2d, uint32_t pdata, uint32_t DstAddress, uint32_t Width,
2050  uint32_t Height)
2051 {
2052  uint32_t tmp;
2053  uint32_t tmp1;
2054  uint32_t tmp2;
2055  uint32_t tmp3;
2056  uint32_t tmp4;
2057 
2058  /* Configure DMA2D data size */
2059  MODIFY_REG(hdma2d->Instance->NLR, (DMA2D_NLR_NL | DMA2D_NLR_PL), (Height | (Width << DMA2D_NLR_PL_Pos)));
2060 
2061  /* Configure DMA2D destination address */
2062  WRITE_REG(hdma2d->Instance->OMAR, DstAddress);
2063 
2064  /* Register to memory DMA2D mode selected */
2065  if (hdma2d->Init.Mode == DMA2D_R2M)
2066  {
2067  tmp1 = pdata & DMA2D_OCOLR_ALPHA_1;
2068  tmp2 = pdata & DMA2D_OCOLR_RED_1;
2069  tmp3 = pdata & DMA2D_OCOLR_GREEN_1;
2070  tmp4 = pdata & DMA2D_OCOLR_BLUE_1;
2071 
2072  /* Prepare the value to be written to the OCOLR register according to the color mode */
2073  if (hdma2d->Init.ColorMode == DMA2D_OUTPUT_ARGB8888)
2074  {
2075  tmp = (tmp3 | tmp2 | tmp1 | tmp4);
2076  }
2077  else if (hdma2d->Init.ColorMode == DMA2D_OUTPUT_RGB888)
2078  {
2079  tmp = (tmp3 | tmp2 | tmp4);
2080  }
2081  else if (hdma2d->Init.ColorMode == DMA2D_OUTPUT_RGB565)
2082  {
2083  tmp2 = (tmp2 >> 19U);
2084  tmp3 = (tmp3 >> 10U);
2085  tmp4 = (tmp4 >> 3U);
2086  tmp = ((tmp3 << 5U) | (tmp2 << 11U) | tmp4);
2087  }
2088  else if (hdma2d->Init.ColorMode == DMA2D_OUTPUT_ARGB1555)
2089  {
2090  tmp1 = (tmp1 >> 31U);
2091  tmp2 = (tmp2 >> 19U);
2092  tmp3 = (tmp3 >> 11U);
2093  tmp4 = (tmp4 >> 3U);
2094  tmp = ((tmp3 << 5U) | (tmp2 << 10U) | (tmp1 << 15U) | tmp4);
2095  }
2096  else /* Dhdma2d->Init.ColorMode = DMA2D_OUTPUT_ARGB4444 */
2097  {
2098  tmp1 = (tmp1 >> 28U);
2099  tmp2 = (tmp2 >> 20U);
2100  tmp3 = (tmp3 >> 12U);
2101  tmp4 = (tmp4 >> 4U);
2102  tmp = ((tmp3 << 4U) | (tmp2 << 8U) | (tmp1 << 12U) | tmp4);
2103  }
2104  /* Write to DMA2D OCOLR register */
2105  WRITE_REG(hdma2d->Instance->OCOLR, tmp);
2106  }
2107  else /* M2M, M2M_PFC or M2M_Blending DMA2D Mode */
2108  {
2109  /* Configure DMA2D source address */
2110  WRITE_REG(hdma2d->Instance->FGMAR, pdata);
2111  }
2112 }
2113 
2125 #endif /* DMA2D */
2126 #endif /* HAL_DMA2D_MODULE_ENABLED */
HAL_DMA2D_CallbackIDTypeDef
HAL DMA2D common Callback ID enumeration definition.
@ HAL_DMA2D_MSPINIT_CB_ID
@ HAL_DMA2D_CLUTLOADINGCPLT_CB_ID
@ HAL_DMA2D_LINEEVENT_CB_ID
@ HAL_DMA2D_TRANSFERERROR_CB_ID
@ HAL_DMA2D_MSPDEINIT_CB_ID
@ HAL_DMA2D_TRANSFERCOMPLETE_CB_ID
HAL_StatusTypeDef HAL_DMA2D_UnRegisterCallback(DMA2D_HandleTypeDef *hdma2d, HAL_DMA2D_CallbackIDTypeDef CallbackID)
Unregister a DMA2D Callback DMA2D Callback is redirected to the weak (overridden) predefined callback...
HAL_StatusTypeDef HAL_DMA2D_RegisterCallback(DMA2D_HandleTypeDef *hdma2d, HAL_DMA2D_CallbackIDTypeDef CallbackID, pDMA2D_CallbackTypeDef pCallback)
Register a User DMA2D Callback To be used instead of the weak (overridden) predefined callback.
HAL_StatusTypeDef HAL_DMA2D_DeInit(DMA2D_HandleTypeDef *hdma2d)
Deinitializes the DMA2D peripheral registers to their default reset values.
void HAL_DMA2D_MspDeInit(DMA2D_HandleTypeDef *hdma2d)
DeInitializes the DMA2D MSP.
HAL_StatusTypeDef HAL_DMA2D_Init(DMA2D_HandleTypeDef *hdma2d)
Initialize the DMA2D according to the specified parameters in the DMA2D_InitTypeDef and create the as...
void HAL_DMA2D_MspInit(DMA2D_HandleTypeDef *hdma2d)
Initializes the DMA2D MSP.
HAL_StatusTypeDef HAL_DMA2D_Start_IT(DMA2D_HandleTypeDef *hdma2d, uint32_t pdata, uint32_t DstAddress, uint32_t Width, uint32_t Height)
Start the DMA2D Transfer with interrupt enabled.
HAL_StatusTypeDef HAL_DMA2D_EnableCLUT(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx)
Enable the DMA2D CLUT Transfer.
void HAL_DMA2D_CLUTLoadingCpltCallback(DMA2D_HandleTypeDef *hdma2d)
CLUT Transfer Complete callback.
HAL_StatusTypeDef HAL_DMA2D_PollForTransfer(DMA2D_HandleTypeDef *hdma2d, uint32_t Timeout)
Polling for transfer complete or CLUT loading.
HAL_StatusTypeDef HAL_DMA2D_Resume(DMA2D_HandleTypeDef *hdma2d)
Resume the DMA2D Transfer.
void HAL_DMA2D_LineEventCallback(DMA2D_HandleTypeDef *hdma2d)
Transfer watermark callback.
HAL_StatusTypeDef HAL_DMA2D_CLUTLoading_Abort(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx)
Abort the DMA2D CLUT loading.
HAL_StatusTypeDef HAL_DMA2D_CLUTLoad(DMA2D_HandleTypeDef *hdma2d, DMA2D_CLUTCfgTypeDef CLUTCfg, uint32_t LayerIdx)
Start DMA2D CLUT Loading.
HAL_StatusTypeDef HAL_DMA2D_CLUTStartLoad_IT(DMA2D_HandleTypeDef *hdma2d, DMA2D_CLUTCfgTypeDef *CLUTCfg, uint32_t LayerIdx)
Start DMA2D CLUT Loading with interrupt enabled.
HAL_StatusTypeDef HAL_DMA2D_CLUTLoading_Suspend(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx)
Suspend the DMA2D CLUT loading.
HAL_StatusTypeDef HAL_DMA2D_Start(DMA2D_HandleTypeDef *hdma2d, uint32_t pdata, uint32_t DstAddress, uint32_t Width, uint32_t Height)
Start the DMA2D Transfer.
HAL_StatusTypeDef HAL_DMA2D_CLUTStartLoad(DMA2D_HandleTypeDef *hdma2d, DMA2D_CLUTCfgTypeDef *CLUTCfg, uint32_t LayerIdx)
Start DMA2D CLUT Loading.
void HAL_DMA2D_IRQHandler(DMA2D_HandleTypeDef *hdma2d)
Handle DMA2D interrupt request.
HAL_StatusTypeDef HAL_DMA2D_CLUTLoading_Resume(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx)
Resume the DMA2D CLUT loading.
HAL_StatusTypeDef HAL_DMA2D_Abort(DMA2D_HandleTypeDef *hdma2d)
Abort the DMA2D Transfer.
HAL_StatusTypeDef HAL_DMA2D_BlendingStart_IT(DMA2D_HandleTypeDef *hdma2d, uint32_t SrcAddress1, uint32_t SrcAddress2, uint32_t DstAddress, uint32_t Width, uint32_t Height)
Start the multi-source DMA2D Transfer with interrupt enabled.
HAL_StatusTypeDef HAL_DMA2D_CLUTLoad_IT(DMA2D_HandleTypeDef *hdma2d, DMA2D_CLUTCfgTypeDef CLUTCfg, uint32_t LayerIdx)
Start DMA2D CLUT Loading with interrupt enabled.
HAL_StatusTypeDef HAL_DMA2D_Suspend(DMA2D_HandleTypeDef *hdma2d)
Suspend the DMA2D Transfer.
HAL_StatusTypeDef HAL_DMA2D_BlendingStart(DMA2D_HandleTypeDef *hdma2d, uint32_t SrcAddress1, uint32_t SrcAddress2, uint32_t DstAddress, uint32_t Width, uint32_t Height)
Start the multi-source DMA2D Transfer.
HAL_StatusTypeDef HAL_DMA2D_ProgramLineEvent(DMA2D_HandleTypeDef *hdma2d, uint32_t Line)
Configure the line watermark.
HAL_StatusTypeDef HAL_DMA2D_EnableDeadTime(DMA2D_HandleTypeDef *hdma2d)
Enable DMA2D dead time feature.
HAL_StatusTypeDef HAL_DMA2D_ConfigDeadTime(DMA2D_HandleTypeDef *hdma2d, uint8_t DeadTime)
Configure dead time.
HAL_StatusTypeDef HAL_DMA2D_DisableDeadTime(DMA2D_HandleTypeDef *hdma2d)
Disable DMA2D dead time feature.
HAL_StatusTypeDef HAL_DMA2D_ConfigCLUT(DMA2D_HandleTypeDef *hdma2d, DMA2D_CLUTCfgTypeDef CLUTCfg, uint32_t LayerIdx)
Configure the DMA2D CLUT Transfer.
HAL_StatusTypeDef HAL_DMA2D_ConfigLayer(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx)
Configure the DMA2D Layer according to the specified parameters in the DMA2D_HandleTypeDef.
HAL_DMA2D_StateTypeDef HAL_DMA2D_GetState(DMA2D_HandleTypeDef *hdma2d)
Return the DMA2D state.
uint32_t HAL_DMA2D_GetError(DMA2D_HandleTypeDef *hdma2d)
Return the DMA2D error code.
void(* XferErrorCallback)(struct __DMA2D_HandleTypeDef *hdma2d)
DMA2D_LayerCfgTypeDef LayerCfg[MAX_DMA2D_LAYER]
void(* XferCpltCallback)(struct __DMA2D_HandleTypeDef *hdma2d)
void(* MspDeInitCallback)(struct __DMA2D_HandleTypeDef *hdma2d)
void(* LineEventCallback)(struct __DMA2D_HandleTypeDef *hdma2d)
void(* MspInitCallback)(struct __DMA2D_HandleTypeDef *hdma2d)
__IO HAL_DMA2D_StateTypeDef State
void(* CLUTLoadingCpltCallback)(struct __DMA2D_HandleTypeDef *hdma2d)
void(* pDMA2D_CallbackTypeDef)(DMA2D_HandleTypeDef *hdma2d)
HAL DMA2D Callback pointer definition.
HAL_DMA2D_StateTypeDef
HAL DMA2D State structures definition.
@ HAL_DMA2D_STATE_RESET
@ HAL_DMA2D_STATE_SUSPEND
@ HAL_DMA2D_STATE_ERROR
@ HAL_DMA2D_STATE_BUSY
@ HAL_DMA2D_STATE_READY
@ HAL_DMA2D_STATE_TIMEOUT
DMA2D CLUT Structure definition.
DMA2D Layer structure definition.
DMA2D handle Structure definition.
uint32_t HAL_GetTick(void)
Provides a tick value in millisecond.
This file contains all the functions prototypes for the HAL module driver.