164 #include "stm32h7xx_hal.h"
166 #ifdef HAL_DMA2D_MODULE_ENABLED
187 #define DMA2D_TIMEOUT_ABORT (1000U)
188 #define DMA2D_TIMEOUT_SUSPEND (1000U)
204 static void DMA2D_SetConfig(DMA2D_HandleTypeDef *hdma2d, uint32_t pdata, uint32_t DstAddress, uint32_t Width,
250 assert_param(IS_DMA2D_OFFSET(hdma2d->Init.OutputOffset));
251 assert_param(IS_DMA2D_ALPHA_INVERTED(hdma2d->Init.AlphaInverted));
252 assert_param(IS_DMA2D_RB_SWAP(hdma2d->Init.RedBlueSwap));
253 assert_param(IS_DMA2D_LOM_MODE(hdma2d->Init.LineOffsetMode));
254 assert_param(IS_DMA2D_BYTES_SWAP(hdma2d->Init.BytesSwap));
256 #if (USE_HAL_DMA2D_REGISTER_CALLBACKS == 1)
257 if (hdma2d->State == HAL_DMA2D_STATE_RESET)
260 hdma2d->LineEventCallback = HAL_DMA2D_LineEventCallback;
261 hdma2d->CLUTLoadingCpltCallback = HAL_DMA2D_CLUTLoadingCpltCallback;
262 if (hdma2d->MspInitCallback ==
NULL)
264 hdma2d->MspInitCallback = HAL_DMA2D_MspInit;
268 hdma2d->MspInitCallback(hdma2d);
271 if (hdma2d->State == HAL_DMA2D_STATE_RESET)
276 HAL_DMA2D_MspInit(hdma2d);
281 hdma2d->State = HAL_DMA2D_STATE_BUSY;
288 hdma2d->Init.ColorMode | hdma2d->Init.BytesSwap);
299 hdma2d->ErrorCode = HAL_DMA2D_ERROR_NONE;
302 hdma2d->State = HAL_DMA2D_STATE_READY;
331 if (HAL_DMA2D_Abort(hdma2d) !=
HAL_OK)
342 if (HAL_DMA2D_CLUTLoading_Abort(hdma2d, 0U) !=
HAL_OK)
353 if (HAL_DMA2D_CLUTLoading_Abort(hdma2d, 1U) !=
HAL_OK)
364 hdma2d->Instance->CR = 0U;
365 hdma2d->Instance->IFCR = 0x3FU;
366 hdma2d->Instance->FGOR = 0U;
367 hdma2d->Instance->BGOR = 0U;
368 hdma2d->Instance->FGPFCCR = 0U;
369 hdma2d->Instance->BGPFCCR = 0U;
370 hdma2d->Instance->OPFCCR = 0U;
372 #if (USE_HAL_DMA2D_REGISTER_CALLBACKS == 1)
374 if (hdma2d->MspDeInitCallback ==
NULL)
376 hdma2d->MspDeInitCallback = HAL_DMA2D_MspDeInit;
380 hdma2d->MspDeInitCallback(hdma2d);
384 HAL_DMA2D_MspDeInit(hdma2d);
388 hdma2d->ErrorCode = HAL_DMA2D_ERROR_NONE;
391 hdma2d->State = HAL_DMA2D_STATE_RESET;
405 __weak
void HAL_DMA2D_MspInit(DMA2D_HandleTypeDef *hdma2d)
421 __weak
void HAL_DMA2D_MspDeInit(DMA2D_HandleTypeDef *hdma2d)
431 #if (USE_HAL_DMA2D_REGISTER_CALLBACKS == 1)
448 HAL_StatusTypeDef HAL_DMA2D_RegisterCallback(DMA2D_HandleTypeDef *hdma2d, HAL_DMA2D_CallbackIDTypeDef CallbackID,
449 pDMA2D_CallbackTypeDef pCallback)
453 if (pCallback ==
NULL)
456 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_INVALID_CALLBACK;
462 if (HAL_DMA2D_STATE_READY == hdma2d->State)
466 case HAL_DMA2D_TRANSFERCOMPLETE_CB_ID :
467 hdma2d->XferCpltCallback = pCallback;
470 case HAL_DMA2D_TRANSFERERROR_CB_ID :
471 hdma2d->XferErrorCallback = pCallback;
474 case HAL_DMA2D_LINEEVENT_CB_ID :
475 hdma2d->LineEventCallback = pCallback;
478 case HAL_DMA2D_CLUTLOADINGCPLT_CB_ID :
479 hdma2d->CLUTLoadingCpltCallback = pCallback;
482 case HAL_DMA2D_MSPINIT_CB_ID :
483 hdma2d->MspInitCallback = pCallback;
486 case HAL_DMA2D_MSPDEINIT_CB_ID :
487 hdma2d->MspDeInitCallback = pCallback;
492 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_INVALID_CALLBACK;
498 else if (HAL_DMA2D_STATE_RESET == hdma2d->State)
502 case HAL_DMA2D_MSPINIT_CB_ID :
503 hdma2d->MspInitCallback = pCallback;
506 case HAL_DMA2D_MSPDEINIT_CB_ID :
507 hdma2d->MspDeInitCallback = pCallback;
512 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_INVALID_CALLBACK;
521 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_INVALID_CALLBACK;
546 HAL_StatusTypeDef HAL_DMA2D_UnRegisterCallback(DMA2D_HandleTypeDef *hdma2d, HAL_DMA2D_CallbackIDTypeDef CallbackID)
553 if (HAL_DMA2D_STATE_READY == hdma2d->State)
557 case HAL_DMA2D_TRANSFERCOMPLETE_CB_ID :
558 hdma2d->XferCpltCallback =
NULL;
561 case HAL_DMA2D_TRANSFERERROR_CB_ID :
562 hdma2d->XferErrorCallback =
NULL;
565 case HAL_DMA2D_LINEEVENT_CB_ID :
566 hdma2d->LineEventCallback = HAL_DMA2D_LineEventCallback;
569 case HAL_DMA2D_CLUTLOADINGCPLT_CB_ID :
570 hdma2d->CLUTLoadingCpltCallback = HAL_DMA2D_CLUTLoadingCpltCallback;
573 case HAL_DMA2D_MSPINIT_CB_ID :
574 hdma2d->MspInitCallback = HAL_DMA2D_MspInit;
577 case HAL_DMA2D_MSPDEINIT_CB_ID :
578 hdma2d->MspDeInitCallback = HAL_DMA2D_MspDeInit;
583 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_INVALID_CALLBACK;
589 else if (HAL_DMA2D_STATE_RESET == hdma2d->State)
593 case HAL_DMA2D_MSPINIT_CB_ID :
594 hdma2d->MspInitCallback = HAL_DMA2D_MspInit;
597 case HAL_DMA2D_MSPDEINIT_CB_ID :
598 hdma2d->MspDeInitCallback = HAL_DMA2D_MspDeInit;
603 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_INVALID_CALLBACK;
612 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_INVALID_CALLBACK;
677 HAL_StatusTypeDef HAL_DMA2D_Start(DMA2D_HandleTypeDef *hdma2d, uint32_t pdata, uint32_t DstAddress, uint32_t Width,
688 hdma2d->State = HAL_DMA2D_STATE_BUSY;
691 DMA2D_SetConfig(hdma2d, pdata, DstAddress, Width, Height);
694 __HAL_DMA2D_ENABLE(hdma2d);
713 HAL_StatusTypeDef HAL_DMA2D_Start_IT(DMA2D_HandleTypeDef *hdma2d, uint32_t pdata, uint32_t DstAddress, uint32_t Width,
724 hdma2d->State = HAL_DMA2D_STATE_BUSY;
727 DMA2D_SetConfig(hdma2d, pdata, DstAddress, Width, Height);
730 __HAL_DMA2D_ENABLE_IT(hdma2d, DMA2D_IT_TC | DMA2D_IT_TE | DMA2D_IT_CE);
733 __HAL_DMA2D_ENABLE(hdma2d);
750 HAL_StatusTypeDef HAL_DMA2D_BlendingStart(DMA2D_HandleTypeDef *hdma2d, uint32_t SrcAddress1, uint32_t SrcAddress2,
751 uint32_t DstAddress, uint32_t Width, uint32_t Height)
761 hdma2d->State = HAL_DMA2D_STATE_BUSY;
763 if (hdma2d->Init.Mode == DMA2D_M2M_BLEND_FG)
766 WRITE_REG(hdma2d->Instance->FGCOLR, SrcAddress1);
768 DMA2D_SetConfig(hdma2d, SrcAddress2, DstAddress, Width, Height);
770 else if (hdma2d->Init.Mode == DMA2D_M2M_BLEND_BG)
773 WRITE_REG(hdma2d->Instance->BGCOLR, SrcAddress2);
775 DMA2D_SetConfig(hdma2d, SrcAddress1, DstAddress, Width, Height);
780 WRITE_REG(hdma2d->Instance->BGMAR, SrcAddress2);
783 DMA2D_SetConfig(hdma2d, SrcAddress1, DstAddress, Width, Height);
787 __HAL_DMA2D_ENABLE(hdma2d);
804 HAL_StatusTypeDef HAL_DMA2D_BlendingStart_IT(DMA2D_HandleTypeDef *hdma2d, uint32_t SrcAddress1, uint32_t SrcAddress2,
805 uint32_t DstAddress, uint32_t Width, uint32_t Height)
815 hdma2d->State = HAL_DMA2D_STATE_BUSY;
817 if (hdma2d->Init.Mode == DMA2D_M2M_BLEND_FG)
820 WRITE_REG(hdma2d->Instance->FGCOLR, SrcAddress1);
822 DMA2D_SetConfig(hdma2d, SrcAddress2, DstAddress, Width, Height);
824 else if (hdma2d->Init.Mode == DMA2D_M2M_BLEND_BG)
827 WRITE_REG(hdma2d->Instance->BGCOLR, SrcAddress2);
829 DMA2D_SetConfig(hdma2d, SrcAddress1, DstAddress, Width, Height);
833 WRITE_REG(hdma2d->Instance->BGMAR, SrcAddress2);
836 DMA2D_SetConfig(hdma2d, SrcAddress1, DstAddress, Width, Height);
840 __HAL_DMA2D_ENABLE_IT(hdma2d, DMA2D_IT_TC | DMA2D_IT_TE | DMA2D_IT_CE);
843 __HAL_DMA2D_ENABLE(hdma2d);
870 if ((
HAL_GetTick() - tickstart) > DMA2D_TIMEOUT_ABORT)
873 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_TIMEOUT;
876 hdma2d->State = HAL_DMA2D_STATE_TIMEOUT;
886 __HAL_DMA2D_DISABLE_IT(hdma2d, DMA2D_IT_TC | DMA2D_IT_TE | DMA2D_IT_CE);
889 hdma2d->State = HAL_DMA2D_STATE_READY;
919 if ((
HAL_GetTick() - tickstart) > DMA2D_TIMEOUT_SUSPEND)
922 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_TIMEOUT;
925 hdma2d->State = HAL_DMA2D_STATE_TIMEOUT;
934 hdma2d->State = HAL_DMA2D_STATE_SUSPEND;
958 hdma2d->State = HAL_DMA2D_STATE_BUSY;
980 HAL_StatusTypeDef HAL_DMA2D_EnableCLUT(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx)
989 hdma2d->State = HAL_DMA2D_STATE_BUSY;
991 if (LayerIdx == DMA2D_BACKGROUND_LAYER)
1016 HAL_StatusTypeDef HAL_DMA2D_CLUTStartLoad(DMA2D_HandleTypeDef *hdma2d, DMA2D_CLUTCfgTypeDef *CLUTCfg, uint32_t LayerIdx)
1020 assert_param(IS_DMA2D_CLUT_CM(CLUTCfg->CLUTColorMode));
1027 hdma2d->State = HAL_DMA2D_STATE_BUSY;
1030 if (LayerIdx == DMA2D_BACKGROUND_LAYER)
1033 WRITE_REG(hdma2d->Instance->BGCMAR, (uint32_t)CLUTCfg->pCLUT);
1046 WRITE_REG(hdma2d->Instance->FGCMAR, (uint32_t)CLUTCfg->pCLUT);
1070 HAL_StatusTypeDef HAL_DMA2D_CLUTStartLoad_IT(DMA2D_HandleTypeDef *hdma2d, DMA2D_CLUTCfgTypeDef *CLUTCfg,
1075 assert_param(IS_DMA2D_CLUT_CM(CLUTCfg->CLUTColorMode));
1082 hdma2d->State = HAL_DMA2D_STATE_BUSY;
1085 if (LayerIdx == DMA2D_BACKGROUND_LAYER)
1088 WRITE_REG(hdma2d->Instance->BGCMAR, (uint32_t)CLUTCfg->pCLUT);
1095 __HAL_DMA2D_ENABLE_IT(hdma2d, DMA2D_IT_CTC | DMA2D_IT_TE | DMA2D_IT_CE | DMA2D_IT_CAE);
1104 WRITE_REG(hdma2d->Instance->FGCMAR, (uint32_t)CLUTCfg->pCLUT);
1111 __HAL_DMA2D_ENABLE_IT(hdma2d, DMA2D_IT_CTC | DMA2D_IT_TE | DMA2D_IT_CE | DMA2D_IT_CAE);
1134 HAL_StatusTypeDef HAL_DMA2D_CLUTLoad(DMA2D_HandleTypeDef *hdma2d, DMA2D_CLUTCfgTypeDef CLUTCfg, uint32_t LayerIdx)
1145 hdma2d->State = HAL_DMA2D_STATE_BUSY;
1148 if (LayerIdx == DMA2D_BACKGROUND_LAYER)
1151 WRITE_REG(hdma2d->Instance->BGCMAR, (uint32_t)CLUTCfg.pCLUT);
1164 WRITE_REG(hdma2d->Instance->FGCMAR, (uint32_t)CLUTCfg.pCLUT);
1191 HAL_StatusTypeDef HAL_DMA2D_CLUTLoad_IT(DMA2D_HandleTypeDef *hdma2d, DMA2D_CLUTCfgTypeDef CLUTCfg, uint32_t LayerIdx)
1202 hdma2d->State = HAL_DMA2D_STATE_BUSY;
1205 if (LayerIdx == DMA2D_BACKGROUND_LAYER)
1208 WRITE_REG(hdma2d->Instance->BGCMAR, (uint32_t)CLUTCfg.pCLUT);
1215 __HAL_DMA2D_ENABLE_IT(hdma2d, DMA2D_IT_CTC | DMA2D_IT_TE | DMA2D_IT_CE | DMA2D_IT_CAE);
1224 WRITE_REG(hdma2d->Instance->FGCMAR, (uint32_t)CLUTCfg.pCLUT);
1231 __HAL_DMA2D_ENABLE_IT(hdma2d, DMA2D_IT_CTC | DMA2D_IT_TE | DMA2D_IT_CE | DMA2D_IT_CAE);
1249 HAL_StatusTypeDef HAL_DMA2D_CLUTLoading_Abort(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx)
1252 const __IO uint32_t *reg = &(hdma2d->Instance->BGPFCCR);
1258 if (LayerIdx == DMA2D_FOREGROUND_LAYER)
1260 reg = &(hdma2d->Instance->FGPFCCR);
1270 if ((
HAL_GetTick() - tickstart) > DMA2D_TIMEOUT_ABORT)
1273 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_TIMEOUT;
1276 hdma2d->State = HAL_DMA2D_STATE_TIMEOUT;
1286 __HAL_DMA2D_DISABLE_IT(hdma2d, DMA2D_IT_CTC | DMA2D_IT_TE | DMA2D_IT_CE | DMA2D_IT_CAE);
1289 hdma2d->State = HAL_DMA2D_STATE_READY;
1306 HAL_StatusTypeDef HAL_DMA2D_CLUTLoading_Suspend(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx)
1309 uint32_t loadsuspended;
1310 const __IO uint32_t *reg = &(hdma2d->Instance->BGPFCCR);
1316 if (LayerIdx == DMA2D_FOREGROUND_LAYER)
1318 reg = &(hdma2d->Instance->FGPFCCR);
1329 while (loadsuspended == 0UL)
1331 if ((
HAL_GetTick() - tickstart) > DMA2D_TIMEOUT_SUSPEND)
1334 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_TIMEOUT;
1337 hdma2d->State = HAL_DMA2D_STATE_TIMEOUT;
1350 hdma2d->State = HAL_DMA2D_STATE_SUSPEND;
1371 HAL_StatusTypeDef HAL_DMA2D_CLUTLoading_Resume(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx)
1374 if (LayerIdx == DMA2D_BACKGROUND_LAYER)
1382 hdma2d->State = HAL_DMA2D_STATE_BUSY;
1394 hdma2d->State = HAL_DMA2D_STATE_BUSY;
1414 HAL_StatusTypeDef HAL_DMA2D_PollForTransfer(DMA2D_HandleTypeDef *hdma2d, uint32_t Timeout)
1417 uint32_t layer_start;
1418 __IO uint32_t isrflags = 0x0U;
1426 while (__HAL_DMA2D_GET_FLAG(hdma2d, DMA2D_FLAG_TC) == 0U)
1428 isrflags =
READ_REG(hdma2d->Instance->ISR);
1429 if ((isrflags & (DMA2D_FLAG_CE | DMA2D_FLAG_TE)) != 0U)
1431 if ((isrflags & DMA2D_FLAG_CE) != 0U)
1433 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_CE;
1435 if ((isrflags & DMA2D_FLAG_TE) != 0U)
1437 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_TE;
1440 __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_CE | DMA2D_FLAG_TE);
1443 hdma2d->State = HAL_DMA2D_STATE_ERROR;
1453 if (((
HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
1456 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_TIMEOUT;
1459 hdma2d->State = HAL_DMA2D_STATE_TIMEOUT;
1472 if (layer_start != 0U)
1477 while (__HAL_DMA2D_GET_FLAG(hdma2d, DMA2D_FLAG_CTC) == 0U)
1479 isrflags =
READ_REG(hdma2d->Instance->ISR);
1480 if ((isrflags & (DMA2D_FLAG_CAE | DMA2D_FLAG_CE | DMA2D_FLAG_TE)) != 0U)
1482 if ((isrflags & DMA2D_FLAG_CAE) != 0U)
1484 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_CAE;
1486 if ((isrflags & DMA2D_FLAG_CE) != 0U)
1488 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_CE;
1490 if ((isrflags & DMA2D_FLAG_TE) != 0U)
1492 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_TE;
1495 __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_CAE | DMA2D_FLAG_CE | DMA2D_FLAG_TE);
1498 hdma2d->State = HAL_DMA2D_STATE_ERROR;
1508 if (((
HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
1511 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_TIMEOUT;
1514 hdma2d->State = HAL_DMA2D_STATE_TIMEOUT;
1526 __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_TC | DMA2D_FLAG_CTC);
1529 hdma2d->State = HAL_DMA2D_STATE_READY;
1542 void HAL_DMA2D_IRQHandler(DMA2D_HandleTypeDef *hdma2d)
1544 uint32_t isrflags =
READ_REG(hdma2d->Instance->ISR);
1545 uint32_t crflags =
READ_REG(hdma2d->Instance->CR);
1548 if ((isrflags & DMA2D_FLAG_TE) != 0U)
1550 if ((crflags & DMA2D_IT_TE) != 0U)
1553 __HAL_DMA2D_DISABLE_IT(hdma2d, DMA2D_IT_TE);
1556 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_TE;
1559 __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_TE);
1562 hdma2d->State = HAL_DMA2D_STATE_ERROR;
1567 if (hdma2d->XferErrorCallback !=
NULL)
1570 hdma2d->XferErrorCallback(hdma2d);
1575 if ((isrflags & DMA2D_FLAG_CE) != 0U)
1577 if ((crflags & DMA2D_IT_CE) != 0U)
1580 __HAL_DMA2D_DISABLE_IT(hdma2d, DMA2D_IT_CE);
1583 __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_CE);
1586 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_CE;
1589 hdma2d->State = HAL_DMA2D_STATE_ERROR;
1594 if (hdma2d->XferErrorCallback !=
NULL)
1597 hdma2d->XferErrorCallback(hdma2d);
1602 if ((isrflags & DMA2D_FLAG_CAE) != 0U)
1604 if ((crflags & DMA2D_IT_CAE) != 0U)
1607 __HAL_DMA2D_DISABLE_IT(hdma2d, DMA2D_IT_CAE);
1610 __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_CAE);
1613 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_CAE;
1616 hdma2d->State = HAL_DMA2D_STATE_ERROR;
1621 if (hdma2d->XferErrorCallback !=
NULL)
1624 hdma2d->XferErrorCallback(hdma2d);
1629 if ((isrflags & DMA2D_FLAG_TW) != 0U)
1631 if ((crflags & DMA2D_IT_TW) != 0U)
1634 __HAL_DMA2D_DISABLE_IT(hdma2d, DMA2D_IT_TW);
1637 __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_TW);
1640 #if (USE_HAL_DMA2D_REGISTER_CALLBACKS == 1)
1641 hdma2d->LineEventCallback(hdma2d);
1643 HAL_DMA2D_LineEventCallback(hdma2d);
1649 if ((isrflags & DMA2D_FLAG_TC) != 0U)
1651 if ((crflags & DMA2D_IT_TC) != 0U)
1654 __HAL_DMA2D_DISABLE_IT(hdma2d, DMA2D_IT_TC);
1657 __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_TC);
1660 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_NONE;
1663 hdma2d->State = HAL_DMA2D_STATE_READY;
1668 if (hdma2d->XferCpltCallback !=
NULL)
1671 hdma2d->XferCpltCallback(hdma2d);
1676 if ((isrflags & DMA2D_FLAG_CTC) != 0U)
1678 if ((crflags & DMA2D_IT_CTC) != 0U)
1681 __HAL_DMA2D_DISABLE_IT(hdma2d, DMA2D_IT_CTC);
1684 __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_CTC);
1687 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_NONE;
1690 hdma2d->State = HAL_DMA2D_STATE_READY;
1696 #if (USE_HAL_DMA2D_REGISTER_CALLBACKS == 1)
1697 hdma2d->CLUTLoadingCpltCallback(hdma2d);
1699 HAL_DMA2D_CLUTLoadingCpltCallback(hdma2d);
1712 __weak
void HAL_DMA2D_LineEventCallback(DMA2D_HandleTypeDef *hdma2d)
1728 __weak
void HAL_DMA2D_CLUTLoadingCpltCallback(DMA2D_HandleTypeDef *hdma2d)
1771 HAL_StatusTypeDef HAL_DMA2D_ConfigLayer(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx)
1773 DMA2D_LayerCfgTypeDef *pLayerCfg;
1779 assert_param(IS_DMA2D_OFFSET(hdma2d->LayerCfg[LayerIdx].InputOffset));
1780 if (hdma2d->Init.Mode != DMA2D_R2M)
1782 assert_param(IS_DMA2D_INPUT_COLOR_MODE(hdma2d->LayerCfg[LayerIdx].InputColorMode));
1783 if (hdma2d->Init.Mode != DMA2D_M2M)
1785 assert_param(IS_DMA2D_ALPHA_MODE(hdma2d->LayerCfg[LayerIdx].AlphaMode));
1788 assert_param(IS_DMA2D_ALPHA_INVERTED(hdma2d->LayerCfg[LayerIdx].AlphaInverted));
1789 assert_param(IS_DMA2D_RB_SWAP(hdma2d->LayerCfg[LayerIdx].RedBlueSwap));
1791 if ((LayerIdx == DMA2D_FOREGROUND_LAYER) && (hdma2d->LayerCfg[LayerIdx].InputColorMode == DMA2D_INPUT_YCBCR))
1793 assert_param(IS_DMA2D_CHROMA_SUB_SAMPLING(hdma2d->LayerCfg[LayerIdx].ChromaSubSampling));
1800 hdma2d->State = HAL_DMA2D_STATE_BUSY;
1802 pLayerCfg = &hdma2d->LayerCfg[LayerIdx];
1810 if ((pLayerCfg->InputColorMode == DMA2D_INPUT_A4) || (pLayerCfg->InputColorMode == DMA2D_INPUT_A8))
1820 if (LayerIdx == DMA2D_BACKGROUND_LAYER)
1823 MODIFY_REG(hdma2d->Instance->BGPFCCR, regMask, regValue);
1826 WRITE_REG(hdma2d->Instance->BGOR, pLayerCfg->InputOffset);
1829 if ((pLayerCfg->InputColorMode == DMA2D_INPUT_A4) || (pLayerCfg->InputColorMode == DMA2D_INPUT_A8))
1839 if (pLayerCfg->InputColorMode == DMA2D_INPUT_YCBCR)
1846 MODIFY_REG(hdma2d->Instance->FGPFCCR, regMask, regValue);
1849 WRITE_REG(hdma2d->Instance->FGOR, pLayerCfg->InputOffset);
1852 if ((pLayerCfg->InputColorMode == DMA2D_INPUT_A4) || (pLayerCfg->InputColorMode == DMA2D_INPUT_A8))
1859 hdma2d->State = HAL_DMA2D_STATE_READY;
1881 HAL_StatusTypeDef HAL_DMA2D_ConfigCLUT(DMA2D_HandleTypeDef *hdma2d, DMA2D_CLUTCfgTypeDef CLUTCfg, uint32_t LayerIdx)
1892 hdma2d->State = HAL_DMA2D_STATE_BUSY;
1895 if (LayerIdx == DMA2D_BACKGROUND_LAYER)
1898 WRITE_REG(hdma2d->Instance->BGCMAR, (uint32_t)CLUTCfg.pCLUT);
1908 WRITE_REG(hdma2d->Instance->FGCMAR, (uint32_t)CLUTCfg.pCLUT);
1916 hdma2d->State = HAL_DMA2D_STATE_READY;
1935 HAL_StatusTypeDef HAL_DMA2D_ProgramLineEvent(DMA2D_HandleTypeDef *hdma2d, uint32_t Line)
1948 hdma2d->State = HAL_DMA2D_STATE_BUSY;
1954 __HAL_DMA2D_ENABLE_IT(hdma2d, DMA2D_IT_TW);
1957 hdma2d->State = HAL_DMA2D_STATE_READY;
1976 hdma2d->State = HAL_DMA2D_STATE_BUSY;
1981 hdma2d->State = HAL_DMA2D_STATE_READY;
1999 hdma2d->State = HAL_DMA2D_STATE_BUSY;
2004 hdma2d->State = HAL_DMA2D_STATE_READY;
2020 HAL_StatusTypeDef HAL_DMA2D_ConfigDeadTime(DMA2D_HandleTypeDef *hdma2d, uint8_t DeadTime)
2025 hdma2d->State = HAL_DMA2D_STATE_BUSY;
2030 hdma2d->State = HAL_DMA2D_STATE_READY;
2065 HAL_DMA2D_StateTypeDef HAL_DMA2D_GetState(DMA2D_HandleTypeDef *hdma2d)
2067 return hdma2d->State;
2076 uint32_t HAL_DMA2D_GetError(DMA2D_HandleTypeDef *hdma2d)
2078 return hdma2d->ErrorCode;
2104 static void DMA2D_SetConfig(DMA2D_HandleTypeDef *hdma2d, uint32_t pdata, uint32_t DstAddress, uint32_t Width,
2117 WRITE_REG(hdma2d->Instance->OMAR, DstAddress);
2120 if (hdma2d->Init.Mode == DMA2D_R2M)
2128 if (hdma2d->Init.ColorMode == DMA2D_OUTPUT_ARGB8888)
2130 tmp = (tmp3 | tmp2 | tmp1 | tmp4);
2132 else if (hdma2d->Init.ColorMode == DMA2D_OUTPUT_RGB888)
2134 tmp = (tmp3 | tmp2 | tmp4);
2136 else if (hdma2d->Init.ColorMode == DMA2D_OUTPUT_RGB565)
2138 tmp2 = (tmp2 >> 19U);
2139 tmp3 = (tmp3 >> 10U);
2140 tmp4 = (tmp4 >> 3U);
2141 tmp = ((tmp3 << 5U) | (tmp2 << 11U) | tmp4);
2143 else if (hdma2d->Init.ColorMode == DMA2D_OUTPUT_ARGB1555)
2145 tmp1 = (tmp1 >> 31U);
2146 tmp2 = (tmp2 >> 19U);
2147 tmp3 = (tmp3 >> 11U);
2148 tmp4 = (tmp4 >> 3U);
2149 tmp = ((tmp3 << 5U) | (tmp2 << 10U) | (tmp1 << 15U) | tmp4);
2153 tmp1 = (tmp1 >> 28U);
2154 tmp2 = (tmp2 >> 20U);
2155 tmp3 = (tmp3 >> 12U);
2156 tmp4 = (tmp4 >> 4U);
2157 tmp = ((tmp3 << 4U) | (tmp2 << 8U) | (tmp1 << 12U) | tmp4);
2160 WRITE_REG(hdma2d->Instance->OCOLR, tmp);
2162 else if (hdma2d->Init.Mode == DMA2D_M2M_BLEND_FG)
2164 WRITE_REG(hdma2d->Instance->BGMAR, pdata);
2169 WRITE_REG(hdma2d->Instance->FGMAR, pdata);