/**
*   @file    Icu_eMios.h
*   @version 1.0.0
*
*   @brief   AUTOSAR Icu - Brief file description (one line).
*   @details Detailed file description (can be multiple lines).
*
*   @addtogroup ICU_MODULE
*   @{
*/
/*==================================================================================================
*   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_H
#define ICU_EMIOS_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_H_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 <MA>_MemMap.h is as per AUTOSAR requirement [SWS_MemMap_00003].
*
* @section ICU_EMIOS_H_REF_2
* Violates MISRA 2012 Advisory Rule 20.1, #include directives should only be preceded by preprocessor
* directives or comments.
* <MA>_MemMap.h is included after each section define in order to set the current memory section as defined by AUTOSAR.
*
* @section ICU_EMIOS_H_REF_3
* Violates MISRA 2012 Advisory Rule 2.5, A project should not contain unused macro declarations.
* Define is/might be used in configuration.
*
* @section ICU_EMIOS_H_REF_4
* Violates MISRA 2012 Advisory Rule 2.3, A project should not contain unused type declarations.
* Enum type is used in configuration.
*
*/

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

/*==================================================================================================
                               SOURCE FILE VERSION INFORMATION
==================================================================================================*/
#define ICU_EMIOS_VENDOR_ID                           43
#define ICU_EMIOS_AR_RELEASE_MAJOR_VERSION            4
#define ICU_EMIOS_AR_RELEASE_MINOR_VERSION            3
#define ICU_EMIOS_AR_RELEASE_REVISION_VERSION         1
#define ICU_EMIOS_SW_MAJOR_VERSION                    1
#define ICU_EMIOS_SW_MINOR_VERSION                    0
#define ICU_EMIOS_SW_PATCH_VERSION                    0

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

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

/*==================================================================================================
                                       DEFINES AND MACROS
==================================================================================================*/
/**
* @brief            eMIOS Channel Modes
* @details          Indicates the channel mode type(capture mode, edge counter).
*/
/*< @brief Mode for detecting edges. */
/* @violates @ref ICU_EMIOS_H_REF_3 Violates Advisory Rule 2.5, A project should not contain unused macro declarations. */
#define EMIOS_CHANNEL_MODE_SIGNAL_EDGE_DETECT       0x01U
/*< @brief Mode for measuring different times between various configurable edges. */
/* @violates @ref ICU_EMIOS_H_REF_3 Violates Advisory Rule 2.5, A project should not contain unused macro declarations. */
#define EMIOS_CHANNEL_MODE_SIGNAL_MEASUREMENT       0x02U
/*< @brief Mode for capturing timer values on configurable edges. */
/* @violates @ref ICU_EMIOS_H_REF_3 Violates Advisory Rule 2.5, A project should not contain unused macro declarations. */
#define EMIOS_CHANNEL_MODE_TIMESTAMP_WITHOUT_DMA    0x04U
/*< @brief Mode for capturing timer values on configurable edges. */
/* @violates @ref ICU_EMIOS_H_REF_3 Violates Advisory Rule 2.5, A project should not contain unused macro declarations. */
#define EMIOS_CHANNEL_MODE_TIMESTAMP_WITH_DMA       0x10U
/*< @brief Mode for counting edges on configurable edges. */
/* @violates @ref ICU_EMIOS_H_REF_3 Violates Advisory Rule 2.5, A project should not contain unused macro declarations. */
#define EMIOS_CHANNEL_MODE_EDGE_COUNTER             0x08U  

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

/**
* @brief Definition of the measurement property type.
*/
typedef enum
{
    EMIOS_ICU_LOW_TIME     = 0x01U,    /*< @brief The channel is configured for reading the
                                         *          elapsed Signal Low Time. */
    EMIOS_ICU_HIGH_TIME    = 0x02U,    /*< @brief The channel is configured for reading the
                                         *          elapsed Signal High Time. */
    EMIOS_ICU_PERIOD_TIME  = 0x04U,    /*< @brief The channel is configured for reading the
                                         *          elapsed Signal Period Time. */
    EMIOS_ICU_DUTY_CYCLE   = 0x08U     /*< @brief The channel is configured to read values which
                                         *          are needed for calculating the duty cycle
                                         *          (coherent Active and Period Time). */
/* @violates @ref ICU_EMIOS_H_REF_4 Violates Advisory Rule 2.3, A project should not contain unused type declarations. */
} Icu_eMios_SignalMeasurementPropertyType;

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


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


/*==================================================================================================
                                     FUNCTION PROTOTYPES
==================================================================================================*/
#define ICU_START_SEC_CODE
/**
* @violates @ref ICU_EMIOS_H_REF_1 Directive 4.10, Precautions shall be taken in order to prevent the contents
* of a header file being included more than once.
*
* @violates @ref ICU_EMIOS_H_REF_2 Advisory Rule 20.1, #include directives should only be preceded by 
* preprocessor directives or comments.
*/
#include "Icu_MemMap.h"

FUNC (void, ICU_CODE) Icu_eMios_Init
(
    P2CONST(Icu_eMios_IpConfigType, AUTOMATIC, ICU_APPL_CONST) peMiosIpConfig
);

#if (ICU_DE_INIT_API == STD_ON)
FUNC (void, ICU_CODE) Icu_eMios_DeInit
(
    P2CONST(Icu_eMios_IpConfigType, AUTOMATIC, ICU_APPL_CONST) peMiosIpConfig
);
#endif

#if (ICU_SET_MODE_API == STD_ON)
FUNC (void, ICU_CODE) Icu_eMios_SetSleepMode
(
    CONST(Icu_eMios_ChannelType, AUTOMATIC) nHwChannel
);
FUNC (void, ICU_CODE) Icu_eMios_SetNormalMode
(
    CONST(Icu_eMios_ChannelType, AUTOMATIC) nHwChannel
);
#endif  /* ICU_SET_MODE_API */


FUNC (void, ICU_CODE) Icu_eMios_SetActivationCondition
(
    CONST(Icu_eMios_ChannelType, AUTOMATIC) nHwChannel,
    CONST(Icu_eMios_ActivationType, AUTOMATIC) Activation
);

#if (ICU_EDGE_DETECT_API == STD_ON)
FUNC (void, ICU_CODE) Icu_eMios_EnableEdgeDetection
(
    CONST(Icu_eMios_ChannelType, AUTOMATIC) nHwChannel
);
FUNC (void, ICU_CODE) Icu_eMios_DisableEdgeDetection
(
    CONST(Icu_eMios_ChannelType, AUTOMATIC) nHwChannel
);
#endif /* ICU_EDGE_DETECT_API */

#if (ICU_TIMESTAMP_API == STD_ON)
FUNC(void, ICU_CODE) Icu_eMios_StartTimestamp
(
    CONST(Icu_eMios_ChannelType, AUTOMATIC)   nHwChannel,
    CONST(boolean, AUTOMATIC)   bDmaSupport
);
FUNC(void, ICU_CODE) Icu_eMios_StopTimestamp
(
    CONST(Icu_eMios_ChannelType, AUTOMATIC)   nHwChannel
);
#endif  /* ICU_TIMESTAMP_API */
#if ((ICU_SIGNALMEASUREMENT_USES_DMA == STD_ON) || (ICU_TIMESTAMP_USES_DMA == STD_ON))
FUNC(uint32, ICU_CODE) Icu_eMios_GetStartAddress
(
    CONST(Icu_eMios_ChannelType, AUTOMATIC) nHwChannel
);
#endif

#if (ICU_EDGE_COUNT_API == STD_ON)
FUNC (void, ICU_CODE) Icu_eMios_ResetEdgeCount
(
    CONST(Icu_eMios_ChannelType, AUTOMATIC) nHwChannel
);
FUNC (void, ICU_CODE) Icu_eMios_EnableEdgeCount
(
    CONST(Icu_eMios_ChannelType, AUTOMATIC) nHwChannel
);
FUNC (void, ICU_CODE) Icu_eMios_DisableEdgeCount
(
    CONST(Icu_eMios_ChannelType, AUTOMATIC) nHwChannel
);
FUNC (uint32, ICU_CODE) Icu_eMios_GetEdgeNumbers
(
    CONST(Icu_eMios_ChannelType, AUTOMATIC) nHwChannel
);
#endif  /* ICU_EDGE_COUNT_API */

#if (ICU_SIGNAL_MEASUREMENT_API == STD_ON)
FUNC (void, ICU_CODE) Icu_eMios_StartSignalMeasurement
(
    CONST(Icu_eMios_ChannelType,    AUTOMATIC) nHwChannel,
    CONST(Icu_eMios_ActivationType, AUTOMATIC) Activation,
    CONST(uint16,                   AUTOMATIC) nMeasProperty,
    CONST(boolean,                  AUTOMATIC) bDmaSupport,
    CONST(boolean,                  AUTOMATIC) bWithoutInterrupt
);

FUNC (void, ICU_CODE) Icu_eMios_StopSignalMeasurement
(
    CONST(Icu_eMios_ChannelType, AUTOMATIC) nHwChannel
);
#endif  /* ICU_SIGNAL_MEASUREMENT_API */

#if (ICU_GET_INPUT_STATE_API == STD_ON)
FUNC (boolean, ICU_CODE) Icu_eMios_GetInputState
(
    CONST(Icu_eMios_ChannelType, AUTOMATIC) nHwChannel
);
#endif  /* ICU_GET_INPUT_STATE_API */

FUNC (void, ICU_CODE) Icu_eMios_ProcessCommonInterrupt
(
    CONST(Icu_eMios_ChannelType, AUTOMATIC) nHwChannel
);

#if (ICU_GET_INPUT_LEVEL_API == STD_ON)
FUNC (boolean, ICU_CODE) Icu_eMios_GetInputLevel
(
    CONST(Icu_eMios_ChannelType, AUTOMATIC) nHwChannel
);
#endif /* ICU_GET_INPUT_LEVEL_API == STD_ON */

FUNC (boolean, ICU_CODE) Icu_eMios_GetOverflow
(
    CONST(Icu_eMios_ChannelType, AUTOMATIC) nHwChannel
);

#if (ICU_DUAL_CLOCK_MODE_API == STD_ON)
FUNC (void, ICU_CODE) Icu_eMios_SetClockMode
(
    P2CONST(Icu_eMios_IpConfigType, AUTOMATIC, ICU_APPL_CONST) peMiosIpConfig,
    CONST(uint32, AUTOMATIC) Prescaler
);
#endif  /* ICU_DUAL_CLOCK_MODE_API == STD_ON */

#if ((ICU_CAPTURERGISTER_API == STD_ON) && ((ICU_SIGNAL_MEASUREMENT_API == STD_ON) || (ICU_TIMESTAMP_API == STD_ON)))
FUNC(uint32, ICU_CODE) Icu_eMios_GetCaptureRegisterValue
(
    CONST(Icu_eMios_ChannelType, AUTOMATIC) nHwChannel
);
#endif  /* ICU_DUAL_CLOCK_MODE_API == STD_ON */

#if ((ICU_GET_PULSE_WIDTH_API == STD_ON) && (ICU_SIGNAL_MEASUREMENT_API == STD_ON))
FUNC(void, ICU_CODE) Icu_eMios_GetPulseWidth
(
    CONST(Icu_eMios_ChannelType, AUTOMATIC) nHwChannel
);
#endif /* ((ICU_GET_PULSE_WIDTH_API == STD_ON) &&  (ICU_SIGNAL_MEASUREMENT_API == STD_ON))*/

#if ((ICU_VALIDATE_GLOBAL_CALL == STD_ON) && ((ICU_GET_PULSE_WIDTH_API == STD_ON) && (ICU_SIGNAL_MEASUREMENT_API == STD_ON)))
FUNC (Std_ReturnType, ICU_CODE) Icu_eMios_ValidateSignalMeasureWithoutInterrupt
(
    VAR         (uint8, AUTOMATIC) u8IdxChannelConfig,
    CONSTP2CONST(Icu_eMios_IpConfigType, AUTOMATIC, ICU_APPL_CONST) peMiosIpConfig
);
#endif /* ((ICU_GET_PULSE_WIDTH_API == STD_ON) &&  (ICU_SIGNAL_MEASUREMENT_API == STD_ON))*/

#define ICU_STOP_SEC_CODE
/**
* @violates @ref ICU_EMIOS_H_REF_1 Directive 4.10, Precautions shall be taken in order to prevent the contents
* of a header file being included more than once.
*
* @violates @ref ICU_EMIOS_H_REF_2 Advisory Rule 20.1, #include directives should only be preceded by 
* preprocessor directives or comments.
*/
#include "Icu_MemMap.h"

#ifdef __cplusplus
}
#endif

#endif  /* ICU_EMIOS_H */
/** @} */
