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

#ifndef __HV_PM51_DRIVER_INTERRUPT_H__
#define __HV_PM51_DRIVER_INTERRUPT_H__

#include "hv_pm51_Base.h"

/* uart rx intr disable for all the time */
#define INTR_IE_ENABLE_ALL       0xEF   /* 0xEF: disable uart rx */
#define INTR_EI1_ENABLE_ALL      0xFF
#define INTR_IE_DISABLE_ALL      0x00
#define INTR_EI1_DISABLE_ALL     0x00

typedef union
{
    USHORT16 All;
    struct 
    {
        volatile USHORT16 stIntFlagExternal0          :1;
        volatile USHORT16 stIntFlagInnerTimer0        :1;
        volatile USHORT16 stIntFlagExternal1          :1;
        volatile USHORT16 stIntFlagInnerTimer1        :1;
        volatile USHORT16 stIntFlagUart               :1;
        volatile USHORT16 stIntFlagInnerTimer2        :1;
        volatile USHORT16 stIntFlagReserved0          :1;
        volatile USHORT16 stIntFlagExTimer0           :1;
        volatile USHORT16 stIntFlagExTimer1           :1;
        volatile USHORT16 stIntFlagPwrKey             :1;
        volatile USHORT16 stIntFlagMips               :1;
        volatile USHORT16 stIntFlagWakeup             :1;
        volatile USHORT16 stIntFlagEvent               :1;
        volatile USHORT16 stIntFlagWdg                :1;
        volatile USHORT16 stIntFlagReserved1          :1;
        volatile USHORT16 stIntFlagReserved2          :1;
    } Bits;    
}IntFlags;

typedef union
{
    USHORT16 All;
    struct 
    {
        volatile USHORT16 stWakeupIntFlagDpCable0      :1;
        volatile USHORT16 stWakeupIntFlagAux0         :1;
        volatile USHORT16 stWakeupIntFlagAux1         :1;
        volatile USHORT16 stWakeupIntFlagHdmiCable0 :1;
        volatile USHORT16 stWakeupIntFlagAdc0         :1;
        volatile USHORT16 stWakeupIntFlagAdc1         :1;
        volatile USHORT16 stWakeupIntFlagRxPhy0     :1;
        volatile USHORT16 stWakeupIntFlagRxPhy1     :1;
        volatile USHORT16 stWakeupIntFlagTmds0      :1;
        volatile USHORT16 stWakeupIntFlagTmds1      :1;
        volatile USHORT16 stWakeupIntFlagDpCable1   :1;
        volatile USHORT16 stWakeupIntFlagHdmiCable1 :1;
        volatile USHORT16 stWakeupIntFlagHdmiCec0   :1;
        volatile USHORT16 stWakeupIntFlagHdmiCec1   :1;
        volatile USHORT16 stWakeupIntFlagTypec0     :1;
        volatile USHORT16 stWakeupIntFlagTypec1     :1;
    } Bits;    
}WakeupIntFlags;

typedef union
{
    UCHAR8 All;
    struct 
    {
        volatile UCHAR8 stMiscIntHdmi0EdidSeg       :1;
        volatile UCHAR8 stMiscIntHdmi1EdidSeg       :1;
        volatile UCHAR8 stMiscIntFlagReserved1      :1;
        volatile UCHAR8 stMiscIntFlagReserved2      :1;
        volatile UCHAR8 stMiscIntFlagReserved3      :1;
        volatile UCHAR8 stMiscIntFlagReserved4      :1;
        volatile UCHAR8 stMiscIntFlagReserved5      :1;
        volatile UCHAR8 stMiscIntFlagReserved6      :1;
    } Bits;    
}MiscIntFlags;

typedef union
{
    USHORT16 All;
    struct 
    {
        volatile USHORT16 stEventIntFlagGpio0         :1;
        volatile USHORT16 stEventIntFlagGpio1         :1;
        volatile USHORT16 stEventIntFlagGpio2         :1;
        volatile USHORT16 stEventIntFlagGpio3         :1;
        volatile USHORT16 stEventIntFlagGpio4         :1;
        volatile USHORT16 stEventIntFlagGpio5         :1;
        volatile USHORT16 stEventIntFlagGpio6         :1;
        volatile USHORT16 stEventIntFlagGpio7         :1;
        volatile USHORT16 stEventIntFlagSw            :1;
        volatile USHORT16 stEventIntFlagPwm           :1;
        volatile USHORT16 stEventIntFlagReserved1   :1;
        volatile USHORT16 stEventIntFlagReserved2   :1;
        volatile USHORT16 stEventIntFlagReserved3   :1;
        volatile USHORT16 stEventIntFlagReserved4   :1;
        volatile USHORT16 stEventIntFlagReserved5   :1;
        volatile USHORT16 stEventIntFlagReserved6   :1;
    } Bits;    
}EventIntFlags;

typedef enum
{
    INTR_NO0_External       = BIT_0 ,
    INTR_NO1_INNER_TIMER0   = BIT_1 ,
    INTR_NO2_External       = BIT_2 ,
    INTR_NO3_INNER_TIMER1   = BIT_3 ,
    INTR_NO4_UART           = BIT_4 ,
    INTR_NO5_INNER_TIMER2   = BIT_5 ,
    INTR_NO6_Reserved       = BIT_6 ,
    INTR_NO7_EX_TIMER0      = BIT_7 ,
    INTR_NO8_EX_TIMER1      = BIT_8 ,
    INTR_NO9_PMU            = BIT_9 ,
    INTR_NO10_MIPS          = BIT_10,
    INTR_NO11_WAKEUP        = BIT_11,
    INTR_NO12_GPIO          = BIT_12,
    INTR_NO13_WDG           = BIT_13,
}ENINTR_NO;

typedef void (*pInterruptCallback)(ENINTR_NO Intr_NO);

typedef enum _IntStateSelEn
{
    STATE_INTR_PWR_KEY = 0,
    STATE_INTR_STB_REG,
    /////////////////////
    STATE_INTR_DP_CABLE_0,
    STATE_INTR_AUX_0,
    STATE_INTR_AUX_1,
    STATE_INTR_HDMI_CABLE_0,
    STATE_INTR_ADC0,
    STATE_INTR_ADC1,
    STATE_INTR_RX_PHY_0,
    STATE_INTR_RX_PHY_1,
    STATE_INTR_RX_PHY_2,
    STATE_INTR_RX_PHY_3,
    STATE_INTR_DP_CABLE_1,
    STATE_INTR_HDMI_CABLE_1,
    STATE_INTR_HDMI_CEC_0,
    STATE_INTR_HDMI_CEC_1,
    STATE_INTR_TYPE_C_0,
    STATE_INTR_TYPE_C_1,
    STATE_INTR_SEL_NUM,
}IntStateSelEn;

typedef enum _IntStateTypeEn
{
    STATE_INTR_LEVEL_P = 0,
    STATE_INTR_LEVEL_N,
    STATE_INTR_EDGE_P,
    STATE_INTR_EDGE_N,
    STATE_INTR_TPYE_NUM,
}IntStateTypeEn;

/**
 * @brief This function init interrupt, after this function all interrupt enable.
 * @return None.
*/
void Hv_PM51_Int_Init(void);

/**
 * @brief This function enable all interrupt.
 * @return None. 
*/
void Hv_PM51_Int_EnableAll(void);

/**
 * @brief This function disable all interrupt.
 * @return None.
*/
void Hv_PM51_Int_DisableAll(void);

#endif
