|
还是这种的API调用起来省事
- /**
- * @brief DMA2D conversion from YCbCr (video output) to RGB (Display frame buffer)
- * @param pSrc : Source buffer pointer
- * @param xsize: Horizontal size of the frame buffer
- * @param ysize: Vertical size of the frame buffer
- * @retval None
- */
- void DMA2D_CopyBuffer_YCbCr_To_RGB(uint32_t *pSrc, uint16_t xsize, uint16_t ysize)
- {
- uint32_t inputLineOffset = 0;
- uint32_t destination;
- U32 BufferSize;
- U32 regValue, regMask;
-
- /* Wait if there is a transfer in progress */
- _DMA2D_ExecOperation();
-
- /* Take the TransferInProgress flag */
- TransferInProgress = 1;
- /* Get the buffer size */
- BufferSize = _GetBufferSize(0);
-
- /* Calculate all the needed DMA2D inputs */
- destination = _aAddr[0] + BufferSize * _aBufferIndex[0];
-
- inputLineOffset = xsize % 16;
- if(inputLineOffset != 0)
- {
- inputLineOffset = 16 - inputLineOffset;
- }
-
- regValue = DMA2D_INPUT_YCBCR | (DMA2D_REPLACE_ALPHA << 16) | \
- (DMA2D_REGULAR_ALPHA << 20)| \
- (DMA2D_RB_REGULAR << 21) | \
- (0xFFU << 24) | \
- (DMA2D_CSS_420 << 18);
-
- regMask = DMA2D_BGPFCCR_CM | DMA2D_BGPFCCR_AM | DMA2D_BGPFCCR_ALPHA | DMA2D_BGPFCCR_AI | DMA2D_BGPFCCR_RBS | DMA2D_FGPFCCR_CSS;
-
- /* Setup DMA2D Configuration */
- DMA2D->CR = 0x00010000UL | (1 << 9);
- DMA2D->OPFCCR = DMA2D_OUTPUT_RGB565;
- DMA2D->OOR = 640 - xsize;
- DMA2D->OPFCCR |= (DMA2D_REGULAR_ALPHA << 20);
- DMA2D->OPFCCR |= (DMA2D_RB_REGULAR << 21);
- DMA2D->FGPFCCR |= (regMask & regValue);
- DMA2D->FGOR = inputLineOffset;
- DMA2D->NLR = (U32)(xsize << 16) | (U16)ysize;
- DMA2D->OMAR = (U32)destination;
- DMA2D->FGMAR = (U32)pSrc;
-
- /* Start the transfer, and enable the transfer complete IT */
- DMA2D->CR |= (1|DMA2D_IT_TC);
-
- /* Wait for the end of the transfer */
- _DMA2D_ExecOperation();
-
- }
复制代码
|
|