/**
*   @file           Ocu.h
*   @implements     Ocu.h_Artifact
*   @version        1.0.0
*
*   @brief          AUTOSAR Ocu - Ocu module API header.
*   @details        Ocu module API header.
*
*   @addtogroup     OCU_MODULE
*   @{
*/
/*==================================================================================================
*   Project              : AUTOSAR 4.3 MCAL
*   Platform             : PA
*   Peripheral           : eMios
*   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 OCU_H
#define OCU_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 OCU_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 OCU_H_REF_2
* Violates MISRA 2012 Advisory Rule 2.5, A project should not contain unused define declarations.
* Define 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
===============================================================================================*/
/*
* @file           Ocu.h
*/
#include "Std_Types.h"


#include "Ocu_Ipw_Types.h"

/*===============================================================================================
*                               SOURCE FILE VERSION INFORMATION
===============================================================================================*/
/**
* @{
* @file           Ocu.h
*/
#define OCU_VENDOR_ID                       43
/**
* @violates @ref OCU_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused define declarations.
*/
#define OCU_MODULE_ID                       125
#define OCU_AR_RELEASE_MAJOR_VERSION        4
#define OCU_AR_RELEASE_MINOR_VERSION        3
#define OCU_AR_RELEASE_REVISION_VERSION     1
#define OCU_SW_MAJOR_VERSION                1
#define OCU_SW_MINOR_VERSION                0
#define OCU_SW_PATCH_VERSION                0
/**@}*/

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

#ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
/* Check if header file and Std_Types.h are of the same Autosar version */
#if ((OCU_AR_RELEASE_MAJOR_VERSION != STD_AR_RELEASE_MAJOR_VERSION) || \
     (OCU_AR_RELEASE_MINOR_VERSION != STD_AR_RELEASE_MINOR_VERSION))
    #error "AutoSar Version Numbers of Ocu.h and Std_Types.h are different"
#endif

#endif


/* Check if header file and Ocu_Ipw_Types header file are of the same vendor */
#if (OCU_VENDOR_ID != OCU_IPW_TYPES_VENDOR_ID)
    #error "Ocu.h and Ocu_Ipw_Types.h have different vendor ids"
#endif
/* Check if header file and Ocu_Ipw_Types header file are of the same Autosar version */
#if ((OCU_AR_RELEASE_MAJOR_VERSION    != OCU_IPW_TYPES_AR_RELEASE_MAJOR_VERSION) || \
     (OCU_AR_RELEASE_MINOR_VERSION    != OCU_IPW_TYPES_AR_RELEASE_MINOR_VERSION) || \
     (OCU_AR_RELEASE_REVISION_VERSION != OCU_IPW_TYPES_AR_RELEASE_REVISION_VERSION))
    #error "AutoSar Version Numbers of Ocu.h and Ocu_Ipw_Types.h are different"
#endif
/* Check if header file and Ocu_Ipw_Types header file are of the same software version */
#if ((OCU_SW_MAJOR_VERSION != OCU_IPW_TYPES_SW_MAJOR_VERSION) || \
     (OCU_SW_MINOR_VERSION != OCU_IPW_TYPES_SW_MINOR_VERSION) || \
     (OCU_SW_PATCH_VERSION != OCU_IPW_TYPES_SW_PATCH_VERSION))
    #error "Software Version Numbers of Ocu.h and Ocu_Ipw_Types.h are different"
#endif

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

/*===============================================================================================
*                                       DEFINES AND MACROS
===============================================================================================*/
/**
* @brief Instance ID of this OCU driver.
*
*/
/**
* @violates @ref OCU_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused define declarations.
*/
#define OCU_INDEX               ((uint8)0U)


#if (OCU_VALIDATE_GLOBAL_CONFIG_CALL == STD_ON)
/**
* @brief            API service used without module initialization
* @details          Errors and exceptions that will be detected by the OCU driver
* @implements       Ocu_ErrorIds_define AUTOSAR
*
*/
/**
* @violates @ref OCU_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused define declarations.
*/
#define OCU_E_UNINIT                    (0x02U)

/**
* @brief            API service used with an invalid channel Identifier
* @details          Errors and exceptions that will be detected by the OCU driver
* @implements       Ocu_ErrorIds_define AUTOSAR
*/
/**
* @violates @ref OCU_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused define declarations.
*/
#define OCU_E_PARAM_INVALID_CHANNEL     (0x03U)

/**
* @brief            API Ocu_SetPinState() called with an invalid pin state or when the channel is in the RUNNING state..
* @details          Errors and exceptions that will be detected by the OCU driver
* @implements       Ocu_ErrorIds_define AUTOSAR
*/
/**
* @violates @ref OCU_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused define declarations.
*/
#define OCU_E_PARAM_INVALID_STATE      (0x04U)

/**
* @brief            API Ocu_SetPinAction() called with an invalid pin action.
* @details          Errors and exceptions that will be detected by the OCU driver
* @implements       Ocu_ErrorIds_define AUTOSAR
*/
/**
* @violates @ref OCU_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused define declarations.
*/
#define OCU_E_PARAM_INVALID_ACTION     (0x05U)

/**
* @brief            Usage of Ocu_DisableNotification() or Ocu_EnableNotification() on a channel where a NULL pointer 
*                   is configured as the notification function.
* @details          Errors and exceptions that will be detected by the OCU driver.
* @implements       Ocu_ErrorIds_define AUTOSAR
*/
/**
* @violates @ref OCU_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused define declarations.
*/
#define OCU_E_NO_VALID_NOTIF           (0x06U)

/**
* @brief            API Ocu_Init() called while the OCU driver has already been initialized
* @details          Errors and exceptions that will be detected by the OCU driver.
* @implements       Ocu_ErrorIds_define AUTOSAR
*/
/**
* @violates @ref OCU_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused define declarations.
*/
#define OCU_E_ALREADY_INITIALIZED      (0x07U)

/**
* @brief            API Ocu_GetVersionInfo() is called with a NULL parameter.
* @details          Errors and exceptions that will be detected by the OCU driver.
* @implements       Ocu_ErrorIds_define AUTOSAR
*/
/**
* @violates @ref OCU_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused define declarations.
*/
#define OCU_E_PARAM_POINTER            (0x08U)

/**
* @brief            API Ocu_StartChannel() called on a channel that is in state RUNNING.
* @details          Errors and exceptions that will be detected by the OCU driver
* @implements       Ocu_ErrorIds_define AUTOSAR
*/
/**
* @violates @ref OCU_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused define declarations.
*/
#define OCU_E_BUSY                      (0x09U)

/**
* @brief            Ocu_SetPinState() or Ocu_SetPinAction() called for a channel that doesn’t 
*                   have an associated output pin.
* @details          Errors and exceptions that will be detected by the OCU driver
* @implements       Ocu_ErrorIds_define AUTOSAR
*/
/**
* @violates @ref OCU_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused define declarations.
*/
#define OCU_E_PARAM_NO_PIN              (0x0AU)


/**
* @brief            API Ocu_Init service called with wrong parameter
* @details          Errors and exceptions that will be detected by the OCU driver
* @implements       Ocu_ErrorIds_define AUTOSAR
*/
/**
* @violates @ref OCU_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused define declarations.
*/
#define OCU_E_INIT_FAILED               (0x0BU)

/**
* @brief            Ocu_SetAbsoluteThreshold() or Ocu_SetRelativeThreshold() called for with a compare 
*                   match parameter greater than maximum supported counter value for a given channel
* @details          Errors and exceptions that will be detected by the OCU driver
* @implements       Ocu_ErrorIds_define Non-AUTOSAR
*/
/**
* @violates @ref OCU_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused define declarations.
*/
#define OCU_E_PARAM_INVALID_VALUE       (0x1BU)

#endif /*#if (OCU_VALIDATE_GLOBAL_CONFIG_CALL == STD_ON)*/

/**
* @brief            API service ID of Ocu_Init function
* @details          Parameters used when raising an error/exception
*/
/**
* @violates @ref OCU_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused define declarations.
*/
#define OCU_INIT_ID                (0x00U)

/**
* @brief            API service ID of Ocu_DeInit function
* @details          Parameters used when raising an error/exception
*/
/**
* @violates @ref OCU_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused define declarations.
*/
#define OCU_DEINIT_ID              (0x01U)

/**
* @brief            API service ID of Ocu_StartChannel function
* @details          Parameters used when raising an error/exception
*/
/**
* @violates @ref OCU_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused define declarations.
*/
#define OCU_STARTCHANNEL_ID        (0x02U)

/**
* @brief            API service ID of Ocu_StopChannel function
* @details          Parameters used when raising an error/exception
*/
/**
* @violates @ref OCU_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused define declarations.
*/
#define OCU_STOPCHANNEL_ID         (0x03U)
/**
* @brief            API service ID of Ocu_SetPinState function
* @details          Parameters used when raising an error/exception
*/
/**
* @violates @ref OCU_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused define declarations.
*/
#define OCU_SETPINSTATE_ID          (0x04U)

/**
* @brief            API service ID of Ocu_SetPinAction function
* @details          Parameters used when raising an error/exception
*/
/**
* @violates @ref OCU_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused define declarations.
*/
#define OCU_SETPINACTION_ID         (0x05U)

/**
* @brief            API service ID of Ocu_GetCounter function
* @details          Parameters used when raising an error/exception
*/
/**
* @violates @ref OCU_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused define declarations.
*/
#define OCU_GETCOUNTER_ID           (0x06U)

/**
* @brief            API service ID of Ocu_SetAbsoluteThreshold function
* @details          Parameters used when raising an error/exception
*/
/**
* @violates @ref OCU_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused define declarations.
*/
#define OCU_SETABSOLUTETHRESHOLD_ID  (0x07U)

/**
* @brief            API service ID of Ocu_SetRelativeThreshold function
* @details          Parameters used when raising an error/exception
*/
/**
* @violates @ref OCU_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused define declarations.
*/
#define OCU_SETRELATIVETHRESHOLD_ID  (0x08U)

/**
* @brief            API service ID of Ocu_DisableNotification function
* @details          Parameters used when raising an error/exception
*/
/**
* @violates @ref OCU_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused define declarations.
*/
#define OCU_DISABLENOTIFICATION_ID   (0x0AU)

/**
* @brief            API service ID of Ocu_EnableNotification function
* @details          Parameters used when raising an error/exception
*/
/**
* @violates @ref OCU_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused define declarations.
*/
#define OCU_ENABLENOTIFICATION_ID    (0x0BU)


/**
* @brief            API service ID of Ocu_GetVersionInfo function
* @details          Parameters used when raising an error/exception
*/
/**
* @violates @ref OCU_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused define declarations.
*/
#define OCU_GETVERSIONINFO_ID        (0x09U)

/**
* @brief            API Ocu_SetClockMode service called with wrong parameter
* @details          Parameters used when raising an error/exception
*/
/**
* @violates @ref OCU_H_REF_2 Violates Advisory Rule 2.5, A project should not contain unused define declarations.
*/
#define OCU_SETCLOCKMODE_ID          (0x7AU)
/*===============================================================================================
*                                             ENUMS
===============================================================================================*/





/*===============================================================================================
*                            STRUCTURES AND OTHER TYPEDEFS
===============================================================================================*/
typedef struct
{
    /** @brief Channel output pin enable */
    VAR(boolean,                OCU_VAR)  bOcuOutputPinEnable;
#if (OCU_NOTIFICATION_SUPPORTED == STD_ON)
    /** @brief Pointer to notification function */
    CONST(Ocu_NotifyType,       OCU_CONST) pfOcuChannelNotification;
#endif /*(OCU_NOTIFICATION_SUPPORTED == STD_ON)*/
} Ocu_ChannelConfigType;


/**
* @brief      Ocu high level configuration structure
* @implements Ocu_ConfigType_struct
*/
typedef struct
{
    /** @brief Number of OCU channels (configured in tresos plugin builder)*/
    CONST(Ocu_ChannelType, OCU_CONST) nNumChannels;
    /** @brief Pointer to the OCU channel configuration */
    CONST(Ocu_ChannelConfigType, OCU_CONST) (*pOcuChannelsConfig)[];
    /** @brief Combined IP specific configuration structure */       
    CONST   (Ocu_IpConfigType,   OCU_CONST)   IpConfig; 
#if (OCU_DOWNCOUNTING_SUPPORED == STD_ON)    
    /** @brief Counting direction  */
    CONST(Ocu_CountDirectionType,   OCU_CONST)   eCountDir;
#endif    
#if (OCU_NOTIFICATION_SUPPORTED == STD_ON)
    /** @brief Index table to translate HW channels to logical used 
    to process interrupts for notifications */
    CONST(Ocu_ChannelType, OCU_CONST) (*HwToLogicChannelMap)[];
#endif    
} Ocu_ConfigType;


/*===============================================================================================
*                                 GLOBAL VARIABLE DECLARATIONS
===============================================================================================*/
#define OCU_START_SEC_CONFIG_DATA_UNSPECIFIED
/**
* @violates @ref OCU_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.
*/
#include "Ocu_MemMap.h"

#if (OCU_PRECOMPILE_SUPPORT != STD_ON)
OCU_CONF_PB
#endif

#define OCU_STOP_SEC_CONFIG_DATA_UNSPECIFIED
/**
* @violates @ref OCU_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.
*
*/
#include "Ocu_MemMap.h"

/*===============================================================================================
                                     FUNCTION PROTOTYPES
===============================================================================================*/
#define OCU_START_SEC_CODE
/**
* @violates @ref OCU_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.
*/
#include "Ocu_MemMap.h"

/*===============================================================================================*/

FUNC (void, OCU_CODE) Ocu_Init
(
    P2CONST(Ocu_ConfigType, AUTOMATIC, OCU_APPL_CONST) ConfigPtr
);

/*===============================================================================================*/

#if (OCU_DEINIT_API == STD_ON)
FUNC (void, OCU_CODE) Ocu_DeInit
(   
    void
);
#endif

/*===============================================================================================*/
FUNC (void, OCU_CODE) Ocu_StartChannel
(
    VAR(Ocu_ChannelType,            AUTOMATIC) ChannelNumber
);

/*===============================================================================================*/
FUNC (void, OCU_CODE) Ocu_StopChannel
(
    VAR(Ocu_ChannelType,            AUTOMATIC) ChannelNumber
);

/*===============================================================================================*/

#if (OCU_SET_PIN_STATE_API == STD_ON)
FUNC (void, OCU_CODE) Ocu_SetPinState
(
    VAR(Ocu_ChannelType,            AUTOMATIC) ChannelNumber,
    VAR(Ocu_PinStateType,           AUTOMATIC) PinState
);
#endif

/*===============================================================================================*/


#if (OCU_SET_PIN_ACTION_API == STD_ON)
FUNC (void, OCU_CODE) Ocu_SetPinAction
(
    VAR(Ocu_ChannelType,            AUTOMATIC) ChannelNumber,
    VAR(Ocu_PinActionType,          AUTOMATIC) PinAction
);
#endif

/*===============================================================================================*/

#if (OCU_GET_COUNTER_API == STD_ON)
FUNC (Ocu_ValueType, OCU_CODE) Ocu_GetCounter
(
    VAR(Ocu_ChannelType,            AUTOMATIC) ChannelNumber
);
#endif


/*===============================================================================================*/

#if (OCU_SET_ABSOLUTE_THRESHOLD_API == STD_ON)
FUNC(Ocu_ReturnType, OCU_CODE) Ocu_SetAbsoluteThreshold
(
   VAR(Ocu_ChannelType,             AUTOMATIC) ChannelNumber,
   VAR(Ocu_ValueType,               AUTOMATIC) ReferenceValue,
   VAR(Ocu_ValueType,               AUTOMATIC) AbsoluteValue
);
#endif

/*===============================================================================================*/

#if (OCU_SET_RELATIVE_THRESHOLD_API == STD_ON)
FUNC(Ocu_ReturnType, OCU_CODE) Ocu_SetRelativeThreshold
(
   VAR(Ocu_ChannelType,             AUTOMATIC) ChannelNumber,
   VAR(Ocu_ValueType,               AUTOMATIC) RelativeValue   
);
#endif

/*===============================================================================================*/

#if (OCU_NOTIFICATION_SUPPORTED == STD_ON)
FUNC (void, OCU_CODE) Ocu_DisableNotification
(
    VAR(Ocu_ChannelType,            AUTOMATIC) ChannelNumber
);
#endif


/*===============================================================================================*/

#if (OCU_NOTIFICATION_SUPPORTED == STD_ON)
FUNC (void, OCU_CODE) Ocu_EnableNotification
(
    VAR(Ocu_ChannelType,            AUTOMATIC) ChannelNumber
);
#endif

/*===============================================================================================*/

#if (OCU_VERSION_INFO_API == STD_ON)
FUNC(void, OCU_CODE) Ocu_GetVersionInfo
(
    P2VAR(Std_VersionInfoType ,     AUTOMATIC, OCU_APPL_DATA) versioninfo
);
#endif

/*===============================================================================================*/

#ifdef OCU_SET_CLOCK_MODE_API
#if (OCU_SET_CLOCK_MODE_API == STD_ON)
FUNC(void, OCU_CODE) Ocu_SetClockMode
(
    VAR(Ocu_SelectPrescalerType, AUTOMATIC) ePrescaler
);
#endif /*OCU_SET_CLOCK_MODE_API*/
#endif

/*===============================================================================================*/


#define OCU_STOP_SEC_CODE
/**
* @violates @ref OCU_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.
*/
#include "Ocu_MemMap.h"


#ifdef __cplusplus
}
#endif

#endif /* OCU_H */

/** @} */
