/**
  ******************************************************************************
  * @file    dma2d_hal.h
  * @author  Product application department
  * @version V1.0
  * @date    2020.05.25
  * @brief   Header file of DMA2D HAL module.
  *
  ******************************************************************************
  */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __DMA2D_HAL_H
#define __DMA2D_HAL_H

#ifdef __cplusplus
extern "C"
{
#endif
/* Includes ------------------------------------------------------------------*/
#include "hal_def.h"
#include "dma2d_drv.h"
/**@defgroup HAL HAL driver
  *
  *@{
  */

/** @defgroup HAL_DMA2D DMA2D
  *
  *@{
  */

/*** 宏定义 *******************************************************************/
/** @defgroup I2C_Exported_Macros Exported Macros
  *
  * @{
  */

#define HAL_DMA2D_ERROR_NONE      (0x00000000U)    /**< No error              */
#define HAL_DMA2D_ERROR_BERR      (0x00000001U)    /**< BERR error            */
#define HAL_DMA2D_ERROR_ARLO      (0x00000002U)    /**< ARLO error            */
#define HAL_DMA2D_ERROR_AF        (0x00000004U)    /**< ACKF error            */
#define HAL_DMA2D_ERROR_OVR       (0x00000008U)    /**< OVR error             */
#define HAL_DMA2D_ERROR_DMA       (0x00000010U)    /**< DMA transfer error    */
#define HAL_DMA2D_ERROR_TIMEOUT   (0x00000020U)    /**< Timeout error         */
#define HAL_DMA2D_ERROR_SIZE      (0x00000040U)    /**< Size Management error */

/**
  *@brief  回调函数类型定义
  *
  */
  typedef void (*dma2d_callback_t)(void*);

/**
  *@}
  */

/*** 结构体、枚举变量定义 *****************************************************/
/** @defgroup DMA2D_Exported_Types Exported Types
  *
  * @{
  */

/**
  *@brief DMA2D通信状态枚举
  */
typedef enum
{
    HAL_DMA2D_STATE_RESET             = 0x00,    /**< Peripheral is not yet Initialized          */
    HAL_DMA2D_STATE_READY             = 0x20,    /**< Peripheral Initialized and ready for use  */
    HAL_DMA2D_STATE_BUSY              = 0x24,    /**< An internal process is ongoing             */
                                                                        
    HAL_DMA2D_STATE_ABORT             = 0x60,    /**< Abort user request ongoing                 */
    HAL_DMA2D_STATE_TIMEOUT           = 0xA0,    /**< Timeout state                              */
    HAL_DMA2D_STATE_ERROR             = 0xE0,    /**< Error                                     */

}HAL_DMA2D_StateTypeDef;

/**
  *@brief DMA2D模块初始化结构体定义.
  *
  */
typedef struct __DMA2D_HandleTypeDef
{
    DMA2D_TypeDef                   *Instance;      /**< DMA2D 寄存器基址       */
    DMA2D_InitTypeDef               Init;           /**< 初始化结构体         */
    
    __IO HAL_DMA2D_StateTypeDef     State;          /**< 状态                 */
	  __IO uint32_t                   ErrorCode;      /**< 错误代码             */
	
	  dma2d_callback_t                callback;       /**< 回调函数*/
	
} DMA2D_HandleTypeDef;

/**
  * @}
  */

/*** 全局变量声明 **************************************************************/
/** @defgroup DMA2D_Exported_Variables Exported Variables
  *
  * @{
  */

/**
  * @}
  */

/*** 函数声明 ******************************************************************/
/** @defgroup DMA2D_Exported_Functions Exported Functions
  * @{
  */

  extern void HAL_DMA2D_SoftReset(void);

  extern void HAL_DMA2D_ClutInit(uint32_t* addr, int32_t len);

  extern void HAL_DMA2D_FgClutLoad(DMA2D_HandleTypeDef *hdma2d);

  extern HAL_StatusTypeDef HAL_DMA2D_PfcHard(DMA2D_HandleTypeDef *hdma2d);

  extern HAL_StatusTypeDef HAL_DMA2D_Reg2Mem(DMA2D_HandleTypeDef *hdma2d);

  extern HAL_StatusTypeDef HAL_DMA2D_Mem2Mem(DMA2D_HandleTypeDef *hdma2d);

  extern HAL_StatusTypeDef HAL_DMA2D_BlendHard(DMA2D_HandleTypeDef *hdma2d);

/**
  * @}
  */

/**
  *@}
  */

/**
  *@}
  */
#ifdef __cplusplus
}
#endif

#endif /* __DMA2D_HAL_H */

