/*!
* @file     Icu_Eint.h
*
* @version  1.0.0
*
* @brief    Data Type Definition and function declaration File for the ICU Module Based on EINT IP
*
* @attention
*
* Project Name      : AUTOSAR MCAL
*
* Platform          : Arm
*
* Autosar Standard  : Classic Platform 4.4.0
*
* Compiled Version  : G32A10xx_MCAL_1_0_0_01-Otc-25
*
* Copyright (C) 2026 Geehy Semiconductor
*
* You may not use this file except in compliance with the
* GEEHY COPYRIGHT NOTICE (Geehy Semiconductor Software License Agreement).
*
* The program is only for reference, which is distributed in the hope
* that it will be usefull and instructional for customers to develop
* their software. Unless required by applicable law or agreed to in
* writing, the program is distributed on an "AS IS" BASIS, WITHOUT
* ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied.
* See the Geehy Semiconductor Software License Agreement for the governing permissions
* and limitations under the License.
*/

#ifndef ICU_EINT_H
#define ICU_EINT_H

#ifdef __cplusplus
extern "C"{
#endif

#include "Icu_EintReg.h"

/** @addtogroup G32A10xx_StdPeriphDriver
  @{
*/

/** @defgroup ICU_Driver
  * @brief ICU driver modules
  @{
*/

/** @defgroup ICU_Macros
  @{
*/
/***********************************************************************************************************************
                                    VENDOR ID & AUTOSAR VERSION INFO
***********************************************************************************************************************/
/** Vendor ID (vendorId) of the dedicated implementation of this module according to the AUTOSAR vendor list. */
#define ICU_EINT_H_VENDOR_ID                       0x00C1U
/** Major version number of AUTOSAR release on which the appropriate implementation is based on. */
#define ICU_EINT_H_AR_RELEASE_MAJOR_VERSION        0x04U
/** Minor version number of AUTOSAR release on which the appropriate implementation is based on. */
#define ICU_EINT_H_AR_RELEASE_MINOR_VERSION        0x04U
/** Revision version number of AUTOSAR release on which the appropriate implementation is based on. */
#define ICU_EINT_H_AR_RELEASE_REVISION_VERSION     0x00U
/** Major version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define ICU_EINT_H_SW_MAJOR_VERSION                0x01U
/** Minor version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define ICU_EINT_H_SW_MINOR_VERSION                0x00U
/** Patch level version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define ICU_EINT_H_SW_PATCH_VERSION                0x00U

/**@} end of group ICU_Macros */

/**********************************************************************************************************************
                                        VERSION INFOMATION VERIFICATION
***********************************************************************************************************************/
/** @defgroup ICU_Macros
  @{
*/

/** No interrupt selected */
#define EINT_LINENONE                  ((uint32_t)0x00000)

/** EINT register reset value */
#define EINT_INTMASK_RESET_VALUE       ((uint32_t)(0x7F840000))
/** EINT Event MASK register reset value */
#define EINT_EVTMASK_RESET_VALUE       ((uint32_t)(0x00000000))
/** EINT Rising Trigger enable register reset value */
#define EINT_RTSEL_RESET_VALUE         ((uint32_t)(0x00000000))
/** EINT Falling Trigger enable register reset value */
#define EINT_FTSEL_RESET_VALUE         ((uint32_t)(0x00000000))
/** EINT Interrupt Pending register reset value */
#define EINT_PEND_RESET_VALUE          ((uint32_t)(0x00000000))

/** EINT channel */
#define EINT_HW_CH0                    ((uint8_t)0x00U)
#define EINT_HW_CH1                    ((uint8_t)0x01U)
#define EINT_HW_CH2                    ((uint8_t)0x02U)
#define EINT_HW_CH3                    ((uint8_t)0x03U)
#define EINT_HW_CH4                    ((uint8_t)0x04U)
#define EINT_HW_CH5                    ((uint8_t)0x05U)
#define EINT_HW_CH6                    ((uint8_t)0x06U)
#define EINT_HW_CH7                    ((uint8_t)0x07U)
#define EINT_HW_CH8                    ((uint8_t)0x08U)
#define EINT_HW_CH9                    ((uint8_t)0x09U)
#define EINT_HW_CH10                   ((uint8_t)0x0AU)
#define EINT_HW_CH11                   ((uint8_t)0x0BU)
#define EINT_HW_CH12                   ((uint8_t)0x0CU)
#define EINT_HW_CH13                   ((uint8_t)0x0DU)
#define EINT_HW_CH14                   ((uint8_t)0x0EU)
#define EINT_HW_CH15                   ((uint8_t)0x0FU)

/**@} end of group ICU_Macros */

/**********************************************************************************************************************
                                             ENUMERATION DEFINITION
***********************************************************************************************************************/
/** @defgroup ICU_Enumerations
  @{
*/

/*!
 * @brief   EINT mode
 */
typedef enum
{
    EINT_MODE_INTERRUPT   = ((uint8)0x00), //!< EINT mode select interrupt
    EINT_MODE_EVENT       = ((uint8)0x01)  //!< EINT mode select event
} Icu_Eint_ModeType;

/*!
 * @brief   EINT trigger mode
 */
typedef enum
{
    EINT_TRIGGER_RISING   = ((uint8)0x00), //!< EINT trigger select rising edge
    EINT_TRIGGER_FALLING  = ((uint8)0x01), //!< EINT trigger select falling edge
    EINT_TRIGGER_ALL      = ((uint8)0x02)  //!< EINT trigger select rising and falling edge
} Icu_Eint_TriggerType;

/*!
 * @brief   EINT line
 */
typedef enum
{
    EINT_LINE0   = ((uint32)0x00000001),  //!< External interrupt line 0
    EINT_LINE1   = ((uint32)0x00000002),  //!< External interrupt line 1
    EINT_LINE2   = ((uint32)0x00000004),  //!< External interrupt line 2
    EINT_LINE3   = ((uint32)0x00000008),  //!< External interrupt line 3
    EINT_LINE4   = ((uint32)0x00000010),  //!< External interrupt line 4
    EINT_LINE5   = ((uint32)0x00000020),  //!< External interrupt line 5
    EINT_LINE6   = ((uint32)0x00000040),  //!< External interrupt line 6
    EINT_LINE7   = ((uint32)0x00000080),  //!< External interrupt line 7
    EINT_LINE8   = ((uint32)0x00000100),  //!< External interrupt line 8
    EINT_LINE9   = ((uint32)0x00000200),  //!< External interrupt line 9
    EINT_LINE10  = ((uint32)0x00000400),  //!< External interrupt line 10
    EINT_LINE11  = ((uint32)0x00000800),  //!< External interrupt line 11
    EINT_LINE12  = ((uint32)0x00001000),  //!< External interrupt line 12
    EINT_LINE13  = ((uint32)0x00002000),  //!< External interrupt line 13
    EINT_LINE14  = ((uint32)0x00004000),  //!< External interrupt line 14
    EINT_LINE15  = ((uint32)0x00008000)   //!< External interrupt line 15
} Icu_Eint_LineType;

/*!
 * @brief   EINT function status
 */
typedef enum
{
    FUN_DISABLE = ((uint8)0),
    FUN_ENABLE =  ((uint8)1)
}Icu_Eint_FunStsType;

/*!
 * @brief   EINT state of flag
 */
typedef enum
{
    RESET_STS = ((uint8)0),
    SET_STS   = ((uint8)1)
}Icu_Eint_FlagType;

/**@} end of group ICU_Enumerations */

/**********************************************************************************************************************
                                             OTHER TYPE DEFINITION
***********************************************************************************************************************/
/** @defgroup ICU_Structure
  @{
*/

/** Eint notification type */
typedef void (*Icu_Eint_NotifyType)(void);

/*!
 * @brief   EINT Config struct definition
 */
typedef struct
{
    uint32            line;        //!< Specifies the new state of the selected EINT lines.
    Icu_Eint_ModeType     mode;    //!< Specifies the mode for the EINT lines.
    Icu_Eint_TriggerType  trigger; //!< Specifies the trigger signal active edge for the EINT lines.
    uint8             lineCmd;     //!< Specifies the EINT lines to be enabled or disabled.
    Icu_Eint_NotifyType   eintChNotifiFuncPtr; //!< Specifies the notification function to be called when the EINT line is triggered.
} Icu_Eint_ConfigType;

/** EINT channel definition */
typedef Icu_Eint_LineType Icu_EintChType;

/**@} end of group ICU_Structure */

/**********************************************************************************************************************
                                              FUNCTION DECLARATION
***********************************************************************************************************************/
/** @defgroup ICU_Fuctions
  @{
*/

FUNC(void, ICU_CODE) Icu_Eint_Reset(void);
FUNC(void, ICU_CODE) Icu_Eint_Config(P2CONST(Icu_Eint_ConfigType, AUTOMATIC, ICU_APPL_CONST) EintConfigPtr);
FUNC(void, ICU_CODE) Icu_Eint_ConfigStructInit(P2VAR(Icu_Eint_ConfigType, AUTOMATIC, ICU_APPL_CONST) EintConfigPtr);

FUNC(void, ICU_CODE) Icu_Eint_SelectSWInterrupt(VAR(uint32, AUTOMATIC) Line);
FUNC(void, ICU_CODE) Icu_Eint_EnableInt(VAR(uint32, AUTOMATIC) Line);
FUNC(void, ICU_CODE) Icu_Eint_DisableInt(VAR(uint32, AUTOMATIC) Line);
FUNC(Icu_Eint_FlagType, ICU_CODE) Icu_Eint_GetIntEnSts(VAR(uint32, AUTOMATIC) Line);
FUNC(void, ICU_CODE) Icu_Eint_EnableEvent(VAR(uint32, AUTOMATIC) Line);
FUNC(void, ICU_CODE) Icu_Eint_DisableEvent(VAR(uint32, AUTOMATIC) Line);
FUNC(void, ICU_CODE) Icu_Eint_EnableRisingTrig(VAR(uint32, AUTOMATIC) Line);
FUNC(void, ICU_CODE) Icu_Eint_DisableRisingTrig(VAR(uint32, AUTOMATIC) Line);
FUNC(void, ICU_CODE) Icu_Eint_EnableFailingTrig(VAR(uint32, AUTOMATIC) Line);
FUNC(void, ICU_CODE) Icu_Eint_DisableFailingTrig(VAR(uint32, AUTOMATIC) Line);

FUNC(Icu_Eint_FlagType, ICU_CODE) Icu_Eint_ReadStatusFlag(VAR(uint32, AUTOMATIC) Line);
FUNC(void, ICU_CODE)  Icu_Eint_ClearStatusFlag(VAR(uint32, AUTOMATIC) Line);
FUNC(Icu_Eint_FlagType, ICU_CODE) Icu_Eint_ReadIntFlag(VAR(uint32, AUTOMATIC) Line);
FUNC(void, ICU_CODE)  Icu_Eint_ClearIntFlag(VAR(uint32, AUTOMATIC) Line);

void EINT0_1_IRQHandler(void);
void EINT2_3_IRQHandler(void);
void EINT4_15_IRQHandler(void);

/**@} end of group ICU_Fuctions */

#ifdef __cplusplus
}
#endif

#endif

/**@} end of group ICU_Driver */
/**@} end of group G32A10xx_StdPeriphDriver */
