/**
*   @file    Icu_eMios_Types.h
*   @version 1.0.0
*
*   @brief   AUTOSAR Icu - Brief file description (one line).
*   @details Detailed file description (can be multiple lines).
*
*   @addtogroup EMIOS_DRIVER
*   @{
*/
/*==================================================================================================
*   Project              : AUTOSAR 4.3 MCAL
*   Platform             : PA
*   Peripheral           : eMIOS SIU
*   Dependencies         : none
*
*   Autosar Version      : 4.3.1
*   Autosar Revision     : ASR_REL_4_3_REV_0001
*   Autosar Conf.Variant :
*   SW Version           : 1.0.0
*   Build Version        : MPC5777C_MCAL_1_0_0_RTM_ASR_REL_4_3_REV_0001_20190315
*
*   (c) Copyright 2006-2016 Freescale Semiconductor, Inc. 
*       Copyright 2017-2019 NXP
*   All Rights Reserved.
==================================================================================================*/
/*==================================================================================================
==================================================================================================*/

#ifndef ICU_EMIOS_TYPES_H
#define ICU_EMIOS_TYPES_H

#ifdef __cplusplus
extern "C"{
#endif

/**
* @page misra_violations MISRA-C:2012 violations
*
* @section [global]
* Violates MISRA 2012 Required Rule 5.1, External identifiers shall be distinct.
* The used compilers use more than 31 chars for identifiers.
*
* @section [global]
* Violates MISRA 2012 Required Rule 5.2, Identifiers declared in the same scope and name space shall be distinct.
* The used compilers use more than 31 chars for identifiers.
*
* @section [global]
* Violates MISRA 2012 Required Rule 5.4, Macro identifiers shall be distinct.
* The used compilers use more than 31 chars for identifiers.
*
* @section [global]
* Violates MISRA 2012 Required Rule 5.5, Identifiers shall be distinct from macro names.
* The used compilers use more than 31 chars for identifiers.
*
* @section ICU_EMIOS_TYPES_H_REF_1
* Violates MISRA 2012 Advisory Directive 4.9, A function should be used in preference to a function-like macro
* where they are interchangeable.
* This violation is done to reduce code complexity by using function-like macros
*
* @section ICU_EMIOS_TYPES_H_REF_2
* Violates MISRA 2012 Advisory Rule 2.5, A project should not contain unused macro declarations.
* Define is/might be used in configuration.
*
*/

/*==================================================================================================
                                         INCLUDE FILES
 1) system and project includes
 2) needed interfaces from external units
 3) internal and external interfaces from this unit
==================================================================================================*/
#include "Std_Types.h"
#include "eMios_Common_Types.h"
/*==================================================================================================
                               SOURCE FILE VERSION INFORMATION
==================================================================================================*/
#define ICU_EMIOS_TYPES_VENDOR_ID                       43
#define ICU_EMIOS_TYPES_AR_RELEASE_MAJOR_VERSION        4
#define ICU_EMIOS_TYPES_AR_RELEASE_MINOR_VERSION        3
#define ICU_EMIOS_TYPES_AR_RELEASE_REVISION_VERSION     1
#define ICU_EMIOS_TYPES_SW_MAJOR_VERSION                1
#define ICU_EMIOS_TYPES_SW_MINOR_VERSION                0
#define ICU_EMIOS_TYPES_SW_PATCH_VERSION                0

/*==================================================================================================
                                      FILE VERSION CHECKS
==================================================================================================*/
/* Check if header file and Std_Types.h file are of the same Autosar version */
#ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
    #if ((ICU_EMIOS_TYPES_AR_RELEASE_MAJOR_VERSION != STD_AR_RELEASE_MAJOR_VERSION) || \
         (ICU_EMIOS_TYPES_AR_RELEASE_MINOR_VERSION != STD_AR_RELEASE_MINOR_VERSION))
    #error "AutoSar Version Numbers of Icu_eMios_Types.h and Std_Types.h are different"
    #endif
#endif
/*==================================================================================================
                                           CONSTANTS
==================================================================================================*/

/*==================================================================================================
                                       DEFINES AND MACROS
==================================================================================================*/

/**
* @brief EMIOS unified channel digital filter control
* @note Hardware Dependent Definition - DO NOT CHANGE
*/

/**
* @violates @ref ICU_EMIOS_TYPES_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused macro declarations.
*/
#define EMIOS_DIGITAL_FILTER_BYPASSED       (0U)
/**
* @violates @ref ICU_EMIOS_TYPES_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused macro declarations.
*/
#define EMIOS_DIGITAL_FILTER_02             (BIT0)
/**
* @violates @ref ICU_EMIOS_TYPES_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused macro declarations.
*/
#define EMIOS_DIGITAL_FILTER_04             (BIT1)
/**
* @violates @ref ICU_EMIOS_TYPES_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused macro declarations.
*/
#define EMIOS_DIGITAL_FILTER_08             (BIT2)
/**
* @violates @ref ICU_EMIOS_TYPES_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused macro declarations.
*/
#define EMIOS_DIGITAL_FILTER_16             (BIT3)


/**
* @brief EMIOS controller register values
*/
/* @violates @ref ICU_EMIOS_TYPES_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused macro declarations. */
#define EMIOS_CCR_CLEAR_U32                     (0x00000000U)
/* @violates @ref ICU_EMIOS_TYPES_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused macro declarations. */
#define EMIOS_CADR_CLEAR_U32                    (0x00000000U)
/* @violates @ref ICU_EMIOS_TYPES_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused macro declarations. */
#define EMIOS_INIT_CADR_U32                     (0x00FFFFFFU)
/* @violates @ref ICU_EMIOS_TYPES_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused macro declarations. */
#define EMIOS_CBDR_CLEAR_U32                    (0x00000000U)
/* @violates @ref ICU_EMIOS_TYPES_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused macro declarations. */
#define EMIOS_CCNTR_CLEAR_U32                   (0x00000000U)
/* @violates @ref ICU_EMIOS_TYPES_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused macro declarations. */
#define EMIOS_INIT_CCNTR_U32                    (0x00000000U)
/* @violates @ref ICU_EMIOS_TYPES_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused macro declarations. */
#define EMIOS_CSR_CLEAR_U32                     (0xFFFFFFFFU)

/**
* @{
* @brief Specific eMIOS Channel parameters
* @remarks defines for bitfields used in Icu_ParamValue member for ICU eMIOS Channels
*/

#if (ICU_DUAL_CLOCK_MODE_API == STD_ON)

#define ICU_EMIOS_PRESC_ALT_PARAM_MASK          (BIT14|BIT13)
#define ICU_EMIOS_PRESC_ALT_PARAM_SHIFT         (13U)

#endif

#define ICU_EMIOS_UC_MODE_PARAM_MASK            (BIT12|BIT11|BIT10|BIT9)
#define ICU_EMIOS_UC_MODE_PARAM_SHIFT           (9U)
#define ICU_EMIOS_FREEZE_PARAM_MASK             (BIT8)
#define ICU_EMIOS_FREEZE_PARAM_SHIFT            (8U)
#define ICU_EMIOS_PRESCALER_PARAM_MASK          (BIT7|BIT6)
#define ICU_EMIOS_PRESCALER_PARAM_SHIFT         (6U)
#define ICU_EMIOS_DIG_FILTER_PARAM_MASK         (BIT5|BIT4|BIT3|BIT2)
#define ICU_EMIOS_DIG_FILTER_PARAM_SHIFT        (2U)
#define ICU_EMIOS_BUS_SELECT_PARAM_MASK         (BIT1|BIT0)
#define ICU_EMIOS_BUS_SELECT_PARAM_SHIFT        (0U)

/**
* @violates @ref ICU_EMIOS_TYPES_H_REF_1 A function should be used in preference to a function-like macro
* where they are interchangeable.
* @violates @ref ICU_EMIOS_TYPES_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused macro declarations.
*/
#define CH_GENERATING_EMIOS_BUS_A(mIdx)         ((uint8)((uint8)((mIdx) << EMIOS_MOD_SHIFT) + EMIOS_CHANNEL_23))
/**
* @violates @ref ICU_EMIOS_TYPES_H_REF_1 A function should be used in preference to a function-like macro
* where they are interchangeable.
* @violates @ref ICU_EMIOS_TYPES_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused macro declarations.
*/
#define CH_GENERATING_EMIOS_BUS_F(mIdx)         ((uint8)((uint8)((mIdx) << EMIOS_MOD_SHIFT) + EMIOS_CHANNEL_22))

/* EMIOS_UC_IPM_MODE : Input Period Measurement mode */
/* @violates @ref ICU_EMIOS_TYPES_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused macro declarations. */
#define EMIOS_UC_IPM_MODE           0x3U
/* EMIOS_UC_IPWM_MODE : Input Pulse Width Measurement mode */
/* @violates @ref ICU_EMIOS_TYPES_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused macro declarations. */
#define EMIOS_UC_IPWM_MODE          0x4U
/* EMIOS_UC_SAIC_MODE : Single Action Input Capture mode */
/* @violates @ref ICU_EMIOS_TYPES_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused macro declarations. */
#define EMIOS_UC_SAIC_MODE          0xBU

#if (ICU_DUAL_CLOCK_MODE_API == STD_ON)
/**
* @brief   Definition of prescaler type for dual clock mode case.
*/
/*< @brief Default channel prescaler. */
#define EMIOS_ICU_NORMAL_CLOCK_MODE     0x0U
/*< @brief Alternate channel prescaler mode */
/** @violates @ref ICU_EMIOS_TYPES_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused macro declarations.*/
#define EMIOS_ICU_ALTERNATE_CLOCK_MODE  0x1U
#endif


/*==================================================================================================
                                             ENUMS
==================================================================================================*/

/*==================================================================================================
                                 STRUCTURES AND OTHER TYPEDEFS
==================================================================================================*/
/**
* @brief          This gives the numeric ID (hardware channel number) of an ICU channel
* @implements Icu_ChannelType_typedef
*/
typedef uint8                           Icu_eMios_ChannelType;

typedef uint32                          Icu_eMios_ControlType;

/**
* @brief    eMIOS_Activation EDGE
* @details  Indicates the channel activation type(Rising, Falling, Both Edges or Opposite Edges).
*/
typedef enum
{
    /* EMIOS_OPPOSITE_EDGES = An appropriate action shall be executed when either a falling or
        rising edge occur on the ICU input signal. */
#ifdef SIGNAL_MEASUREMENT_USES_SAIC_MODE
    EMIOS_OPPOSITE_EDGES    = 0x3U,
#endif   /* SIGNAL_MEASUREMENT_USES_SAIC_MODE */
    /* EMIOS_FALLING_EDGE = An appropriate action shall be executed when a falling edge occurs
        on the ICU input signal. */
    EMIOS_FALLING_EDGE      = 0x0U,
    /* EMIOS_RISING_EDGE = An appropriate action shall be executed when a rising edge occurs on
        the ICU input signal.*/
    EMIOS_RISING_EDGE       = 0x1U,
    /* EMIOS_RISING_EDGE = An appropriate action shall be executed when either a rising or
        falling edge occur on the ICU input signal.*/
    EMIOS_BOTH_EDGES        = 0x2U
} Icu_eMios_ActivationType;

typedef struct
{
    /** @brief Assigned eMios channel id*/
    CONST(Icu_eMios_ChannelType,     ICU_CONST) nHwChannel;
    /** @brief eMios channel parameters */
    CONST(Icu_eMios_ControlType,     ICU_CONST) nControlValue;
    /** @brief eMios Default Start Edge */
    CONST(Icu_eMios_ActivationType,  ICU_CONST) nDefaultStartEdge;
    /** @brief Measurement of ICU signal property without using interrupt */
    CONST(boolean,                   ICU_CONST) bSignalMeasure_WithoutInterrupt;
} Icu_eMios_ChannelConfigType;

/**
* @brief      eTimer IP specific configuration structure type
*/
typedef struct
{
    /** @brief Number of eMios channels in the Icu configuration */
    CONST(Icu_eMios_ChannelType,       ICU_CONST) nNumChannels;
    /** @brief Pointer to the configured channels for eMios */
    CONST(Icu_eMios_ChannelConfigType, ICU_CONST) (*pChannelsConfig)[];
} Icu_eMios_IpConfigType;

/*==================================================================================================
                                 GLOBAL VARIABLE DECLARATIONS
==================================================================================================*/

/*==================================================================================================
                                     FUNCTION PROTOTYPES
==================================================================================================*/

#ifdef __cplusplus
}
#endif

#endif /* ICU_EMIOS_TYPES_H */

/** @} */
