/**
*   @file    Adc_CfgDefines.h
*   @version 1.0.0
*
*   @brief   AUTOSAR Adc - Module configuration interface for Adc driver.
*   @details Contains the module configuration interface for Adc driver.
*
*   @addtogroup ADC
*   @{
*/
/*==================================================================================================
*   Project              : AUTOSAR 4.3 MCAL
*   Platform             : PA
*   Peripheral           : EQADC
*   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 ADC_CFG_DEFINES_H
#define ADC_CFG_DEFINES_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.
*
*/

/*==================================================================================================
*                                        INCLUDE FILES
* 1) system and project includes
* 2) needed interfaces from external units
* 3) internal and external interfaces from this unit
==================================================================================================*/
[!NOCODE!][!//
[!INCLUDE "Adc_VersionCheck_Inc.m"!][!//
[!ENDNOCODE!][!//
[!NOCODE!][!//
[!INCLUDE "Adc_RegOperations.m"!][!//
[!ENDNOCODE!][!//

/*==================================================================================================
*                              SOURCE FILE VERSION INFORMATION
==================================================================================================*/
#define ADC_VENDOR_ID_CFG_DEFINES                       43
#define ADC_AR_RELEASE_MAJOR_VERSION_CFG_DEFINES        4
#define ADC_AR_RELEASE_MINOR_VERSION_CFG_DEFINES        3
#define ADC_AR_RELEASE_REVISION_VERSION_CFG_DEFINES     1
#define ADC_SW_MAJOR_VERSION_CFG_DEFINES                1
#define ADC_SW_MINOR_VERSION_CFG_DEFINES                0
#define ADC_SW_PATCH_VERSION_CFG_DEFINES                0

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


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


/*==================================================================================================
*                                      DEFINES AND MACROS
==================================================================================================*/
[!FOR "x" = "0" TO "ecu:get('Adc.AdcConfigSet.AdcHwUnit')-1"!][!//
/**
* @brief          ADC unit [!"$x"!] available
*/
#define ADC_UNIT_[!"$x"!]  [!"$x"!]U

[!ENDFOR!][!//

/**
* @brief          MHT functionality not activated.
*/
#define ADC_MULTIPLE_HARDWARE_TRIGGERS      (STD_OFF)

/** 
* @brief           Adds/removes ((STD_ON)/(STD_OFF)) the services Adc_EnableHardwareTrigger() and Adc_DisableHardwareTrigger() from the code.
*/
#define ADC_HW_TRIGGER_API                  [!IF "AdcGeneral/AdcHwTriggerApi"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

/** 
* @brief           Set mode api enabled/disabled ((STD_ON)/(STD_OFF)).
*/
#define ADC_SET_MODE_API                    (STD_OFF)

/** 
* @brief           Enables or disables limit checking feature in the ADC driver.
*/
#define ADC_ENABLE_LIMIT_CHECK              [!IF "AdcGeneral/AdcEnableLimitCheck"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

/** 
* @brief           Group notification mechanism is/isn't ((STD_ON)/(STD_OFF)) available at runtime.
*/
#define ADC_GRP_NOTIF_CAPABILITY            [!IF "AdcGeneral/AdcGrpNotifCapability"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

/** 
* @brief           Type of prioritization mechanism ADC_PRIORITY_HW, ADC_PRIORITY_HW_SW and ADC_PRIORITY_NONE.
*/
#define ADC_PRIORITY_HW                     0U
#define ADC_PRIORITY_HW_SW                  1U
#define ADC_PRIORITY_NONE                   2U

/** 
* @brief           Priority implementation.
*/
#define ADC_PRIORITY_IMPLEMENTATION         ([!"AdcGeneral/AdcPriorityImplementation"!])

/** 
* @brief           Type of alignment mechanism ADC_ALIGN_RIGHT, ADC_ALIGN_LEFT.
*/
#define ADC_ALIGN_RIGHT                     0U
#define ADC_ALIGN_LEFT                      1U

/** 
* @brief           Result Alignment.
*/
#define ADC_RESULT_ALIGNMENT                ([!"AdcGeneral/AdcResultAlignment"!])

/** 
* @brief           Adc transfer type.
*/
#define ADC_DMA                             0U
#define ADC_INTERRUPT                       1U

/** 
* @brief         This is a timeout value which is used to wait till
*                  - the conversion is not aborted.
*                  - ADC hardware is not entered in power down state.
*                  - ADC hardware is not entered in idle state.
*/
#define ADC_TIMEOUT_COUNTER                 ([!"num:inttohex(AdcGeneral/AdcTimeout,8)"!]UL)

/** 
* @brief          Add/Remove One time setting of Conversion time resisters from Init() function.
*/
#define ADC_SET_ADC_CONV_TIME_ONCE          (STD_OFF)

/** 
* @brief          CMR Register is not supported by hardware
*/
#define ADC_CMR_REGISTER_NOT_SUPPORTED

/**
* @brief           This is a timeout value which is used to wait till the
*                  conversions pending in the CBuffer are not completed.
*/
#define ADC_CFG_CONV_TIMEOUT                 ([!"num:inttohex(AdcGeneral/AdcConvTimeout)"!]UL)

[!NOCODE!][!//
[!VAR "DMA_ENABLED"="0"!][!//
[!LOOP "AdcConfigSet/AdcHwUnit/*"!][!//
[!IF "AdcTransferType = 'ADC_DMA'"!][!//
[!VAR "DMA_ENABLED"="1"!][!//
[!ENDIF!][!//
[!ENDLOOP!][!//
[!ENDNOCODE!][!//
[!IF "$DMA_ENABLED = 1"!][!//
/** 
* @brief           Active DMA.
*/
#define ADC_DMA_SUPPORTED
[!ENDIF!][!//

/** 
* @brief           Max number of hw units - is 4 on Cobra.
*/
#define ADC_MAX_HW_UNITS                          ([!"num:i(ecu:get('Adc.AdcConfigSet.AdcHwUnit'))"!]U)

/**
 * @brief   Define the number of maximum channels
 */
/* #define ADC_MAXIMUM_HW_CHANNELS                   (255U) */

/** 
* @brief           Add/Remove Autosar Extension Adc_EnableChannel() and Adc_DisableChannel() api.
*/
#define ADC_ENABLE_CH_DISABLE_CH_NONAUTO_API      (STD_OFF)

/** 
* @brief           Get injected conversion status api enabled/disabled (STD_ON/STD_OFF).
*/
#define ADC_GET_INJECTED_CONVERSION_STATUS_API    (STD_OFF)

/** 
* @brief          Add/remove ((STD_ON)/(STD_OFF)) the service Adc_SetChannel() from the code.
*/
#define ADC_SETCHANNEL_API                        (STD_OFF)

/** 
* @brief          Add/Remove Autosar Extension Adc_SetClockMode().
*/
#define ADC_DUAL_CLOCK_MODE   [!IF "AutosarExt/AdcEnableDualClockMode"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

/** 
* @brief           Specifies for reducing the number of interrupts for streaming groups
*/
#define ADC_ENABLE_DOUBLE_BUFFERING  [!IF "AutosarExt/AdcEnableDoubleBufferingOptimization"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]
/**
* @brief           Specifies to optimize conversions for hw triggered, one shot group.
*/
#define ADC_OPTIMIZE_ONESHOT_HW_TRIGGER      [!IF "AutosarExt/AdcOptimizeOneShotHwTriggerConversions"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

/**
 * @brief           Add/Remove Autosar Extension Adc_ConfigureThreshold() api.
 */
#define ADC_ENABLE_CONFIGURE_THRESHOLD_NONAUTO_API      (STD_OFF)

/** 
* @brief          Add/remove ((STD_ON)/(STD_OFF)) the service Adc_Calibration() from the code.
*/
#define ADC_CALIBRATION         [!IF "AutosarExt/AdcEnableCalibration"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

/** 
* @brief          Add/remove ((STD_ON)/(STD_OFF)) the service Adc_SelfTest() from the code.
*/
#define ADC_SELF_TEST           (STD_OFF)

/**
* @brief  Switch to enable/disable the API for the PR-MCAL-3312, PR-MCAL-3313, PR-MCAL-3314, PR-MCAL-3315 and PR-MCAL-3316.
*/
#define CTUV2_ENABLE_TRIGGER_CONFIGURATION_APIS     (STD_OFF)

/** 
* @brief  Switch to enable/disable the API for the CPR-MCAL-726, CPR-MCAL-727, CPR-MCAL-728.
*/
#define ADC_ENABLE_CTU_CONTROL_MODE_API                 (STD_OFF)

[!NOCODE!][!//
[!VAR "AdcDisableDemReport" = "0"!]
[!IF "node:exists(AdcDemEventParameterRefs)"!]
  [!IF "AutosarExt/AdcDisableDemReportErrorStatus = 'true'"!]
    [!VAR "AdcDisableDemReport" = "1"!]
  [!ENDIF!]
[!ELSE!]
  [!VAR "AdcDisableDemReport" = "1"!]
[!ENDIF!]
[!ENDNOCODE!][!//
/** 
* @brief  Switch to enable/disable the production error reporting.
*/
#define ADC_DISABLE_DEM_REPORT_ERROR_STATUS           [!IF "$AdcDisableDemReport = 1"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

#define ADC_USER_MODE_REG_PROT_ENABLED      (STD_OFF)

[!IF "(IMPLEMENTATION_CONFIG_VARIANT !='VariantPostBuild' and (variant:size()<=1))"!][!//
/**
* @brief          Configuration Precompile variant.
* @details        Configuration Precompile variant.
*/
#define ADC_PRECOMPILE_SUPPORT
[!ENDIF!][!//
   
/** 
* @brief          Development error detection enabled/disabled ((STD_ON)/(STD_OFF)).
*/
#define ADC_DEV_ERROR_DETECT                [!IF "AdcGeneral/AdcDevErrorDetect"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

/** 
* @brief          Add/remove ((STD_ON)/(STD_OFF)) the service Adc_GetVersionInfo() from the code.
*/
#define ADC_VERSION_INFO_API                [!IF "AdcGeneral/AdcVersionInfoApi"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

/** 
* @brief          Add/remove ((STD_ON)/(STD_OFF)) the service Adc_DeInit() from the code.
*/
#define ADC_DEINIT_API                      [!IF "AdcGeneral/AdcDeInitApi"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

/** 
* @brief          Add/remove ((STD_ON)/(STD_OFF)) the services Adc_StartGroupConversion()and Adc_StopGroupConversion() from the code.
*/
#define ADC_ENABLE_START_STOP_GROUP_API     [!IF "AdcGeneral/AdcEnableStartStopGroupApi"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

/** 
* @brief          Add/Remove the services Adc_ReadGroup() from the code.
*/
#define ADC_READ_GROUP_API                  [!IF "AdcGeneral/AdcReadGroupApi"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

/** 
* @brief          This switch is used to enable the hardware trigger Autosar Extension API.
*/
#define ADC_ENABLE_CTUTRIG_NONAUTO_API       (STD_OFF)

/**
* @brief   Switch to enable that power state mode is supported
*
*/
#define ADC_POWER_STATE_SUPPORTED            [!IF "node:exists(AdcGeneral/AdcLowPowerStatesSupport) and (AdcGeneral/AdcLowPowerStatesSupport = 'true')"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

/**
* @brief   Enable/Disable the asynchronous power mode
*
*/
#define ADC_POWER_STATE_ASYNCH_MODE_SUPPORTED [!IF "node:exists(AdcGeneral/AdcPowerStateAsynchTransitionMode) and (AdcGeneral/AdcPowerStateAsynchTransitionMode = 'true')"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

/** 
* @brief           This switch is used to enable the queue.
*/
[!IF "AdcGeneral/AdcPriorityImplementation = 'ADC_PRIORITY_NONE'"!][!//
#define ADC_ENABLE_QUEUING                  [!IF "AdcGeneral/AdcEnableQueuing"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]
[!ELSE!][!//
#define ADC_ENABLE_QUEUING                  (STD_ON)
[!ENDIF!][!//

[!NOCODE!][!//
[!IF "(AutosarExt/AdcEnableChDisableChApi = 'true')"!][!//
[!VAR "AdcGroupCounter" = "0"!][!//
[!LOOP "AdcConfigSet/AdcHwUnit/*/AdcGroup/*"!][!//
  [!IF "(AdcEnableChDisableChGroup = 'true')"!][!//
    [!VAR "AdcGroupCounter" = "$AdcGroupCounter + 1"!][!//
  [!ENDIF!][!//
[!ENDLOOP!][!//
[!IF "$AdcGroupCounter = 0"!][!//
[!VAR "AdcGroupCounter" = "1"!][!//
[!ENDIF!][!//
[!CODE!][!//
/** 
* @brief           Max number of groups supports the individual group channel enable or disable support.
*/
#define  ADC_NO_OF_ENABLE_CH_DISABLE_CH_GROUPS    [!"num:i($AdcGroupCounter)"!]
[!ENDCODE!][!//
[!ENDIF!][!//
[!ENDNOCODE!][!//

[!VAR "index" = "0"!][!//
[!VAR "maxVal" = "1"!][!//
[!VAR "tempVal" = "0"!][!//
[!LOOP "AdcConfigSet/AdcHwUnit/*"!][!//
[!VAR "tempVal" = "num:i(count(AdcChannel/*))"!][!//
[!IF "num:i($tempVal) > num:i($maxVal)"!][!VAR "maxVal" = "$tempVal"!][!ENDIF!][!//
[!ENDLOOP!][!//
/** 
* @brief           Maximum number of channels across all hardware units.
*/
#define ADC_MAX_CHANNEL_PER_HW_UNIT         [!"num:i($maxVal)"!]

/** 
* @brief           EQADC A symbolic name definition
*/
#define ADC_EQADC_A     (0U)

/** 
* @brief           EQADC B symbolic name definition.
*/
#define ADC_EQADC_B     (1U)

/**
* @brief          Maximum eQADC.
*/
#define ADC_EQADC_MAX_U8                     ([!"num:i(ecu:get('Adc.AdcConfigSet.MaxEqadc'))"!]U)

/**
* @brief          max number of FIFO available on ADC.
*/
#define ADC_EQADC_MAX_FIFO_U8                ([!"num:i(ecu:get('Adc.AdcConfigSet.MaxFifo'))"!]U)

/**
* @brief          FIFOs in ADC.
*/
#define ADC_FIFO_0                           (0U)
#define ADC_FIFO_1                           (1U)
#define ADC_FIFO_2                           (2U)
#define ADC_FIFO_3                           (3U)
#define ADC_FIFO_4                           (4U)
#define ADC_FIFO_5                           (5U)

/**
* @brief          max number of command FIFOs available on ADC.
*/
#define ADC_MAX_COMMAND_FIFO_U8              (6U)

/**
* @brief          max number of result FIFOs available on ADC.
*/
#define ADC_MAX_RESULT_FIFO_U8               (6U)

[!NOCODE!][!//
[!VAR "ADC_EQADC_A_Fifo0Counter" = "0"!][!//
[!VAR "ADC_EQADC_A_Fifo1Counter" = "0"!][!//
[!VAR "ADC_EQADC_A_Fifo2Counter" = "0"!][!//
[!VAR "ADC_EQADC_A_Fifo3Counter" = "0"!][!//
[!VAR "ADC_EQADC_A_Fifo4Counter" = "0"!][!//
[!VAR "ADC_EQADC_A_Fifo5Counter" = "0"!][!//
[!VAR "ADC_EQADC_B_Fifo0Counter" = "0"!][!//
[!VAR "ADC_EQADC_B_Fifo1Counter" = "0"!][!//
[!VAR "ADC_EQADC_B_Fifo2Counter" = "0"!][!//
[!VAR "ADC_EQADC_B_Fifo3Counter" = "0"!][!//
[!VAR "ADC_EQADC_B_Fifo4Counter" = "0"!][!//
[!VAR "ADC_EQADC_B_Fifo5Counter" = "0"!][!//
[!//
[!LOOP "AdcConfigSet/AdcHwUnit/*/AdcGroup/*"!][!//
[!IF "node:exists(AdcGroupFifo)"!]
[!IF "(../../AdcHwUnitId = 'ADC0') or (../../AdcHwUnitId = 'ADC1')"!][!//
[!IF "AdcGroupFifo='ADC_FIFO_0'"!]
[!VAR "ADC_EQADC_A_Fifo0Counter" = "$ADC_EQADC_A_Fifo0Counter + 1"!]
[!ENDIF!][!//
[!ELSEIF "(../../AdcHwUnitId = 'ADC2') or (../../AdcHwUnitId = 'ADC3')"!][!//
[!IF "AdcGroupFifo='ADC_FIFO_0'"!]
[!VAR "ADC_EQADC_B_Fifo0Counter" = "$ADC_EQADC_B_Fifo0Counter + 1"!]
[!ENDIF!][!//
[!ENDIF!][!//
[!//
[!IF "(../../AdcHwUnitId = 'ADC0') or (../../AdcHwUnitId = 'ADC1')"!][!//
[!IF "AdcGroupFifo='ADC_FIFO_1'"!]
[!VAR "ADC_EQADC_A_Fifo1Counter" = "$ADC_EQADC_A_Fifo1Counter + 1"!]
[!ENDIF!][!//
[!ELSEIF "(../../AdcHwUnitId = 'ADC2') or (../../AdcHwUnitId = 'ADC3')"!][!//
[!IF "AdcGroupFifo='ADC_FIFO_1'"!]
[!VAR "ADC_EQADC_B_Fifo1Counter" = "$ADC_EQADC_B_Fifo1Counter + 1"!]
[!ENDIF!][!//
[!ENDIF!][!//
[!//
[!IF "(../../AdcHwUnitId = 'ADC0') or (../../AdcHwUnitId = 'ADC1')"!][!//
[!IF "AdcGroupFifo='ADC_FIFO_2'"!]
[!VAR "ADC_EQADC_A_Fifo2Counter" = "$ADC_EQADC_A_Fifo2Counter + 1"!]
[!ENDIF!][!//
[!ELSEIF "(../../AdcHwUnitId = 'ADC2') or (../../AdcHwUnitId = 'ADC3')"!][!//
[!IF "AdcGroupFifo='ADC_FIFO_2'"!]
[!VAR "ADC_EQADC_B_Fifo2Counter" = "$ADC_EQADC_B_Fifo2Counter + 1"!]
[!ENDIF!][!//
[!ENDIF!][!//
[!//
[!IF "(../../AdcHwUnitId = 'ADC0') or (../../AdcHwUnitId = 'ADC1')"!][!//
[!IF "AdcGroupFifo='ADC_FIFO_3'"!]
[!VAR "ADC_EQADC_A_Fifo3Counter" = "$ADC_EQADC_A_Fifo3Counter + 1"!]
[!ENDIF!][!//
[!ELSEIF "(../../AdcHwUnitId = 'ADC2') or (../../AdcHwUnitId = 'ADC3')"!][!//
[!IF "AdcGroupFifo='ADC_FIFO_3'"!]
[!VAR "ADC_EQADC_B_Fifo3Counter" = "$ADC_EQADC_B_Fifo3Counter + 1"!]
[!ENDIF!][!//
[!ENDIF!][!//
[!//
[!IF "(../../AdcHwUnitId = 'ADC0') or (../../AdcHwUnitId = 'ADC1')"!][!//
[!IF "AdcGroupFifo='ADC_FIFO_4'"!]
[!VAR "ADC_EQADC_A_Fifo4Counter" = "$ADC_EQADC_A_Fifo4Counter + 1"!]
[!ENDIF!][!//
[!ELSEIF "(../../AdcHwUnitId = 'ADC2') or (../../AdcHwUnitId = 'ADC3')"!][!//
[!IF "AdcGroupFifo='ADC_FIFO_4'"!]
[!VAR "ADC_EQADC_B_Fifo4Counter" = "$ADC_EQADC_B_Fifo4Counter + 1"!]
[!ENDIF!][!//
[!ENDIF!][!//
[!//
[!IF "(../../AdcHwUnitId = 'ADC0') or (../../AdcHwUnitId = 'ADC1')"!][!//
[!IF "AdcGroupFifo='ADC_FIFO_5'"!]
[!VAR "ADC_EQADC_A_Fifo5Counter" = "$ADC_EQADC_A_Fifo5Counter + 1"!]
[!ENDIF!][!//
[!ELSEIF "(../../AdcHwUnitId = 'ADC2') or (../../AdcHwUnitId = 'ADC3')"!][!//
[!IF "AdcGroupFifo='ADC_FIFO_5'"!]
[!VAR "ADC_EQADC_B_Fifo5Counter" = "$ADC_EQADC_B_Fifo5Counter + 1"!]
[!ENDIF!][!//
[!ENDIF!][!//
[!ELSE!]
[!IF "(../../AdcHwUnitId = 'ADC0') or (../../AdcHwUnitId = 'ADC1')"!][!//
    [!VAR "ADC_EQADC_A_Fifo0Counter" = "$ADC_EQADC_A_Fifo0Counter + 1"!]
[!ELSE!][!IF "(../../AdcHwUnitId = 'ADC2') or (../../AdcHwUnitId = 'ADC3')"!][!//
    [!VAR "ADC_EQADC_B_Fifo0Counter" = "$ADC_EQADC_B_Fifo0Counter + 1"!]
[!ENDIF!][!//
[!ENDIF!][!//
[!ENDIF!][!//
[!ENDLOOP!][!//
[!ENDNOCODE!][!//

[!NOCODE!][!//
[!VAR "ADC_EQADC_A_Fifo0Enable" = "0"!][!//
[!VAR "ADC_EQADC_A_Fifo1Enable" = "0"!][!//
[!VAR "ADC_EQADC_A_Fifo2Enable" = "0"!][!//
[!VAR "ADC_EQADC_A_Fifo3Enable" = "0"!][!//
[!VAR "ADC_EQADC_A_Fifo4Enable" = "0"!][!//
[!VAR "ADC_EQADC_A_Fifo5Enable" = "0"!][!//
[!VAR "ADC_EQADC_B_Fifo0Enable" = "0"!][!//
[!VAR "ADC_EQADC_B_Fifo1Enable" = "0"!][!//
[!VAR "ADC_EQADC_B_Fifo2Enable" = "0"!][!//
[!VAR "ADC_EQADC_B_Fifo3Enable" = "0"!][!//
[!VAR "ADC_EQADC_B_Fifo4Enable" = "0"!][!//
[!VAR "ADC_EQADC_B_Fifo5Enable" = "0"!][!//
[!ENDNOCODE!][!//

/** 
* @brief           Enable/Disable the eQADC_A FIFO0.
*/
[!IF "$ADC_EQADC_A_Fifo0Counter > 0"!][!//
#define ADC_EQADC_A_FIFO0_ENABLED   (STD_ON)
[!VAR "ADC_EQADC_A_Fifo0Enable" = "$ADC_EQADC_A_Fifo0Enable + 1"!][!//
[!ELSE!][!//
#define ADC_EQADC_A_FIFO0_ENABLED   (STD_OFF)
[!ENDIF!][!//
[!//
/** 
* @brief           Enable/Disable the eQADC_A FIFO1.
*/
[!IF "$ADC_EQADC_A_Fifo1Counter > 0"!][!//
#define ADC_EQADC_A_FIFO1_ENABLED   (STD_ON)
[!VAR "ADC_EQADC_A_Fifo1Enable" = "$ADC_EQADC_A_Fifo1Enable + 1"!][!//
[!ELSE!][!//
#define ADC_EQADC_A_FIFO1_ENABLED   (STD_OFF)
[!ENDIF!][!//
[!//
/** 
* @brief           Enable/Disable the eQADC_A FIFO2.
*/
[!IF "$ADC_EQADC_A_Fifo2Counter > 0"!][!//
#define ADC_EQADC_A_FIFO2_ENABLED   (STD_ON)
[!VAR "ADC_EQADC_A_Fifo2Enable" = "$ADC_EQADC_A_Fifo2Enable + 1"!][!//
[!ELSE!][!//
#define ADC_EQADC_A_FIFO2_ENABLED   (STD_OFF)
[!ENDIF!][!//
[!//
/** 
* @brief           Enable/Disable the eQADC_A FIFO3.
*/
[!IF "$ADC_EQADC_A_Fifo3Counter > 0"!][!//
#define ADC_EQADC_A_FIFO3_ENABLED   (STD_ON)
[!VAR "ADC_EQADC_A_Fifo3Enable" = "$ADC_EQADC_A_Fifo3Enable + 1"!][!//
[!ELSE!][!//
#define ADC_EQADC_A_FIFO3_ENABLED   (STD_OFF)
[!ENDIF!][!//
[!//
/** 
* @brief           Enable/Disable the eQADC_A FIFO4.
*/
[!IF "$ADC_EQADC_A_Fifo4Counter > 0"!][!//
#define ADC_EQADC_A_FIFO4_ENABLED   (STD_ON)
[!VAR "ADC_EQADC_A_Fifo4Enable" = "$ADC_EQADC_A_Fifo4Enable + 1"!][!//
[!ELSE!][!//
#define ADC_EQADC_A_FIFO4_ENABLED   (STD_OFF)
[!ENDIF!][!//
[!//
/** 
* @brief           Enable/Disable the eQADC_A FIFO5.
*/
[!IF "$ADC_EQADC_A_Fifo5Counter > 0"!][!//
#define ADC_EQADC_A_FIFO5_ENABLED   (STD_ON)
[!VAR "ADC_EQADC_A_Fifo5Enable" = "$ADC_EQADC_A_Fifo5Enable + 1"!][!//
[!ELSE!][!//
#define ADC_EQADC_A_FIFO5_ENABLED   (STD_OFF)
[!ENDIF!][!//
[!//
/** 
* @brief           Enable/Disable the CFIFO and RFIFO.
*/
[!IF "($ADC_EQADC_A_Fifo0Enable >=1) or ($ADC_EQADC_A_Fifo1Enable >=1) or ($ADC_EQADC_A_Fifo2Enable >=1) or ($ADC_EQADC_A_Fifo3Enable >=1) or ($ADC_EQADC_A_Fifo4Enable >=1) or ($ADC_EQADC_A_Fifo5Enable >=1)"!]
#define ADC_EQADC_A_CFIFO_ENABLED   (STD_ON)
#define ADC_EQADC_A_RFIFO_ENABLED   (STD_ON)
[!ELSE!][!//
#define ADC_EQADC_A_CFIFO_ENABLED   (STD_OFF)
#define ADC_EQADC_A_RFIFO_ENABLED   (STD_OFF)
[!ENDIF!][!//
[!//

/** 
* @brief           Enable/Disable the eQADC_B FIFO0.
*/
[!IF "$ADC_EQADC_B_Fifo0Counter > 0"!][!//
#define ADC_EQADC_B_FIFO0_ENABLED   (STD_ON)
[!VAR "ADC_EQADC_B_Fifo0Enable" = "$ADC_EQADC_B_Fifo0Enable + 1"!][!//
[!ELSE!][!//
#define ADC_EQADC_B_FIFO0_ENABLED   (STD_OFF)
[!ENDIF!][!//
[!//
/** 
* @brief           Enable/Disable the eQADC_B FIFO1.
*/
[!IF "$ADC_EQADC_B_Fifo1Counter > 0"!][!//
#define ADC_EQADC_B_FIFO1_ENABLED   (STD_ON)
[!VAR "ADC_EQADC_B_Fifo1Enable" = "$ADC_EQADC_B_Fifo1Enable + 1"!][!//
[!ELSE!][!//
#define ADC_EQADC_B_FIFO1_ENABLED   (STD_OFF)
[!ENDIF!][!//
[!//
/** 
* @brief           Enable/Disable the eQADC_B FIFO2.
*/
[!IF "$ADC_EQADC_B_Fifo2Counter > 0"!][!//
#define ADC_EQADC_B_FIFO2_ENABLED   (STD_ON)
[!VAR "ADC_EQADC_B_Fifo2Enable" = "$ADC_EQADC_B_Fifo2Enable + 1"!][!//
[!ELSE!][!//
#define ADC_EQADC_B_FIFO2_ENABLED   (STD_OFF)
[!ENDIF!][!//
[!//
/** 
* @brief           Enable/Disable the eQADC_B FIFO3.
*/
[!IF "$ADC_EQADC_B_Fifo3Counter > 0"!][!//
#define ADC_EQADC_B_FIFO3_ENABLED   (STD_ON)
[!VAR "ADC_EQADC_B_Fifo3Enable" = "$ADC_EQADC_B_Fifo3Enable + 1"!][!//
[!ELSE!][!//
#define ADC_EQADC_B_FIFO3_ENABLED   (STD_OFF)
[!ENDIF!][!//
[!//
/** 
* @brief           Enable/Disable the eQADC_B FIFO4.
*/
[!IF "$ADC_EQADC_B_Fifo4Counter > 0"!][!//
#define ADC_EQADC_B_FIFO4_ENABLED   (STD_ON)
[!VAR "ADC_EQADC_B_Fifo4Enable" = "$ADC_EQADC_B_Fifo4Enable + 1"!][!//
[!ELSE!][!//
#define ADC_EQADC_B_FIFO4_ENABLED   (STD_OFF)
[!ENDIF!][!//
[!//
/** 
* @brief           Enable/Disable the eQADC_B FIFO5.
*/
[!IF "$ADC_EQADC_B_Fifo5Counter > 0"!][!//
#define ADC_EQADC_B_FIFO5_ENABLED   (STD_ON)
[!VAR "ADC_EQADC_B_Fifo5Enable" = "$ADC_EQADC_B_Fifo5Enable + 1"!][!//
[!ELSE!][!//
#define ADC_EQADC_B_FIFO5_ENABLED   (STD_OFF)
[!ENDIF!][!//
[!//
/** 
* @brief           Enable/Disable the CFIFO and RFIFO.
*/
[!IF "($ADC_EQADC_B_Fifo0Enable >=1) or ($ADC_EQADC_B_Fifo1Enable >=1) or ($ADC_EQADC_B_Fifo2Enable >=1) or ($ADC_EQADC_B_Fifo3Enable >=1) or ($ADC_EQADC_B_Fifo4Enable >=1) or ($ADC_EQADC_B_Fifo5Enable >=1)"!]
#define ADC_EQADC_B_CFIFO_ENABLED   (STD_ON)
#define ADC_EQADC_B_RFIFO_ENABLED   (STD_ON)
[!ELSE!][!//
#define ADC_EQADC_B_CFIFO_ENABLED   (STD_OFF)
#define ADC_EQADC_B_RFIFO_ENABLED   (STD_OFF)
[!ENDIF!][!//
[!//

/** 
* @brief           Symbolic names of ADC Hardware units.
*/
[!LOOP "AdcConfigSet/AdcHwUnit/*"!][!//
#define  [!"name(.)"!]                      ([!"AdcLogicalUnitId"!])
[!ENDLOOP!][!//

[!NOCODE!][!//
[!VAR "SoftwareInjectedConversionsUsed" = "0"!]
[!LOOP "AdcConfigSet/AdcHwUnit/*/AdcGroup/*"!]
    [!IF "(./AdcGroupTriggSrc = 'ADC_TRIGG_SRC_SW') and (./AdcGroupConversionType = 'ADC_CONV_TYPE_INJECTED')"!]
        [!VAR "SoftwareInjectedConversionsUsed" = "1"!]
    [!ENDIF!]
[!ENDLOOP!]
[!ENDNOCODE!][!//
/** 
* @brief           Software injected conversion use
*/
#define ADC_SOFTWARE_INJECTED_CONVERSIONS_USED          [!IF "$SoftwareInjectedConversionsUsed = 1"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

[!NOCODE!][!//
[!VAR "HwNormalUsed" = "0"!]
[!IF "count(AdcConfigSet/AdcHwUnit/*/AdcGroup/*[(AdcGroupTriggSrc = 'ADC_TRIGG_SRC_HW') and (AdcGroupConversionType = 'ADC_CONV_TYPE_NORMAL')]) > 0"!]
    [!VAR "HwNormalUsed" = "1"!]
[!ENDIF!]
[!ENDNOCODE!][!//
/** 
* @brief           Hardware normal conversion use
*/
#define ADC_HARDWARE_NORMAL_CONVERSIONS_USED            [!IF "$HwNormalUsed = 1"!](STD_ON)[!ELSE!](STD_OFF)[!ENDIF!]

/** 
* @brief           ADC Hardware unit macro for register access.
*
*/
#define ADC_HW_UNITS(unit)                  (Adc_pCfgPtr->Misc.au8Adc_HwUnit[(unit)])

/**
* @brief          Adc channel id.
*/
#define ADC_ID_CHANNEL_U8(Id)            ((uint8)(Id))

/**
* @brief          macros to simplify access to structures.
* @details        Streaming number of samples
*/
#define ADC_STREAMING_NUM_SAMPLES(num)      ((Adc_StreamNumSampleType)(num))

/**
* @brief          Configured hardware unit of the group.
*/
#if (ADC_MAX_HW_UNITS == 1U)
  #define Adc_GroupUnit(group)              0U
#else
  #define Adc_GroupUnit(group)              (Adc_pCfgPtr->pGroups[(group)].HwUnit)
#endif /* (ADC_MAX_HW_UNITS == 1U) */

/**
* @brief          Adc group priority.
*/
#define ADC_GROUP_PRIORITY(Priority)        ((Adc_GroupPriorityType)(Priority))

/**
* @brief          Adc hardware trigger source configured for the group.
*/
#define Adc_GroupTriggerSource(group,pos)   (Adc_pCfgPtr->pGroups[(group)].pHwResource[(pos)])

#if (ADC_PRIORITY_IMPLEMENTATION != ADC_PRIORITY_NONE)
/**
* @brief          Adc priority assigned to the group.
*/
#define Adc_GroupPriority(group)          (Adc_pCfgPtr->pGroups[(group)].Priority)
#endif /* ((ADC_PRIORITY_IMPLEMENTATION != ADC_PRIORITY_NONE)) */

/**
* @brief          Maximum boundary for the Adc_QueueIndexType.
*/
#define ADC_QUEUE_INDEX_TYPE_MAXIMUM          (65535U)

/**
* @brief          Check for continuous channels in group is not needed
*/
#define ADC_SKIP_DMA_CONTINUOUS_CHECK

/**
 * @brief       Invalid EXT/TST <-> INT CH mapping
 */
#define ADC_NO_EXT_TEST_CH_MAPPING            (255U)

/** 
* @brief           max queue depth configured across all configset.
*/
#define ADC_QUEUE_MAX_DEPTH_MAX             ([!"num:i(AdcGeneral/AdcPriorityQueueMaxDepth)"!]U)

[!VAR "maxGrp" = "num:i(count(AdcConfigSet/AdcHwUnit/*/AdcGroup/*))"!]
[!VAR "maxGrpChannel" = "1"!][!//
[!VAR "tempVal" = "0"!][!//
[!LOOP "AdcConfigSet/AdcHwUnit/*/AdcGroup/*"!][!//
[!VAR "tempVal" = "num:i(count(AdcGroupDefinition/*))"!][!//
[!IF "num:i($tempVal) > num:i($maxGrpChannel)"!][!VAR "maxGrpChannel" = "$tempVal"!][!ENDIF!][!//
[!ENDLOOP!][!//
/** 
* @brief           max number of channels in one group across all configset.
*/
#define ADC_MAX_GROUP_CHANNELS              [!"num:i($maxGrpChannel)"!]U

/** 
* @brief           max number of groups configured across all configset.
*/
#define ADC_MAX_GROUPS                      [!"num:i($maxGrp)"!]U

/** 
* @brief           Invalid group Id definition.
*/
#define ADC_INVALID_GROUPS_ID               (0xFFFFU)

/** 
* @brief           Defined to check the hardware triggered groups available in Hw Queue.
* @details         Defined to check the hardware triggered groups available in Hw Queue.
*/
#define ADC_HW_QUEUE                        (1U)

/** 
* @brief           AUTOSAR Symbolic names of channels on all HW units.
*/
[!FOR "x" = "0" TO "count(AdcConfigSet/AdcHwUnit/*/AdcChannel/*)-1"!][!//
[!LOOP "AdcConfigSet/AdcHwUnit/*/AdcChannel/*"!][!//
[!IF "$x = AdcLogicalChannelId"!]
#define [!"name(.)"!]                       [!"AdcLogicalChannelId"!][!//
[!ENDIF!][!//
[!ENDLOOP!][!//
[!ENDFOR!][!//

[!IF "AutosarExt/AdcEnableGroupDependentChannelNames = 'true'"!][!//
[!VAR "already_parsed_names"!][!ENDVAR!][!//
/** 
* @brief           Autosar Extension symbolic names of channels on all HW units.
*/
[!FOR "x" = "0" TO "count(AdcConfigSet/AdcHwUnit/*/AdcGroup/*)-1"!][!//
[!LOOP "AdcConfigSet/AdcHwUnit/*/AdcGroup/*"!][!//
[!IF "$x = AdcGroupId"!][!//
[!VAR "Groupname" = "name(.)"!][!//
[!VAR "index" = "0"!][!//
[!LOOP "AdcGroupDefinition/*"!][!//
[!VAR "CurrAdcChannel" = "."!][!//
[!VAR "CurrAdcChannel1" = "substring-after(substring-after(substring-after(substring-after(substring-after($CurrAdcChannel,'/'),'/'),'/'),'/'),'/')"!][!//
[!LOOP "../../../../AdcChannel/*"!][!//
[!IF "@name = $CurrAdcChannel1"!][!//
[!IF "contains($already_parsed_names, concat($Groupname, '_', node:name(.), '|')) = false()"!][!//
#define [!"$Groupname"!]_[!"name(.)"!]      [!"num:i($index)"!]
[!VAR "already_parsed_names"="concat($already_parsed_names, $Groupname, '_', node:name(.), '|')"!][!//
[!VAR "index" = "$index + 1"!][!//
[!ENDIF!][!//
[!ENDIF!][!//
[!ENDLOOP!][!//
[!ENDLOOP!][!//
[!ENDIF!][!//
[!ENDLOOP!][!//
[!ENDFOR!][!//
[!ENDIF!][!//

/** 
* @brief           Symbolic names of groups.
*/
[!FOR "x" = "0" TO "count(AdcConfigSet/AdcHwUnit/*/AdcGroup/*)-1"!][!//
[!LOOP "AdcConfigSet/AdcHwUnit/*/AdcGroup/*"!][!//
[!IF "$x = AdcGroupId"!]
#define [!"name(.)"!]                       [!"AdcGroupId"!][!//
[!ENDIF!][!//
[!ENDLOOP!][!//
[!ENDFOR!]

/** 
* @brief           Symbolic names of groups - ecuc 2108 compliant.
*/
[!FOR "x" = "0" TO "count(AdcConfigSet/AdcHwUnit/*/AdcGroup/*)-1"!][!//
[!LOOP "AdcConfigSet/AdcHwUnit/*/AdcGroup/*"!][!//
[!IF "$x = AdcGroupId"!]
#define AdcConf_AdcGroup_[!"name(.)"!]                       [!"AdcGroupId"!][!//
[!ENDIF!][!//
[!ENDLOOP!][!//
[!ENDFOR!]

/** 
* @brief           Adc Autosar Extension Enable/Disable invalid group index.
*/
#if (ADC_ENABLE_CH_DISABLE_CH_NONAUTO_API == STD_ON)
#define ADC_ENABLE_CH_DISABLE_CH_INVALID_GROUP_INDEX   ((Adc_GroupType)0xFFFF)
#endif /* ADC_ENABLE_CH_DISABLE_CH_NONAUTO_API == STD_ON */

/** 
* @brief            Support for User mode.
*                   STD_ON: the Adc driver can be executed from both supervisor and user mode. 
*                   STD_OFF: the Adc driver can be executed only from supervisor mode. 
*/
#define ADC_ENABLE_USER_MODE_SUPPORT     ([!IF "AutosarExt/AdcEnableUserModeSupport"!]STD_ON[!ELSE!]STD_OFF[!ENDIF!])

#ifndef MCAL_ENABLE_USER_MODE_SUPPORT
 #ifdef ADC_ENABLE_USER_MODE_SUPPORT
  #if (STD_ON == ADC_ENABLE_USER_MODE_SUPPORT)
   #error MCAL_ENABLE_USER_MODE_SUPPORT is not enabled. For running  ADC in user mode the MCAL_ENABLE_USER_MODE_SUPPORT needs to be defined.
  #endif /* (STD_ON == ADC_ENABLE_USER_MODE_SUPPORT) */
 #endif /* ifndef ADC_ENABLE_USER_MODE_SUPPORT */
#endif /* ifndef MCAL_ENABLE_USER_MODE_SUPPORT*/
/*==================================================================================================
*                                             ENUMS
==================================================================================================*/


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


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


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

#ifdef __cplusplus
}
#endif

#endif /* ADC_CFG_DEFINES_H */

/** @} */
