/*
 * @file hv_pm51_driver_GPIO.h
 * @brief Header file of GPIO driver.
 *
 * @verbatim
 * ==============================================================================
 *                        ##### How to use #####
 * ==============================================================================
 * (+) Use ()
 *
 * @endverbatim
 * @author HiView SoC Software Team
 * @version 1.0.0
 * @date 2023-03-01
 */

#ifndef __HV_PM51_DRIVER_GPIO_H__
#define __HV_PM51_DRIVER_GPIO_H__

#include "hv_pm51_Base.h"
#include "hv_pm51_Setting.h"
#include "hv_pm51_driver_Interrupt.h"

typedef enum _GpioEn
{
    GPIO0 = 0,      /* pinshare:0=gpio 1=low                         */
    GPIO1,          /* pinshare:0=gpio 1=aux_dprx_gpio_oe            */
    GPIO2,          /* pinshare:uartRX ,0=gpio 1=aux_dprx_gpio_out   */
    GPIO3,          /* pinshare:0=gpio,1=uartTX,2 & 3=low            */
    GPIO4,
    GPIO5,
    GPIO6,
    GPIO7,
    GPIO_ALL,
}GpioEn;

typedef enum _GpioDirEn
{
    GPIO_OUTPUT = 0,
    GPIO_INPUT,
}GpioDirEn;

typedef enum _GpioDcEn
{
    GPIO_DC_0 = 0,
    GPIO_DC_1,
    GPIO_DC_2,
    GPIO_DC_3,
    GPIO_DC_NUM,
}GpioDcEn;

typedef enum _GpioLevelEn
{
    GPIO_LEVEL_HIGH = 0,
    GPIO_LEVEL_LOW,
    GPIO_LEVEL_NUM,
}GpioLevelEn;

typedef enum _GpioIntEn
{
    GPIO_INTR_LEVEL_P = 0,
    GPIO_INTR_LEVEL_N,
    GPIO_INTR_EDGE_P,
    GPIO_INTR_EDGE_N,
    GPIO_INTR_TPYE_NUM,
}GpioIntEn;

typedef enum _GpioPuPdEn
{
    GPIO_PU,
    GPIO_PD,
    GPIO_PU_PD_MAX
}GpioPuPdEn;

/**
 * @brief This function init GPIO interrupt,after this function all GPIO interrupt disabled.
 * @return None.
*/
void Hv_PM51_Gpio_Init(void);


/**
 * @brief This function clear gpio interrupt signal.Must use it after interrupt service.
 * @param [in] enGpioSel                 GPIO index
 * @return None. 
*/
void Hv_PM51_Gpio_ClearIntState(GpioEn enGpioSel);


/**
 * @brief This function enable GPIO interrupt 
 * @param [in] enGpioSel                 GPIO index want to set
 * @param [in] enGpioInt                GPIO interrupt type
 * @return None. 
*/
void Hv_PM51_Gpio_EnableInt(GpioEn enGpioSel, GpioIntEn enGpioInt);

/**
 * @brief This function disable GPIO interrupt 
 * @param [in] enGpioSel                 GPIO index want to set
 * @return None. 
*/
void Hv_PM51_Gpio_DisableInt(GpioEn enGpioSel);

/**
 * @brief This function set GPIO pin share
 * @param [in] enGpioSel                 GPIO index want to set
 * @return None. 
*/
void Hv_PM51_Gpio_InitPin(GpioEn enGpioSel);

/**
 * @brief This function set GPIO direction
 * @param [in] enGpioSel                 GPIO index want to set
 * @param [in] enGpioDir                 GPIO as input or output
 * @return None. 
*/
void Hv_PM51_Gpio_SetIODirection(GpioEn enGpioSel,GpioDirEn enGpioDir);

/**
 * @brief This function set GPIO driver capability
 * @param [in] enGpioSel                 GPIO index want to set
 * @param [in] enGpioDc                  GPIO as driver capability
 * @return None. 
*/
void Hv_PM51_Gpio_SetIODC(GpioEn enGpioSel, GpioDcEn enGpioDc);

/**
 * @brief This function set GPIO output level
 * @param [in] enGpioSel                  GPIO index want to set
 * @param [in] enGpioLevel                GPIO set high or low
 * @return None. 
*/
void Hv_PM51_Gpio_SetOutputLevel(GpioEn enGpioSel,GpioLevelEn enGpioLevel);

/**
 * @brief This function set GPIO output level
 * @param [in] enGpioSel                 GPIO index want to get level
 * @param [in] penGpioLevel              point to val of GPIO level
 * @return None. 
 */
void Hv_PM51_Gpio_GetInputLevel(GpioEn enGpioSel, GpioLevelEn *penGpioLevel);

/**
 * @brief This function set GPIO pull up or pull down
 * @param [in] enGpioSel                 GPIO index want to get level
 * @param [in] enGpioPuPd                  GPIO set pull up or pull down
 * @return None. 
 */
void Hv_PM51_Gpio_SetPuPd(GpioEn enGpioSel, GpioPuPdEn enGpioPuPd);

#endif
