/**
*   @file    Reg_eSys_SSCM.h
*   @version 1.0.0
*
*   @brief   AUTOSAR Mcu - Macros for memory access.
*   @details Macros/Defines used for registry and memory read/write.
*
*   @addtogroup MCU
*   @{
*/
/*==================================================================================================
*   Project              : AUTOSAR 4.3 MCAL
*   Platform             : PA
*   Peripheral           : MC
*   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 REG_ESYS_SSCM_H
#define REG_ESYS_SSCM_H

#ifdef __cplusplus
extern "C"{
#endif

/**
* @page misra_violations MISRA-C:2012 violations
*
* @section Reg_eSys_SSCM_h_REF_1
* Violates MISRA 2012 Advisory Rule 2.5, A project should not contain unused macro declarations.
*
*/

/*==================================================================================================
                                         INCLUDE FILES
 1) system and project includes
 2) needed interfaces from external units
 3) internal and external interfaces from this unit
==================================================================================================*/
#include "Reg_eSys.h"
#include "Mcu_SSCM_IPVersion.h"

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

#define REG_ESYS_SSCM_VENDOR_ID                         43
#define REG_ESYS_SSCM_AR_RELEASE_MAJOR_VERSION          4
#define REG_ESYS_SSCM_AR_RELEASE_MINOR_VERSION          3
#define REG_ESYS_SSCM_AR_RELEASE_REVISION_VERSION       1
#define REG_ESYS_SSCM_SW_MAJOR_VERSION                  1
#define REG_ESYS_SSCM_SW_MINOR_VERSION                  0
#define REG_ESYS_SSCM_SW_PATCH_VERSION                  0


/*==================================================================================================
                                      FILE VERSION CHECKS
==================================================================================================*/
/* Check if current file and Reg_eSys header file are of the same version */
#ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
    #if ((REG_ESYS_SSCM_AR_RELEASE_MAJOR_VERSION != REG_ESYS_AR_RELEASE_MAJOR_VERSION) || \
         (REG_ESYS_SSCM_AR_RELEASE_MINOR_VERSION != REG_ESYS_AR_RELEASE_MINOR_VERSION) \
        )
        #error "AutoSar Version Numbers of Reg_eSys_SSCM.h and Reg_eSys.h are different"
    #endif
#endif

/* Check if source file and Mcu_SSCM_IPVersion header file are from the same vendor */
#if (REG_ESYS_SSCM_VENDOR_ID != MCU_SSCM_IPVERSION_VENDOR_ID)
    #error "Reg_eSys_SSCM.h and Mcu_SSCM_IPVersion.h have different vendor ids"
#endif
/* Check if source file and Mcu_SSCM_IPVersion header file are of the same Autosar version */
#if ((REG_ESYS_SSCM_AR_RELEASE_MAJOR_VERSION != MCU_SSCM_IPVERSION_AR_RELEASE_MAJOR_VERSION) || \
     (REG_ESYS_SSCM_AR_RELEASE_MINOR_VERSION != MCU_SSCM_IPVERSION_AR_RELEASE_MINOR_VERSION) || \
     (REG_ESYS_SSCM_AR_RELEASE_REVISION_VERSION != MCU_SSCM_IPVERSION_AR_RELEASE_REVISION_VERSION) \
    )
    #error "AutoSar Version Numbers of Reg_eSys_SSCM.h and Mcu_SSCM_IPVersion.h are different"
#endif
/* Check if source file and Mcu_SSCM_IPVersion header file are of the same Software version */
#if ((REG_ESYS_SSCM_SW_MAJOR_VERSION != MCU_SSCM_IPVERSION_SW_MAJOR_VERSION) || \
     (REG_ESYS_SSCM_SW_MINOR_VERSION != MCU_SSCM_IPVERSION_SW_MINOR_VERSION) || \
     (REG_ESYS_SSCM_SW_PATCH_VERSION != MCU_SSCM_IPVERSION_SW_PATCH_VERSION) \
    )
    #error "Software Version Numbers of Reg_eSys_SSCM.h and Mcu_SSCM_IPVersion.h are different"
#endif

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


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

#if (IPV_SSCM == IPV_SSCM_06_00_00_06)
#if (CPU_BYTE_ORDER == LOW_BYTE_FIRST)    
    /* SSCM System Status (SSCM_STATUS) */
    #define SSCM_STATUS_ADDR16                  ((uint32)(SSCM_BASEADDR + (uint32)0x0002UL))
    /* SSCM System Memory and ID Register (SSCM_MEMCONFIG) */
    #define SSCM_MEMCONFIG_ADDR16               ((uint32)(SSCM_BASEADDR + (uint32)0x0000UL))
#else
    /* SSCM System Status (SSCM_STATUS) */
    #define SSCM_STATUS_ADDR16                  ((uint32)(SSCM_BASEADDR + (uint32)0x0000UL))
    /* SSCM System Memory and ID Register (SSCM_MEMCONFIG) */
    #define SSCM_MEMCONFIG_ADDR16               ((uint32)(SSCM_BASEADDR + (uint32)0x0002UL))
#endif
#else
    /* SSCM System Status (SSCM_STATUS) */
    #define SSCM_STATUS_ADDR16                  ((uint32)(SSCM_BASEADDR + (uint32)0x0000UL))
    /* SSCM System Memory and ID Register (SSCM_MEMCONFIG) */
#if ((MCU_GET_SYSTEM_STATE_API == STD_ON) || (MCU_GET_MEM_CONFIG_API == STD_ON))
    #define SSCM_MEMCONFIG_ADDR16               ((uint32)(SSCM_BASEADDR + (uint32)0x0002UL))
#endif
#endif


/* SSCM Error Configuration Register (SSCM_ERROR) */
#define SSCM_ERROR_ADDR16                   ((uint32)(SSCM_BASEADDR + (uint32)0x0006UL))

#ifdef MCU_SSCM_GET_UOPS_API
#if (MCU_SSCM_GET_UOPS_API == STD_ON)
#if ((IPV_SSCM == IPV_SSCM_05_03_00_00) || (IPV_SSCM == IPV_SSCM_06_00_00_06) ||  \
     (IPV_SSCM == IPV_SSCM_06_00_00_04) || (IPV_SSCM == IPV_SSCM_04_01_17_00))
    /* User Option Status Register (SSCM_UOPS) */
    #define SSCM_UOPS_ADDR32                ((uint32)(SSCM_BASEADDR + (uint32)0x0020UL))
#endif
#endif /* MCU_SSCM_GET_UOPS_API == STD_ON */
#endif /* MCU_SSCM_GET_UOPS_API */

#if (defined(MCU_DISABLE_SSCM_INIT) && (STD_OFF == MCU_DISABLE_SSCM_INIT))
/* SSCM System Status (SSCM_STATUS) bit masks */
#if (IPV_SSCM == IPV_SSCM_06_00_00_01)
    #define SSCM_STATUS_RWBITS_MASK16       ((uint16)0x6000U)
    #define SSCM_STATUS_RESBITS_MASK16      ((uint16)0x0400U)

#elif (IPV_SSCM == IPV_SSCM_05_03_00_00)
    #define SSCM_STATUS_RESBITS_MASK16      ((uint16)0x0400U)

#elif (IPV_SSCM == IPV_SSCM_05_04_00_00)
    #define SSCM_STATUS_RWBITS_MASK16       ((uint16)0x6000U)
    #define SSCM_STATUS_RESBITS_MASK16      ((uint16)0x0010U)

#elif (IPV_SSCM == IPV_SSCM_06_00_00_06)
    #define SSCM_STATUS_RWBITS_MASK16       ((uint16)0x4000U)
    #define SSCM_STATUS_RESBITS_MASK16      ((uint16)0x0410U)

#elif (IPV_SSCM == IPV_SSCM_06_00_00_04)
    #define SSCM_STATUS_RWBITS_MASK16       ((uint16)0x6000U)
    #define SSCM_STATUS_RESBITS_MASK16      ((uint16)0x0410U)

#elif (IPV_SSCM == IPV_SSCM_04_01_17_00)
    #define SSCM_STATUS_RWBITS_MASK16       ((uint16)0x6000U)
    #define SSCM_STATUS_RESBITS_MASK16      ((uint16)0x0000U)
#endif
#endif /* #if (defined(MCU_DISABLE_SSCM_INIT) && (STD_OFF == MCU_DISABLE_SSCM_INIT)) */

/* Configuration Error */
#define SSCM_STATUS_CER_MASK16              ((uint16)0x4000U)

/* Configuration Error for Safe DCF Clients */
#if ((IPV_SSCM == IPV_SSCM_06_00_00_01) || (IPV_SSCM == IPV_SSCM_05_04_00_00) || \
     (IPV_SSCM == IPV_SSCM_06_00_00_04) || (IPV_SSCM == IPV_SSCM_04_01_17_00))
    #define SSCM_STATUS_CERS_MASK16         ((uint16)0x2000U)
#endif

/* Public Serial Access Status, Security Status */
#if ((IPV_SSCM == IPV_SSCM_05_04_00_00) || (IPV_SSCM == IPV_SSCM_04_01_17_00))
    #define SSCM_STATUS_PUB_MASK16          ((uint16)0x0400U)
    #define SSCM_STATUS_SEC_MASK16          ((uint16)0x0200U)
#endif

/* Variable Length Instruction Mode. */
#if ((IPV_SSCM == IPV_SSCM_06_00_00_01) || (IPV_SSCM == IPV_SSCM_04_01_17_00))
    #define SSCM_STATUS_VLE_MASK16          ((uint16)0x0010U)
#endif

#if ((IPV_SSCM == IPV_SSCM_06_00_00_01) || (IPV_SSCM == IPV_SSCM_06_00_00_06))
    #define SSCM_MEMCONFIG_RESBITS_MASK16   ((uint16)0x0020U)
#elif ((IPV_SSCM == IPV_SSCM_05_04_00_00) || (IPV_SSCM == IPV_SSCM_04_01_17_00))
    #define SSCM_MEMCONFIG_RESBITS_MASK16   ((uint16)0x0000U)
#endif

#if (IPV_SSCM == IPV_SSCM_05_04_00_00)
    #define SSCM_MEMCONFIG_IVLD_MASK16      ((uint16)0x0020U)

#elif (IPV_SSCM == IPV_SSCM_04_01_17_00)
    #define SSCM_MEMCONFIG_IVLD_MASK16      ((uint16)0x0020U)
    #define SSCM_MEMCONFIG_DVLD_MASK16      ((uint16)0x0001U)
#endif

/* SSCM Error Configuration Register (SSCM_ERROR) */
#define SSCM_ERROR_RWBITS_MASK16            ((uint16)0x0003U)

#define SSCM_ERROR_RESBITS_MASK16           ((uint16)0x0000U)
/** @violates @ref Reg_eSys_SSCM_h_REF_1 This violation is due to macros reserved for future use.*/
#define SSCM_ERROR_PAE_MASK16               ((uint16)0x0002U)

/* User Option Status Register (SSCM_UOPS) */
#if (IPV_SSCM == IPV_SSCM_06_00_00_06)
    #define SSCM_UOPS_SBE_MASK32            ((uint32)0x00000010U)
    #define SSCM_UOPS_CSE_BC_MASK32         ((uint32)0x0000000EU)
    #define SSCM_UOPS_CEN_MASK32            ((uint32)0x00000001U)
#elif (IPV_SSCM == IPV_SSCM_04_01_17_00)
    #define SSCM_UOPS_UOPT_MASK32           ((uint32)0xFFFFFFFFU)
#endif

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


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


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


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


#ifdef __cplusplus
}
#endif

#endif /* REG_ESYS_SSCM_H */

/** @} */
