硬汉嵌入式论坛

 找回密码
 立即注册
查看: 2880|回复: 1
收起左侧

[DMA2D] STM32H7的DMA2D做Alpha混合和颜色混合比之前F429方便很多了

[复制链接]

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
106649
QQ
发表于 2019-4-22 03:13:07 | 显示全部楼层 |阅读模式

后实测下Alpha混合的性能。

  1. /**
  2.   * @brief  DMA2D Alpha blending bulk
  3.   * @param  pColorFG : Foregroung color
  4.   * @param  pColorBG : Backgroung color
  5.   * @param  pColorDst: Destination color
  6.   * @param  NumItems : Number of lines
  7.   * @retval None
  8.   */
  9. static void _DMA_AlphaBlendingBulk(LCD_COLOR * pColorFG, LCD_COLOR * pColorBG, LCD_COLOR * pColorDst, U32 NumItems)
  10. {  
  11.   /* Wait if there is a transfer in progress */
  12.   _DMA2D_ExecOperation();
  13.   
  14.   /* Take the TransferInProgress flag */
  15.   TransferInProgress = 1;
  16.   
  17.   /* Setup DMA2D Configuration */  
  18.   DMA2D->CR      = 0x00020000UL | (1 << 9);
  19.   DMA2D->FGMAR   = (U32)pColorFG;
  20.   DMA2D->BGMAR   = (U32)pColorBG;
  21.   DMA2D->OMAR    = (U32)pColorDst;
  22.   DMA2D->FGOR    = 0;
  23.   DMA2D->BGOR    = 0;
  24.   DMA2D->OOR     = 0;
  25.   DMA2D->FGPFCCR = LTDC_PIXEL_FORMAT_ARGB8888;
  26.   DMA2D->BGPFCCR = LTDC_PIXEL_FORMAT_ARGB8888;
  27.   DMA2D->OPFCCR  = LTDC_PIXEL_FORMAT_ARGB8888;
  28.   DMA2D->NLR     = (U32)(NumItems << 16) | 1;
  29.   
  30.   /* Start the transfer, and enable the transfer complete IT */
  31.   DMA2D->CR     |= (1|DMA2D_IT_TC);
  32.   
  33.   /* Wait for the end of the transfer */
  34.   _DMA2D_ExecOperation();
  35. }

  36. /**
  37.   * @brief  Mixing bulk colors
  38.   * @param  pColorFG : Foregroung color
  39.   * @param  pColorBG : Backgroung color
  40.   * @param  pColorDst: Destination color
  41.   * @param  Intens   : Color intensity
  42.   * @param  NumItems : Number of lines
  43.   * @retval None
  44.   */
  45. static void _DMA_MixColorsBulk(LCD_COLOR * pColorFG, LCD_COLOR * pColorBG, LCD_COLOR * pColorDst, U8 Intens, U32 NumItems)
  46. {
  47.   /* Wait if there is a transfer in progress */
  48.   _DMA2D_ExecOperation();
  49.   
  50.   /* Take the TransferInProgress flag */
  51.   TransferInProgress = 1;

  52.   /* Setup DMA2D Configuration */
  53.   DMA2D->CR      = 0x00020000UL | (1 << 9);
  54.   DMA2D->FGMAR   = (U32)pColorFG;
  55.   DMA2D->BGMAR   = (U32)pColorBG;
  56.   DMA2D->OMAR    = (U32)pColorDst;
  57.   DMA2D->FGPFCCR = LTDC_PIXEL_FORMAT_ARGB8888
  58.                  | (1UL << 16)
  59.                  | ((U32)Intens << 24);
  60.   DMA2D->BGPFCCR = LTDC_PIXEL_FORMAT_ARGB8888
  61.                  | (0UL << 16)
  62.                  | ((U32)(255 - Intens) << 24);
  63.   DMA2D->OPFCCR  = LTDC_PIXEL_FORMAT_ARGB8888;
  64.   DMA2D->NLR     = (U32)(NumItems << 16) | 1;
  65.   
  66.   /* Start the transfer, and enable the transfer complete IT */
  67.   DMA2D->CR     |= (1|DMA2D_IT_TC);

  68.   /* Wait for the end of the transfer */
  69.   _DMA2D_ExecOperation();
  70. }
复制代码


回复

使用道具 举报

609

主题

3045

回帖

4892

积分

至尊会员

积分
4892
发表于 2019-4-24 16:04:07 | 显示全部楼层
看来后续的 gui 界面很快就要出来了哟,期待中 ...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2024-4-27 22:13 , Processed in 0.235954 second(s), 25 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表