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

#ifdef __cplusplus
extern "C"
{
#endif
/* Includes ------------------------------------------------------------------*/
#include "hal_def.h"
#include "dcmi_drv.h"

  /**@defgroup HAL HAL driver
  *
  *@{
  */

  /** @defgroup HAL_DCMI DCMI
  *
  *@{
  */

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

#define HAL_DCMI_ERROR_NONE (0x00000000U)    /**< No error              */
#define HAL_DCMI_ERROR_BERR (0x00000001U)    /**< BERR error            */
#define HAL_DCMI_ERROR_ARLO (0x00000002U)    /**< ARLO error            */
#define HAL_DCMI_ERROR_AF (0x00000004U)      /**< ACKF error            */
#define HAL_DCMI_ERROR_OVR (0x00000008U)     /**< OVR error             */
#define HAL_DCMI_ERROR_DMA (0x00000010U)     /**< DMA transfer error    */
#define HAL_DCMI_ERROR_TIMEOUT (0x00000020U) /**< Timeout error         */
#define HAL_DCMI_ERROR_SIZE (0x00000040U)    /**< Size Management error */

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

  /**
  * @}
  */

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

  /**
  *@brief DCMI通信状态枚举
  */
  typedef enum
  {
    HAL_DCMI_STATE_RESET = 0x00, /**< Peripheral is not yet Initialized          */
    HAL_DCMI_STATE_READY = 0x20, /**< Peripheral Initialized and ready for use  */
    HAL_DCMI_STATE_BUSY = 0x24,  /**< An internal process is ongoing             */

    HAL_DCMI_STATE_ABORT = 0x60,   /**< Abort user request ongoing                 */
    HAL_DCMI_STATE_TIMEOUT = 0xA0, /**< Timeout state                              */
    HAL_DCMI_STATE_ERROR = 0xE0,   /**< Error                                     */

  } HAL_DCMI_StateTypeDef;

  /**
  *@brief DCMI句柄定义
  */
  typedef struct __DCMI_HandleTypeDef
  {
    DCMI_TypeDef *Instance; /**< DCMI 寄存器基址       */
    DCMI_InitTypeDef Init;  /**< 初始化结构体         */

    __IO HAL_DCMI_StateTypeDef State; /**< 状态                 */
    __IO uint32_t ErrorCode;          /**< 错误代码             */

    dcmi_callback_t callback; /**< 回调函数*/

  } DCMI_HandleTypeDef;

  /**
  * @}
  */

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

  /**
  * @}
  */

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

  extern HAL_StatusTypeDef HAL_DCMI_Getgray(DCMI_HandleTypeDef *hdcmi);

  extern HAL_StatusTypeDef HAL_DCMI_Init(DCMI_HandleTypeDef *hdcmi);

  /**
  * @}
  */

  /**
  *@}
  */

  /**
  *@}
  */

#ifdef __cplusplus
}
#endif

#endif /* __DCMI_HAL_H */

