[!CODE!][!//
/**
*   @file    Dio_Cfg.c
*   @implements    Dio_Cfg.c_artifact
*   @version 1.0.0
*
*   @brief   AUTOSAR Dio precompile configuration code.
*   @details This file is the Autosar DIO driver precompile configuration
*            code. This file is automatically generated, do not modify manually.
*
*   @addtogroup DIO_CFG
*   @{
*/
/*=================================================================================================
*   Project              : AUTOSAR 4.3 MCAL
*   Platform             : PA
*   Peripheral           : 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.
=================================================================================================*/
/*=================================================================================================
=================================================================================================*/


#ifdef __cplusplus
extern "C" {
#endif

/**
* @page misra_violations MISRA-C:2012 violations
*
* @section Dio_CFG_C_REF_1
*          Violates MISRA 2012 Required Directive 4.10, Precautions shall be taken in order to prevent the contents of a header file being included more than once.
*          This violation is not fixed since the inclusion of Dio_MemMap.h is as per AUTOSAR requirement [SWS_MemMap_00003].
*
* @section Dio_CFG_C_REF_2
*          Violates MISRA 2012 Advisory Rule 20.1, #include directives should only be preceded by preprocessor directives or comments.
*          Dio_MemMap.h is included after each section define in order to set the current memory section as defined by AUTOSAR
*
* @section Dio_CFG_C_REF_3
*          Violates MISRA 2012 Required Rule 8.4, A compatible declaration shall be visible when an object or function with external linkage is defined.
*          This define to make sure that it cannot export the Dio_Config structure and make it visible to the upper layer.
*
* @section Dio_CFG_C_REF_4
*          Violates MISRA 2012 Advisory Rule 8.7, Functions and objects should not be defined with external linkage if they are referenced in only one translation unit.
*          These functions represent the API of the driver. External linkage is needed to "export" the API.
*
* @section Dio_CFG_C_REF_5
*          Violates MISRA 2012 Advisory Rule 8.9, An object should be defined at block scope if its identifier only appears in a single function.
*          This violation is due to exporting the externally configured initialization structure used by the "Dio_Init" function.
*
* @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, An identifier declared in an inner scope shall not hide an identifier declared in an outer scope.
*          The used compilers use more than 31 chars for identifiers.
*
* @section [global]
*          Violates MISRA 2012 Required Rule 5.5, Macro identifiers shall be distinct.
*          The used compilers use more than 31 chars for identifiers.
*
*/

/*=================================================================================================
*                                        INCLUDE FILES
* 1) system and project includes
* 2) needed interfaces from external units
* 3) internal and external interfaces from this unit
=================================================================================================*/

#include "Dio.h"
[!NOCODE!][!//
[!INCLUDE "Dio_VersionCheck_Src.m"!][!//
[!ENDNOCODE!][!//

#if defined(DIO_PRECOMPILE_SUPPORT)
/*=================================================================================================
*                              SOURCE FILE VERSION INFORMATION
=================================================================================================*/

#define DIO_VENDOR_ID_CFG_C                   43
#define DIO_AR_RELEASE_MAJOR_VERSION_CFG_C    4
#define DIO_AR_RELEASE_MINOR_VERSION_CFG_C    3
#define DIO_AR_RELEASE_REVISION_VERSION_CFG_C 1
#define DIO_SW_MAJOR_VERSION_CFG_C            1
#define DIO_SW_MINOR_VERSION_CFG_C            0
#define DIO_SW_PATCH_VERSION_CFG_C            0

/*=================================================================================================
*                                     FILE VERSION CHECKS
=================================================================================================*/


#if (((DIO_AR_RELEASE_MAJOR_VERSION_CFG_C != DIO_AR_RELEASE_MAJOR_VERSION)  ||  \
      (DIO_AR_RELEASE_MINOR_VERSION_CFG_C != DIO_AR_RELEASE_MINOR_VERSION)) ||  \
      (DIO_AR_RELEASE_REVISION_VERSION_CFG_C != DIO_AR_RELEASE_REVISION_VERSION)\
    )
      #error "AutoSar Version Numbers of Dio_Cfg.c and Dio.h are different"
#endif
#if ((DIO_SW_MAJOR_VERSION_CFG_C != DIO_SW_MAJOR_VERSION) || \
     (DIO_SW_MINOR_VERSION_CFG_C != DIO_SW_MINOR_VERSION) || \
     (DIO_SW_PATCH_VERSION_CFG_C != DIO_SW_PATCH_VERSION)    \
    )
      #error "Software Version Numbers of Dio_Cfg.c and Dio.h are different"
#endif
#if ((DIO_VENDOR_ID_CFG_C != DIO_VENDOR_ID))
    #error "VENDOR ID for Dio_Cfg.c and Dio.h is different"
#endif

/*=================================================================================================
*                          LOCAL TYPEDEFS (STRUCTURES, UNIONS, ENUMS)
=================================================================================================*/


/*=================================================================================================
*                                       LOCAL MACROS
=================================================================================================*/


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


/*=================================================================================================
*                                      LOCAL VARIABLES
=================================================================================================*/


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

#define DIO_START_SEC_CONFIG_DATA_UNSPECIFIED
/** @violates @ref Dio_CFG_C_REF_1 Precautions shall be taken in order to prevent the contents of a header file being included more than once. */
#include "Dio_MemMap.h"

/**
* @brief          Platform implemented port pins representation.
* @details        Array of bit maps reflecting the available pins in each port.
*                 The number of elements in the array corresponds to the number of
*                 ports implemented in the platform package. Leftmost bit of each
*                 array element corresponds to channel 0 of the associated port,
*                 while rightmost bit of each array element corresponds to channel 15
*                 of the associated port. A 0 bit means that the correspondent channel
*                 is not available in the platform package, while a bit of 1 means 
*                 that the correspondent channel is available in the platform package.
*
* @api
*/
[!VAR "NumPorts"="count(ecu:list('Dio.AvailablePortPinsForWrite'))"!][!//
CONST(Dio_PortLevelType, DIO_CONST) Dio_aAvailablePinsForWrite[DIO_NUM_PORTS_U16] = 
{
[!FOR "Loop" = "1" TO "$NumPorts"!][!//
   (Dio_PortLevelType)[!"ecu:list('Dio.AvailablePortPinsForWrite')[num:dectoint($Loop)]"!][!//
[!IF "$Loop < $NumPorts "!],[!ENDIF!]
[!ENDFOR!][!//
};

[!VAR "NumPorts"="count(ecu:list('Dio.AvailablePortPinsForRead'))"!][!//
/** @violates @ref Dio_CFG_C_REF_5 An object should be defined at block scope if its identifier only appears in a single function. */
CONST(Dio_PortLevelType, DIO_CONST) Dio_aAvailablePinsForRead[DIO_NUM_PORTS_U16] = 
{
[!FOR "Loop" = "1" TO "$NumPorts"!][!//
   (Dio_PortLevelType)[!"ecu:list('Dio.AvailablePortPinsForRead')[num:dectoint($Loop)]"!][!//
[!IF "$Loop < $NumPorts "!],[!ENDIF!]
[!ENDFOR!][!//
};

[!//
[!MACRO "reverse_bits"!][!//
[!NOCODE!]
    [!VAR "Orig_mask"="DioPortMask"!]
    [!VAR "Orig_offset"="DioPortOffset"!]
    [!IF "../../../../../DioGeneral/DioReversePortBits"!]
        [!VAR "Reversed_mask"="0"!]
        [!VAR "Found_1"="0"!]
        [!FOR "Loop" = "0" TO "15"!]
            [!VAR "crt_bit" = "bit:shr($Orig_mask,$Loop)"!]
            [!VAR "crt_bit"="bit:and($crt_bit, 1)"!]
            [!VAR "Reversed_mask"="bit:or($Reversed_mask,$crt_bit)"!]
            [!IF "$Loop != 15"!][!//
                [!VAR "Reversed_mask"="bit:shl($Reversed_mask, 1)"!]
            [!ENDIF!]
            [!IF "$Found_1=1 and $crt_bit=0"!]
                [!VAR "right_bits"="$Loop"!]
                [!VAR "Found_1"="0"!]
            [!ENDIF!]
            [!IF "$crt_bit = 1"!]
                [!VAR "Found_1"="1"!]
            [!ENDIF!][!//
        [!ENDFOR!]
    [!ELSE!]
        [!VAR "Reversed_mask"="DioPortMask"!]
    [!ENDIF!]
    [!VAR "Reversed_offset"="DioPortOffset"!]
[!ENDNOCODE!][!//
(uint8)[!"num:inttohex($Reversed_offset,2)"!], (Dio_PortLevelType)[!"num:inttohex($Reversed_mask,4)"!]U}[!//
[!ENDMACRO!][!//

[!SELECT "DioConfig"!][!//
/* ========== [!"as:name(.)"!] ========== */

[!VAR "numChannelGroupsInConfig" = "count(DioPort/*/DioChannelGroup/*)"!][!//

/**
* @brief          Data structure for configuration [!"as:name(.)"!].
*/
/** @violates @ref Dio_CFG_C_REF_3 A compatible declaration shall be visible when an object or function with external linkage is defined. */
/** @violates @ref Dio_CFG_C_REF_4 Functions and objects should not be defined with external linkage if they are referenced in only one translation unit. */
CONST(Dio_ConfigType, DIO_CONST) [!"as:name(.)"!] =
{
    (uint8)[!"num:inttohex($numChannelGroupsInConfig)"!],
[!IF "$numChannelGroupsInConfig != 0"!][!//
    &[!"as:name(.)"!]_aChannelGroupList[0]
[!ELSE!][!//
    NULL_PTR
[!ENDIF!][!//
};
[!VAR "numChannelGroupsInConfig" = "count(DioPort/*/DioChannelGroup/*)"!][!//
[!IF "$numChannelGroupsInConfig != 0"!][!//
/**
* @brief          List of channel groups in configuration [!"as:name(.)"!].
*/
CONST(Dio_ChannelGroupType, DIO_CONST) [!"as:name(.)"!]_aChannelGroupList[[!"num:dectoint($numChannelGroupsInConfig)"!]] =
{
[!VAR "i" = "0"!][!//
[!LOOP "DioPort/*"!][!//
[!LOOP "DioChannelGroup/*"!][!//
    {DioConf_DioPort_[!"node:name(./../..)"!], [!CALL "reverse_bits"!][!//
[!VAR "i"="$i+1"!][!//
[!IF "$i != $numChannelGroupsInConfig"!],[!ENDIF!]
[!ENDLOOP!][!//
[!ENDLOOP!][!//
};
[!ENDIF!]
[!ENDSELECT!][!//

#define DIO_STOP_SEC_CONFIG_DATA_UNSPECIFIED
/** @violates @ref Dio_CFG_C_REF_1 Precautions shall be taken in order to prevent the contents of a header file being included more than once. */
/** @violates @ref Dio_CFG_C_REF_2 #include directives should only be preceded by preprocessor directives or comments. */
#include "Dio_MemMap.h"

/*=================================================================================================
*                                      GLOBAL VARIABLES
=================================================================================================*/


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


/*=================================================================================================
*                                       LOCAL FUNCTIONS
=================================================================================================*/


/*=================================================================================================
*                                       GLOBAL FUNCTIONS
=================================================================================================*/


#endif /* defined(DIO_PRECOMPILE_SUPPORT) */

#ifdef __cplusplus
}
#endif

/** @} */
[!ENDCODE!][!//
