#ifndef _BSP_DMA2D_H
#define _BSP_DMA2D_H

#include "main.h"
#include "dma2d.h"

// extern uint8_t dma2d_transfering;
void DMA2D_Fill( void * pDst, 
		uint32_t width, uint32_t height, uint32_t lineOff, uint32_t pixelFormat,  
		uint32_t color);

void DMA2D_MemCopy(uint32_t pixelFormat, 
				void * pSrc, void * pDst, 
				int xSize, int ySize, 
				int OffLineSrc, int OffLineDst);

void DMA2D_Blend(void* pFg, void* pBg, void* pDst,
    uint32_t offlineFg, uint32_t offlineBg, uint32_t offlineDist,
    uint16_t xSize, uint16_t ySize,
    uint32_t pixelFormat, uint8_t opa);

#endif

/*
Test 

    uint32_t gpubuf1[200];
    uint32_t gpubuf2[200];
    DMA2D_Fill( gpubuf1, 25, 8, 0, DMA2D_ARGB8888,  0xFFFFFFFF );
    if (gpubuf1[0] ==0xFFFFFFFF && gpubuf1[199] ==0xFFFFFFFF){
        log_i( "DMA2d Fill  Test Pass  %02X " ,  gpubuf1[199]);
    }
 
    dma2d_transfering =1;
    DMA2D_MemCopy(DMA2D_ARGB8888, gpubuf1, gpubuf2, 25, 8, 0, 0);
    osDelay(100);
    if (gpubuf2[0] ==0xFFFFFFFF && gpubuf2[199] ==0xFFFFFFFF){
        log_i( "DMA2D  MemCopy   Test Pass  %02X " ,  gpubuf2[199]);
    }  

    DMA2D->CR |= DMA2D_IT_TC;
    DMA2D->CR   |= DMA2D_CR_START;
	会产生两次DMA 传输完成中断
	第一次中断传输中断后，停止，数据也接收到，可能时间太短
	建议死等

    //  DMA 的寄存器启动
    void MYDMA_Enable(DMA_Stream_TypeDef *DMA_Streamx,u16 ndtr)
    {
        DMA_Streamx->CR&=~(1<<0); 	//关闭DMA传输 
        while(DMA_Streamx->CR&0X1);	//确保DMA可以被设置  
        DMA_Streamx->NDTR=ndtr;		//DMA 存储器0地址 
        DMA_Streamx->CR|=1<<0;		//开启DMA传输
    }	

    // 读 GPIOB pin13 电平
    #define NAND_RB  	 (((GPIOB->IDR) >> 13) & 0x1U) 
*/