/**
*   @file    Mcem_Fccu_Types.h
*   @implements     Mcem_Fccu_Types.h_Artifact
*
*   @version 1.0.0
*
*   @brief   AUTOSAR Mcem - FCCUv2 IP Types 
*   @details Internal types used in the FCCUv2 IP layer of the MCEM module.
*
*   @addtogroup MCEM_MODULE
*   @{
*/
/*==================================================================================================
*   Project              : AUTOSAR 4.3 MCAL
*   Platform             : PA
*   Peripheral           : Fccu
*   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 MCEM_FCCU_TYPES_H
#define MCEM_FCCU_TYPES_H

#ifdef __cplusplus
extern "C"{
#endif

/**
 * @page misra_violations MISRA-C:2004 violations
 *
 * @section [global]
 * Violates MISRA 2004 Required Rule 5.1, Exceeds 31 characters due to AUTOSAR compatibility
 *
 * @section Mcem_Fccu_Types_h_REF_1
 * Violates MISRA 2004 Advisory Rule 19.7, Function-like macro defined.
 * This violation is due to use of range checking macros as functions.
 *
 */



/*==================================================================================================
*                                        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"

/*==================================================================================================
*                              SOURCE FILE VERSION INFORMATION
==================================================================================================*/

#define FCCU_TYPES_VENDOR_ID                    43
#define FCCU_TYPES_MODULE_ID                    0
#define FCCU_TYPES_AR_RELEASE_MAJOR_VERSION     4
#define FCCU_TYPES_AR_RELEASE_MINOR_VERSION     3
#define FCCU_TYPES_AR_RELEASE_REVISION_VERSION  1
#define FCCU_TYPES_SW_MAJOR_VERSION             1
#define FCCU_TYPES_SW_MINOR_VERSION             0
#define FCCU_TYPES_SW_PATCH_VERSION             0

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

/*==================================================================================================
*                                          CONSTANTS
==================================================================================================*/

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

/* FCCU configuration bit positions/values */
/* FCCU Recovery type */
#define MCEM_FCCU_RECOVERY_HW                        (0UL)
#define MCEM_FCCU_RECOVERY_SW                        (1UL)

/* FCCU Reset Reaction */
#define MCEM_FCCU_REACTION_NORESETREACTION           (0UL)
#define MCEM_FCCU_REACTION_SHORTRESETREACTION        (1UL)
#define MCEM_FCCU_REACTION_LONGRESETREACTION         (2UL)

/* FCCU EOUT state after reset */
#define MCEM_FCCU_CFG_EOUT_AFTER_RESET               24U

/* FCCU Output protocol position, values, and polarity (TESTx modes are not supported at this time) */
#define MCEM_FCCU_CFG_EOUT                           6U
#define MCEM_FCCU_CFG_EOUT_DUALRAIL                  (0UL << MCEM_FCCU_CFG_EOUT)
#define MCEM_FCCU_CFG_EOUT_TIMESWITCHING             (1UL << MCEM_FCCU_CFG_EOUT)
#define MCEM_FCCU_CFG_EOUT_BISTABLE                  (2UL << MCEM_FCCU_CFG_EOUT)
#define MCEM_FCCU_CFG_EOUT_TEST0                     (4UL << MCEM_FCCU_CFG_EOUT)
#define MCEM_FCCU_CFG_EOUT_TEST1                     (5UL << MCEM_FCCU_CFG_EOUT)
#define MCEM_FCCU_CFG_EOUT_TEST2                     (6UL << MCEM_FCCU_CFG_EOUT)
#define MCEM_FCCU_CFG_POLARITY                       9U
#define MCEM_FCCU_CFG_POLARITY_E1LE0H                (1UL)
#define MCEM_FCCU_CFG_POLARITY_E1HE0L                (0UL)

/* FCCU EOUT switching speed */
#define MCEM_FCCU_CFG_FAST_SWITCHING_MODE            10U

/* FCCU EOUT open-drain selection */
#define MCEM_FCCU_CFG_OPEN_DRAIN                     12U

/* FCCU alarm IRQ */
#define MCEM_FCCU_CFG_IRQ_EN                         0U

/* FCCU config FOPE and FOP */
#define MCEM_FCCU_CFG_FOPE                           15U
/* @violates @ref Mcem_Fccu_Types_h_REF_1 Function-like macro defined */
#define MCEM_FCCU_CFG_FOP(value)                     ((uint32)(value))

/* FCCU CTRL Glitch Filter bitfields positions */
#define MCEM_FCCU_CTRL_GLITCH_FILTER_BYPASS          31U
#define MCEM_FCCU_CTRL_GLITCH_FILTER_WIDTH           29U

/* FCCU CTRL Glitch Filter width possible values */
#define MCEM_FCCU_FILTER_GLITCH_UP_TO_50_US         (0UL << MCEM_FCCU_CTRL_GLITCH_FILTER_WIDTH)
#define MCEM_FCCU_FILTER_GLITCH_UP_TO_75_US         (1UL << MCEM_FCCU_CTRL_GLITCH_FILTER_WIDTH)
#define MCEM_FCCU_FILTER_GLITCH_UP_TO_100_US        (2UL << MCEM_FCCU_CTRL_GLITCH_FILTER_WIDTH)


/* Number of FCCU fault registers */
#define FCCU_FAULT_REGISTER_COUNT                    2U
#define FCCU_FAULT_STATE_REGISTER_COUNT              3U

/* Width of FCCU registers (bits), and corresponding shift and mask */
#define FCCU_REG_SIZE_U8          32U
#define FCCU_REG_SIZE_BYTE_U8     4U
#define FCCU_REG_SHIFT_U8         5U
#if ((1UL << FCCU_REG_SHIFT_U8)) != FCCU_REG_SIZE_U8
    #error "FCCU_REG_SIZE_U8 and FCCU_REG_SHIFT_U8 do not correspond."
#endif
#define FCCU_REG_MASK_U8          (FCCU_REG_SIZE_U8-1U)

/* Frozen ALARM transition status fault index offset */
#define FCCU_FAULT_INDEX_U8                         1U
/* Frozen ALARM transition status: multiple faults */
#define FCCU_FAULT_MULTIPLE_U8                      0xFFU
/* Frozen ALARM transition status: no transition recorded */
#define FCCU_FAULT_NONE_U8                          0U


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

/**
* @brief          Fault Status type
* @details        A Fccu Fault status
*/
typedef enum
{
    FCCU_FAULT_NOT_AVAILABLE          = 0x00,
    FCCU_FAULT_NOT_ASSERTED           = 0x55,
    FCCU_FAULT_ASSERTED               = 0xAA
} Fccu_FaultStatusType;
/**
* @brief          The type of FaultID.
*
*/
typedef uint8 Mcem_FaultType;

/*==================================================================================================
*                                STRUCTURES AND OTHER TYPEDEFS
==================================================================================================*/

/**
* @brief          FCCU configuration struct type
* @details        Configuration values of individual FCCU configuration registers.
*/
typedef struct
{
  uint32  Ctrl_Glitch_Filter;   /**< @brief Content of Glitch Filter related bitfields in CTRL register */
  uint32  Fault_Config;         /**< @brief Configuration Register */
  uint32  Fault_Ncf_TO;         /**< @brief Non Critical Fault Recovery Timeout Register */
  uint32  Fault_Cfg_TO;         /**< @brief Mcem Configuration timeout Register */
  uint32  Fault_DeltaT;         /**< @brief EOUT delta T signal duration Register */
  uint32  Fault_Irq_EN;         /**< @brief Configuration Timeout Enable Register */

  uint32  Fault_Ncf_E[FCCU_FAULT_REGISTER_COUNT];         /**< @brief NCF Enable Register 0 */
  uint32  Fault_Ncf_Cfg[FCCU_FAULT_REGISTER_COUNT];       /**< @brief NCF Cfg Register 0 */
  uint32  Fault_Alarm_EN[FCCU_FAULT_REGISTER_COUNT];      /**< @brief NCF Alarm Interrupt Enable Register 0 */
  uint32  Fault_Nmi_EN[FCCU_FAULT_REGISTER_COUNT];        /**< @brief NCF NMI Enable Register 0 */
  uint32  Fault_Ncf_TOE[FCCU_FAULT_REGISTER_COUNT];       /**< @brief NCF Recovery Timeout Enable Register 0 */
  uint32  Fault_EoutSig_EN[FCCU_FAULT_REGISTER_COUNT];    /**< @brief NCF Eout Sinaling Enable Register 0 */
  
  uint32  Fault_Ncfs_Cfg[FCCU_FAULT_STATE_REGISTER_COUNT];     /**< @brief NCF Reaction Type Register 0 */
  
} Fccu_ConfigType;


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

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

#ifdef __cplusplus
}
#endif

#endif /*MCEM_FCCU_TYPES_H*/

/** @} */
