/*!
* @file     Ocu.c
*
* @version  1.0.0
*
* @brief    The implementation of Ocu high level interface.
*           This file includes the high level interface implementation of the Ocu moudle.
* @attention
*
* Project Name      : AUTOSAR MCAL
*
* Platform          : Arm
*
* Autosar Standard  : Classic Platform 4.4.0
*
* Compiled Version  : G32A10xx_MCAL_1_0_0_15-Nov-2
*
* Copyright (C) 2026 Geehy Semiconductor
*
* You may not use this file except in compliance with the
* GEEHY COPYRIGHT NOTICE (Geehy Semiconductor Software License Agreement).
*
* The program is only for reference, which is distributed in the hope
* that it will be usefull and instructional for customers to develop
* their software. Unless required by applicable law or agreed to in
* writing, the program is distributed on an "AS IS" BASIS, WITHOUT
* ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied.
* See the Geehy Semiconductor Software License Agreement for the governing permissions
* and limitations under the License.
*/

/*
* MISRA-C:2012 compliance checks
*
*     Ocu_c_MISRA_REF1
*          Breaks the required Rule-13.5 of MISRA 2012 guidelines,
*          The right hand operand of a logical && or || operator shall not contain persistent side effects.
*
*     Ocu_c_MISRA_REF2
*          Breaks the required Rule-10.5 of MISRA 2012 guidelines,
*          The value of an expression should not be cast to an inappropriate essential type.
*
*/

#ifdef __cplusplus
extern "C"{
#endif  /* ifdef __cplusplus */

#include "Ocu.h"
#include "Ocu_Ipw.h"
#include "Mcal.h"

#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)
    #include "Det.h"
#endif
/** @addtogroup G32A10xx_StdPeriphDriver
  @{
*/

/** @defgroup OCU_Driver
  * @brief OCU driver modules
  @{
*/

/** @defgroup OCU_Macros
  @{
*/
/***********************************************************************************************************************
                                    VENDOR ID & AUTOSAR VERSION INFO
***********************************************************************************************************************/
/** Vendor ID (vendorId) of the dedicated implementation of this module according to the AUTOSAR vendor list. */
#define OCU_VENDOR_ID                                      0x00C1U
/** Major version number of AUTOSAR release on which the appropriate implementation is based on. */  
#define OCU_AR_RELEASE_MAJOR_VERSION                       0x04U
/** Minor version number of AUTOSAR release on which the appropriate implementation is based on. */
#define OCU_AR_RELEASE_MINOR_VERSION                       0x04U
/** Revision version number of AUTOSAR release on which the appropriate implementation is based on. */
#define OCU_AR_RELEASE_REVISION_VERSION                    0x00U
/** Major version number of the vendor specific implementation of the module. The numbering is vendor specific. */ 
#define OCU_SW_MAJOR_VERSION                               0x01U
/** Minor version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define OCU_SW_MINOR_VERSION                               0x00U
/** Patch level version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define OCU_SW_PATCH_VERSION                               0x00U
/**@} end of group OCU_Macros */
/***********************************************************************************************************
                                  VERSION INFOMATION VERIFICATION
*************************************************************************************************************/
#ifdef ENABLE_INTERMODULE_MCAL_CHECK
#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)
    /* Make sure the AUTOSAR major version number is the same between Ocu.c and Det.h */
    #if (OCU_AR_RELEASE_MAJOR_VERSION != DET_H_AR_RELEASE_MAJOR_VERSION)
        #error "AUTOSAR Major Version Number mismatch between Ocu.c and Det.h"
    #endif
    /* Make sure the AUTOSAR minor version number is the same between Ocu.c and Det.h */
    #if (OCU_AR_RELEASE_MINOR_VERSION != DET_H_AR_RELEASE_MINOR_VERSION)
        #error "AUTOSAR Minor Version Number mismatch between Ocu.c and Det.h"
    #endif
#endif  /* {if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)} */
/* Make sure the AUTOSAR major version number is the same between Ocu.c and Mcal.h */
#if (OCU_AR_RELEASE_MAJOR_VERSION != MCAL_H_AR_RELEASE_MAJOR_VERSION)
    #error "AUTOSAR Major Version Number mismatch between Ocu.c and Mcal.h"
#endif
/* Make sure the AUTOSAR minor version number is the same between Ocu.c and Mcal.h */
#if (OCU_AR_RELEASE_MINOR_VERSION != MCAL_H_AR_RELEASE_MINOR_VERSION)
    #error "AUTOSAR Minor Version Number mismatch between Ocu.c and Mcal.h"
#endif
#endif 

/* Make sure the vendor ids are the same between Ocu.c and Ocu.h */
#if (OCU_VENDOR_ID != OCU_H_VENDOR_ID)
    #error "Vendor ids mismatch between Ocu.c and Ocu.h"
#endif  /* {if (OCU_VENDOR_ID != OCU_H_VENDOR_ID)} */

/* Make sure the AUTOSAR major version number is the same between Ocu.c and Ocu.h */
#if (OCU_AR_RELEASE_MAJOR_VERSION    != OCU_H_AR_RELEASE_MAJOR_VERSION)
    #error "AUTOSAR Major Version Number mismatch between Ocu.c and Ocu.h"
#endif
/* Make sure the AUTOSAR minor version number is the same between Ocu.c and Ocu.h */
#if (OCU_AR_RELEASE_MINOR_VERSION    != OCU_H_AR_RELEASE_MINOR_VERSION)
    #error "AUTOSAR Minor Version Number mismatch between Ocu.c and Ocu.h"
#endif
/* Make sure the AUTOSAR revision version number is the same between Ocu.c and Ocu.h */
#if (OCU_AR_RELEASE_REVISION_VERSION != OCU_H_AR_RELEASE_REVISION_VERSION)
    #error "AUTOSAR Revision Version Number mismatch between Ocu.c and Ocu.h"
#endif

/* Make sure the software major version number is the same between Ocu.c and Ocu.h */
#if (OCU_SW_MAJOR_VERSION != OCU_H_SW_MAJOR_VERSION)
    #error "Software Major Version Number mismatch between Ocu.c and Ocu.h"
#endif
/* Make sure the software minor version number is the same between Ocu.c and Ocu.h */
#if (OCU_SW_MINOR_VERSION != OCU_H_SW_MINOR_VERSION)
    #error "Software Minor Version Number mismatch between Ocu.c and Ocu.h"
#endif
/* Make sure the software patch version number is the same between Ocu.c and Ocu.h */
#if (OCU_SW_PATCH_VERSION != OCU_H_SW_PATCH_VERSION)
    #error "Software Patch Version Number mismatch between Ocu.c and Ocu.h"
#endif

/* Make sure the vendor ids are the same between Ocu.c and Ocu_Ipw.h */
#if (OCU_VENDOR_ID != OCU_IPW_H_VENDOR_ID)
    #error "Vendor ids mismatch between Ocu.c and Ocu_Ipw.h"
#endif  /* {if (OCU_VENDOR_ID != OCU_IPW_H_VENDOR_ID)} */

/* Make sure the AUTOSAR major version number is the same between Ocu.c and Ocu_Ipw.h */
#if (OCU_AR_RELEASE_MAJOR_VERSION    != OCU_IPW_H_AR_RELEASE_MAJOR_VERSION)
    #error "AUTOSAR Major Version Number mismatch between Ocu.c and Ocu_Ipw.h"
#endif
/* Make sure the AUTOSAR minor version number is the same between Ocu.c and Ocu_Ipw.h */
#if (OCU_AR_RELEASE_MINOR_VERSION    != OCU_IPW_H_AR_RELEASE_MINOR_VERSION)
    #error "AUTOSAR Minor Version Number mismatch between Ocu.c and Ocu_Ipw.h"
#endif
/* Make sure the AUTOSAR revision version number is the same between Ocu.c and Ocu_Ipw.h */
#if (OCU_AR_RELEASE_REVISION_VERSION != OCU_IPW_H_AR_RELEASE_REVISION_VERSION)
    #error "AUTOSAR Revision Version Number mismatch between Ocu.c and Ocu_Ipw.h"
#endif

/* Make sure the software major version number is the same between Ocu.c and Ocu_Ipw.h */
#if (OCU_SW_MAJOR_VERSION != OCU_IPW_H_SW_MAJOR_VERSION)
    #error "Software Major Version Number mismatch between Ocu.c and Ocu_Ipw.h"
#endif
/* Make sure the software minor version number is the same between Ocu.c and Ocu_Ipw.h */
#if (OCU_SW_MINOR_VERSION != OCU_IPW_H_SW_MINOR_VERSION)
    #error "Software Minor Version Number mismatch between Ocu.c and Ocu_Ipw.h"
#endif
/* Make sure the software patch version number is the same between Ocu.c and Ocu_Ipw.h */
#if (OCU_SW_PATCH_VERSION != OCU_IPW_H_SW_PATCH_VERSION)
    #error "Software Patch Version Number mismatch between Ocu.c and Ocu_Ipw.h"
#endif

/* Make sure the vendor ids are the same between Ocu.c and Ocu_Ipw_Types.h */
#if (OCU_VENDOR_ID != OCU_IPW_TYPES_H_VENDOR_ID)
    #error "Vendor ids mismatch between Ocu.c and Ocu_Ipw_Types.h"
#endif  /* {if (OCU_VENDOR_ID != OCU_IPW_TYPES_H_VENDOR_ID)} */

/* Make sure the AUTOSAR major version number is the same between Ocu.c and Ocu_Ipw_Types.h */
#if (OCU_AR_RELEASE_MAJOR_VERSION    != OCU_IPW_TYPES_H_AR_RELEASE_MAJOR_VERSION)
    #error "AUTOSAR Major Version Number mismatch between Ocu.c and Ocu_Ipw_Types.h"
#endif
/* Make sure the AUTOSAR minor version number is the same between Ocu.c and Ocu_Ipw_Types.h */
#if (OCU_AR_RELEASE_MINOR_VERSION    != OCU_IPW_TYPES_H_AR_RELEASE_MINOR_VERSION)
    #error "AUTOSAR Minor Version Number mismatch between Ocu.c and Ocu_Ipw_Types.h"
#endif
/* Make sure the AUTOSAR revision version number is the same between Ocu.c and Ocu_Ipw_Types.h */
#if (OCU_AR_RELEASE_REVISION_VERSION != OCU_IPW_TYPES_H_AR_RELEASE_REVISION_VERSION)
    #error "AUTOSAR Revision Version Number mismatch between Ocu.c and Ocu_Ipw_Types.h"
#endif

/* Make sure the software major version number is the same between Ocu_Ipw.c and Ocu_Ipw_Types.h */
#if (OCU_SW_MAJOR_VERSION != OCU_IPW_TYPES_H_SW_MAJOR_VERSION)
    #error "Software Major Version Number mismatch between Ocu.c and Ocu_Ipw_Types.h"
#endif
/* Make sure the software minor version number is the same between Ocu_Ipw.c and Ocu_Ipw_Types.h */
#if (OCU_SW_MINOR_VERSION != OCU_IPW_TYPES_H_SW_MINOR_VERSION)
    #error "Software Minor Version Number mismatch between Ocu.c and Ocu_Ipw_Types.h"
#endif
/* Make sure the software patch version number is the same between Ocu_Ipw.c and Ocu_Ipw_Types.h */
#if (OCU_SW_PATCH_VERSION != OCU_IPW_TYPES_H_SW_PATCH_VERSION)
    #error "Software Patch Version Number mismatch between Ocu.c and Ocu_Ipw_Types.h"
#endif

/**********************************************************************************************************************
                                             GLOBAL VARIABLE
***********************************************************************************************************************/
/** @defgroup OCU_Variable
  @{
*/
#define OCU_START_SEC_VAR_NO_INIT_UNSPECIFIED
#include "Ocu_MemMap.h"

/** The array contains the OCU channels operation state .
    The channel state: OCU_CH_STS_UNINIT, OCU_CH_STS_INIT, 
    OCU_CH_STS_STOP, OCU_CH_STS_RUN */
VAR(Ocu_ChStsType, OCU_VAR) g_ocuChSts[OCU_CH_COUNT_SUPPORTED];

#define OCU_STOP_SEC_VAR_NO_INIT_UNSPECIFIED
#include "Ocu_MemMap.h"

#define OCU_START_SEC_VAR_NO_INIT_BOOLEAN
#include "Ocu_MemMap.h"

/** The array contains the OCU channels Notification enabled states: TRUE, FALSE */
VAR(boolean, OCU_VAR) g_ocuNotifiEnSts[OCU_CH_COUNT_SUPPORTED];

#define OCU_STOP_SEC_VAR_NO_INIT_BOOLEAN
#include "Ocu_MemMap.h"

#define OCU_START_SEC_VAR_INIT_UNSPECIFIED
#include "Ocu_MemMap.h"

#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)
    /** The current state of the Ocu moudle */
    static VAR(Ocu_GlobStsType, OCU_VAR) g_ocuGlobSts = OCU_GLOBAL_STS_UNINIT;
#endif  /* {if ((STD_ON == OCU_DEV_ERR_DETECT_ENABLE)} */

/** The pointer of the high level configuration structure that is valid only when the OCU is in the initialized state */
static P2CONST(Ocu_ConfigType, OCU_VAR, OCU_APPL_CONST) g_ocuConfigPtr = NULL_PTR;

#define OCU_STOP_SEC_VAR_INIT_UNSPECIFIED
#include "Ocu_MemMap.h"
/**@} end of group OCU_Variable */
/**********************************************************************************************************************
                                                  LOCAL FUNCTION
***********************************************************************************************************************/
/** @defgroup OCU_Fuctions
  @{
*/
#define OCU_START_SEC_CODE
#include "Ocu_MemMap.h"

#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)
/*!
 * @brief         The function is to verify that an API(Ocu_Init expected) should ensure 
 *                it is called after the Ocu driver is initialized, and the channel id
 *                should in configuration range, otherwise the API should report an error 
 *                to the DET moudle.
 *
 * @param[in]     OcuChannelNumber     The Ocu channel id
 * @param[in]     FunctionServiceId    The function service id
 *
 * @retval        E_OK: the funciton is in expected state, and it could continue executing.
 *                E_NOT_OK:the function is in unexpected state, and it should stop execute.
 */
LOCAL_INLINE FUNC(Std_ReturnType, OCU_CODE) Ocu_VerifyChConfigParameter(\
    VAR(Ocu_ChannelType, AUTOMATIC) OcuChannelNumber, VAR(uint8, AUTOMATIC) FunctionServiceId)
{
    VAR(Std_ReturnType, AUTOMATIC) returnValue = (Std_ReturnType)E_NOT_OK;
    VAR(boolean, AUTOMATIC) boolTemp = (boolean)FALSE;
    boolTemp = (boolean)(OCU_GLOBAL_STS_UNINIT == g_ocuGlobSts);

    if ((boolean)FALSE == boolTemp)
    {
        if(g_ocuConfigPtr->ocuChCnt <= OcuChannelNumber)
        {
            (void)Det_ReportError((uint16)OCU_H_MODULE_ID, (uint8)OCU_INSTANCE_ID, (uint8)FunctionServiceId,\
                                  (uint8)OCU_E_PARAM_INVALID_CHANNEL);
        }
        else
        {
            returnValue = (Std_ReturnType)E_OK;
        }
    }
    else
    {
        (void)Det_ReportError((uint16)OCU_H_MODULE_ID, (uint8)OCU_INSTANCE_ID, (uint8)FunctionServiceId,\
                              (uint8)OCU_E_UNINIT);
    }
    
    return returnValue;    
}

#endif /* {if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)} */

#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)
#if (STD_ON == OCU_SET_PIN_ACTION_API)
/*!
 * @brief         The function is to verify that the action of channel linked pin is valid, otherwise the API 
 *                should report an error to the DET moudle.
 *
 * @param[in]     OcuLinkPinAct     The action of channel linked pin
 *
 * @retval        E_OK: The action of channel linked pin is valid.
 *                E_NOT_OK: The action of channel linked pin is invalid.
 */
LOCAL_INLINE  FUNC(Std_ReturnType, OCU_CODE) Ocu_VerifyLinkPinAct(VAR(Ocu_PinActionType, AUTOMATIC) OcuLinkPinAct)
{  
    VAR(Std_ReturnType, AUTOMATIC) returnValue = (Std_ReturnType)E_OK;    
    
    if((OCU_DISABLE != OcuLinkPinAct) || (OCU_SET_HIGH != OcuLinkPinAct) || (OCU_SET_LOW != OcuLinkPinAct) || 
       (OCU_TOGGLE != OcuLinkPinAct) || (OCU_FORCE_LOW != OcuLinkPinAct) || (OCU_FORCE_HIGH != OcuLinkPinAct) ||
       (OCU_PWM1 != OcuLinkPinAct) || (OCU_PWM2 != OcuLinkPinAct))
    {
        (void)Det_ReportError((uint16)OCU_H_MODULE_ID, (uint8)OCU_INSTANCE_ID, (uint8)OCU_SET_PIN_ACTION_SID, \
                  (uint8)OCU_E_PARAM_INVALID_ACTION);

        returnValue = (Std_ReturnType)E_NOT_OK; 
    }
    else
    {
        /* do nothing */
    }
    return returnValue;  
}  
#endif  /* {if (STD_ON == OCU_SET_PIN_ACTION_API)} */

#if (STD_ON == OCU_NOTIFICATION_EN)
/*!
 * @brief         The function is to verify that the channel notificaiton callback is valid, otherwise the API 
 *                should report an error to the DET moudle.
 *
 * @param[in]     OcuChannelNumber     The Ocu channel id
 * @param[in]     FunctionServiceId    The function service id
 *
 * @retval        E_OK: The channel notificaiton callback is valid.
 *                E_NOT_OK: The channel notification callback is invalid.
 */
LOCAL_INLINE  FUNC(Std_ReturnType, OCU_CODE) Ocu_VerifyChNotifi(VAR(Ocu_ChannelType, AUTOMATIC) OcuChannelNumber,\
    VAR(uint8, AUTOMATIC) FunctionServiceId)
{
    VAR(Std_ReturnType, AUTOMATIC) returnValue = (Std_ReturnType)E_NOT_OK;
    
    if(NULL_PTR == (*g_ocuConfigPtr->ocuChConfigPtr)[OcuChannelNumber].ocuChNotiPtr)
    {
        (void)Det_ReportError((uint16)OCU_H_MODULE_ID, (uint8)OCU_INSTANCE_ID, (uint8)FunctionServiceId, (uint8)OCU_E_NO_VALID_NOTIF);
    }
    else
    {
        returnValue = (Std_ReturnType)E_OK;
    }

    return returnValue;   
}
#endif /* {if (STD_ON == OCU_NOTIFICATION_EN)} */ 

/*!
 * @brief         The function is to verify that Ocu_Init API should ensure it is called with a valid 
 *                parameter, otherwise the API should report an error to the DET moudle.
 *
 * @param[in]     OcuConfigPtr     The pointer of configuration parameter.
 *
 * @retval        E_OK: The input parameter is valid, and it could continue executing.
 *                E_NOT_OK: The input parameter is invalid, and it should stop execute.
 */
LOCAL_INLINE  FUNC(Std_ReturnType, OCU_CODE) Ocu_VerifyInitParam(P2CONST(Ocu_ConfigType, AUTOMATIC, OCU_APPL_CONST) OcuConfigPtr)
{
    VAR(Std_ReturnType, AUTOMATIC) returnValue = (Std_ReturnType)E_OK;

   if(NULL_PTR == OcuConfigPtr)
   {
        (void)Det_ReportError((uint16)OCU_H_MODULE_ID, (uint8) OCU_INSTANCE_ID, (uint8)OCU_INIT_SID,\
                              (uint8)OCU_E_INIT_FAILED);
         
        returnValue = (Std_ReturnType)E_NOT_OK;  
   }
   else
   {
       /* do nothing */
   }

    return returnValue;
}

/*!
 * @brief         The function is to verify that the API should ensure it is called with a valid 
 *                channel state, otherwise the API should report an error to the DET moudle.
 *
 * @param[in]     OcuChannelNumber     The Ocu channel id
 * @param[in]     FunctionServiceId    The function service id
 *
 * @retval        E_OK: The channel state is valid.
 *                E_NOT_OK: The channel state is invalid.
 */
LOCAL_INLINE  FUNC(Std_ReturnType, OCU_CODE) Ocu_VerifyChOperateSts(\
    VAR(Ocu_ChannelType, AUTOMATIC) OcuChannelNumber,\
    VAR(uint8, AUTOMATIC) FunctionServiceId)
{
    VAR(Std_ReturnType, AUTOMATIC) returnValue = (Std_ReturnType)E_OK;
    VAR(boolean, AUTOMATIC) boolTemp = (boolean)FALSE;
    boolTemp = (boolean)(OCU_CH_STS_RUN == g_ocuChSts[OcuChannelNumber]);

    if ((boolean)TRUE == boolTemp)
    {
      switch (FunctionServiceId)
      {
        case (uint8)OCU_START_CHANNEL_SID:
        {
            (void)Det_ReportError((uint16)OCU_H_MODULE_ID, (uint8)OCU_INSTANCE_ID, (uint8)OCU_START_CHANNEL_SID,\
                                  (uint8)OCU_E_BUSY);
            
            returnValue = (Std_ReturnType)E_NOT_OK;          
            break;
        }

#if (STD_ON == OCU_SET_PIN_STATE_API)
        case (uint8)OCU_SET_PIN_STATE_SID:
        {
            (void)Det_ReportError((uint16)OCU_H_MODULE_ID, (uint8)OCU_INSTANCE_ID, (uint8)OCU_SET_PIN_STATE_SID,\
                                  (uint8)OCU_E_PARAM_INVALID_STATE);
             
            returnValue = (Std_ReturnType)E_NOT_OK;
            break;
        }     
#endif 

#if (STD_ON == OCU_DEINIT_API_ENABLE)
        case (uint8)OCU_DEINIT_SID:
        {
            (void)Det_ReportError((uint16)OCU_H_MODULE_ID, (uint8)OCU_INSTANCE_ID, (uint8)OCU_DEINIT_SID,\
                                  (uint8)OCU_E_PARAM_INVALID_STATE);
             
            returnValue = (Std_ReturnType)E_NOT_OK; 
            break;
        }
#endif
      default:
        {
           /* do nothing */
        }
        break;
      }
    }
    else
    {
        /* do nothing */
    }
    
    if((uint8)OCU_STOP_CHANNEL_SID == FunctionServiceId)
    {
        if(OCU_CH_STS_STOP == g_ocuChSts[OcuChannelNumber])
        {
            returnValue = (Std_ReturnType)E_NOT_OK;  
        }
        else
        {
            /* do nothing */
        }
    }
    else
    {
        /* do nothing */
    }

    return returnValue;
}

#if ((STD_ON == OCU_SET_RELATIVE_THRESHOLD_API) || (STD_ON == OCU_SET_ABSOLUTE_THRESHOLD_API))
/*!
 * @brief         The function is to verify that the channel compare value is valid, otherwise the 
 *                API should report an error to the DET moudle.
 *
 * @param[in]     OcuChannelNumber     The Ocu channel id
 * @param[in]     FunctionServiceId    The function service id
 * @param[in]     ChannelCompareValue  The channel compare value
 *
 * @retval        E_OK: The channel compare value is valid.
 *                E_NOT_OK: The channel compare value is invalid.
 */
LOCAL_INLINE  FUNC(Std_ReturnType, OCU_CODE) Ocu_VerifyChCompaVal(\
    VAR(Ocu_ChannelType, AUTOMATIC) OcuChannelNumber,\
    VAR(Ocu_ValueType, AUTOMATIC) ChannelCompareValue,\
    VAR(uint8, AUTOMATIC) FunctionServiceId)
{
    VAR(Std_ReturnType, AUTOMATIC) returnValue = (Std_ReturnType)E_NOT_OK;
    VAR(Ocu_ValueType, AUTOMATIC) ocuMaxCounterValue = 0;
    
    ocuMaxCounterValue = (uint16)Ocu_Ipw_GetMaxCntVal(OcuChannelNumber);
    
    if((uint32)ChannelCompareValue <= (uint32)ocuMaxCounterValue)
    {
        returnValue = (Std_ReturnType)E_OK;
    }
    else
    {
        (void)Det_ReportError((uint16)OCU_H_MODULE_ID, (uint8)OCU_INSTANCE_ID, (uint8)FunctionServiceId, (uint8)OCU_E_PARAM_INVALID_VALUE);
    }

    return returnValue;   

}
#endif  /* {if ((STD_ON == OCU_SET_RELATIVE_THRESHOLD_API) || (STD_ON == OCU_SET_ABSOLUTE_THRESHOLD_API))} */

#if ((STD_ON == OCU_SET_PIN_ACTION_API) || (STD_ON == OCU_SET_PIN_STATE_API))
/*!
 * @brief         The function is to verify that the channel linked pin is enabled, otherwise the API 
 *                should report an error to the DET moudle.
 *
 * @param[in]     OcuChannelNumber     The Ocu channel id
 * @param[in]     FunctionServiceId    The function service id
 *
 * @retval        E_OK: The channel linked pin is enabled.
 *                E_NOT_OK: The channel linked pin is disabled.
 */
LOCAL_INLINE  FUNC(Std_ReturnType, OCU_CODE) Ocu_VerifyLinkPinEnSts(\
    VAR(Ocu_ChannelType, AUTOMATIC) OcuChannelNumber,\
    VAR(uint8, AUTOMATIC) FunctionServiceId)
{
    VAR(Std_ReturnType, AUTOMATIC) returnValue = (Std_ReturnType)E_NOT_OK;
    VAR(boolean, AUTOMATIC) linkedPinEnableStatus = 0;
    
    linkedPinEnableStatus = (*g_ocuConfigPtr->ocuChConfigPtr)[OcuChannelNumber].ocuEnChOutPin;

    if((boolean)TRUE == linkedPinEnableStatus)
    {
        returnValue = (Std_ReturnType)E_OK;
    }
    else
    {
        (void)Det_ReportError((uint16)OCU_H_MODULE_ID, (uint8)OCU_INSTANCE_ID, (uint8)FunctionServiceId, (uint8)OCU_E_PARAM_NO_PIN);
    }
    
    return returnValue;  
}
#endif  /* {if ((STD_ON == OCU_SET_PIN_ACTION_API) || (STD_ON == OCU_SET_PIN_STATE_API))} */

#if (STD_ON == OCU_SET_PIN_STATE_API)  
/*!
 * @brief         The function is to verify the linked pin state is valid, otherwise the API should 
 *                report an error to the DET moudle.
 *
 * @param[in]     OcuLinkedPinState     The state of linked pin.
 *
 * @retval        E_OK: The input parameter is valid.
 *                E_NOT_OK: The input parameter is invalid.
 */
LOCAL_INLINE  FUNC(Std_ReturnType, OCU_CODE) Ocu_VerifyLinkPinSts(VAR(Ocu_PinStateType, AUTOMATIC) OcuLinkedPinState)
{
    VAR(Std_ReturnType, AUTOMATIC) returnValue = (Std_ReturnType)E_NOT_OK;
    
    if(OCU_LOW != OcuLinkedPinState)
    {
        if(OCU_HIGH != OcuLinkedPinState)
        {
            (void)Det_ReportError((uint16)OCU_H_MODULE_ID, (uint8)OCU_INSTANCE_ID, (uint8)OCU_SET_PIN_STATE_SID, (uint8)OCU_E_PARAM_INVALID_STATE);
        }
        else
        {
            returnValue = (Std_ReturnType)E_OK;
        }
    }
    else
    {
        returnValue = (Std_ReturnType)E_OK;
    }

    return returnValue;   
}
#endif  /* {if (STD_ON == OCU_SET_PIN_STATE_API)} */
#endif /* {if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)} */    

#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)
/*!
 * @brief         The function is to verify that an API(Ocu_Init expected) should ensure 
 *                it is called after the Ocu driver is initialized, and the API Ocu_Init 
 *                should be called before the Ocu driver is initialized,otherwise the API 
 *                should report an error to the DET moudle.
 *
 * @param[in]     FunctionServiceId       The service id of the function.
 *
 * @retval        E_OK: the funciton is in expected state, and it could continue executing.
 *                E_NOT_OK:the function is in unexpected state, and it should stop execute.
 */
LOCAL_INLINE FUNC(Std_ReturnType, OCU_CODE) Ocu_VerifyApiInvoke(VAR(uint8, AUTOMATIC) FunctionServiceId)
{
    VAR(Std_ReturnType, AUTOMATIC) returnValue = (Std_ReturnType)E_NOT_OK;
    
    switch (g_ocuGlobSts)
    {
        case OCU_GLOBAL_STS_UNINIT:            
            if((uint8)OCU_INIT_SID == FunctionServiceId)
            {
                returnValue = (Std_ReturnType)E_OK;
            }
            else
            {
                (void)Det_ReportError((uint16)OCU_H_MODULE_ID, (uint8)OCU_INSTANCE_ID, (uint8)FunctionServiceId, (uint8)OCU_E_UNINIT);
            }
            break;
        default:
            if((uint8)OCU_INIT_SID != FunctionServiceId)
            {
                returnValue = (Std_ReturnType)E_OK;
            }            
            else
            {
                (void)Det_ReportError((uint16)OCU_H_MODULE_ID, (uint8)OCU_INSTANCE_ID, (uint8)FunctionServiceId, (uint8)OCU_E_ALREADY_INITIALIZED);
            }
            break;
    }

    return returnValue;
}

/*!
 * @brief         The function is to refresh the Ocu state according to the return value of the API 
 *                Ocu_VerifyApiInvoke.
 *
 * @param[in]     FunctionServiceId      The function service id
 * @param[in]     IsValidFunctionCall    The previous function call validated state
 *
 * @retval         None
 */
LOCAL_INLINE  FUNC(void, OCU_CODE) Ocu_FinishVerifyApiInvoke(VAR(Std_ReturnType, AUTOMATIC) ApiValidFlag,\
    VAR(uint8,          AUTOMATIC) FunctionServiceId)
{
    VAR(boolean, AUTOMATIC) boolTemp = (boolean)FALSE;
    boolTemp = (boolean)((Std_ReturnType)E_OK == ApiValidFlag);

    if ((boolean)TRUE == boolTemp)
    {        
        switch (FunctionServiceId)
        {
            case (uint8)OCU_DEINIT_SID:
                 g_ocuGlobSts = OCU_GLOBAL_STS_UNINIT;
                 break;        
            default:
                g_ocuGlobSts = OCU_GLOBAL_STS_IDLE;
                break;
        }
    }
    else
    {
        /* do nothing */
    }
}
#endif /* {if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)} */

/**********************************************************************************************************************
                                                    GLOBAL FUNCTION
***********************************************************************************************************************/
#if (STD_ON == OCU_SET_PIN_STATE_API)
/*!
 * @brief         The function is to set the pin state linked to the Ocu channel.
 *
 * @param[in]     ChannelNumber     The Ocu channel id
 * @param[in]     PinState    The output pin state linked to the Ocu channel
 *
 * @retval        void
 */
FUNC(void, OCU_CODE) Ocu_SetPinState(VAR(Ocu_ChannelType,  AUTOMATIC) ChannelNumber,\
    VAR(Ocu_PinStateType, AUTOMATIC) PinState)
{
#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)
    if(((Std_ReturnType)E_OK == Ocu_VerifyChConfigParameter(ChannelNumber, (uint8)OCU_SET_PIN_STATE_SID)) && \
       ((Std_ReturnType)E_OK == Ocu_VerifyLinkPinSts(PinState)) && \
       ((Std_ReturnType)E_OK == Ocu_VerifyChOperateSts(ChannelNumber, (uint8)OCU_SET_PIN_STATE_SID)) && \
       ((Std_ReturnType)E_OK == Ocu_VerifyLinkPinEnSts(ChannelNumber, (uint8)OCU_SET_PIN_STATE_SID)))
    {
#endif

        Ocu_Ipw_SetPinState(ChannelNumber, PinState);

#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)
    }
    else
    {
        /* do nothing */
    }
#endif
}
#endif /* {if (STD_ON == OCU_SET_PIN_STATE_API)} */

#if (STD_ON == OCU_SET_CLOCK_MODE_API_ENABLE)
/*!
 * @brief         The function is to set the prescaler that divides the OCU channels
 *                clock frequency.
 *
 * @param[in]     OcuPrescalerType      The clock prescaler type
 *
 * @retval        void
 */
FUNC(void, OCU_CODE) Ocu_SetClkPsc(VAR(Ocu_TmrPrescalerType, AUTOMATIC) OcuPrescalerType)
{
#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)
    VAR(Std_ReturnType, AUTOMATIC)  functionCallIsValid = (Std_ReturnType)E_NOT_OK;
    
    if((Std_ReturnType)E_OK == Ocu_VerifyApiInvoke((uint8)OCU_SET_CLOCK_MODE_SID))
    {
        functionCallIsValid = (Std_ReturnType)E_OK;
#endif
        
        Ocu_Ipw_SetClkPsc(&g_ocuConfigPtr->ocuHwConfig, OcuPrescalerType);

#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)
    }
    else
    {
        /* do nothing */
    }

    Ocu_FinishVerifyApiInvoke(functionCallIsValid, (uint8)OCU_SET_CLOCK_MODE_SID);
#endif
}
#endif /* {if (STD_ON == OCU_SET_CLOCK_MODE_API_ENABLE)} */

#if (STD_ON == OCU_SET_RELATIVE_THRESHOLD_API)
/*!
 * @brief         The function is to set the value of the channel relative threshold with an input data.
 *
 * @param[in]     ChannelNumber    The Ocu channel id
 * @param[in]     RelativeValue    The relative compare value
 *
 * @retval        OCU_CM_OUT_REF_INTERVAL: The compare match event will not occur inside the current
 *                reference interval.
 *                OCU_CM_IN_REF_INTERVAL: The compare match event will occur inside the current reference interval.
 */
FUNC(Ocu_ReturnType, OCU_CODE) Ocu_SetRelativeThreshold(VAR(Ocu_ChannelType, AUTOMATIC) ChannelNumber,\
   VAR(Ocu_ValueType,   AUTOMATIC) RelativeValue)
{
    VAR(Ocu_ReturnType, AUTOMATIC)  compareEventStatus = OCU_CM_OUT_REF_INTERVAL;

#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)
    if(((Std_ReturnType)E_OK == Ocu_VerifyChConfigParameter(ChannelNumber, (uint8)OCU_SET_RELATIVE_THRESHOLD_SID)) && \
       ((Std_ReturnType)E_OK == Ocu_VerifyChCompaVal(ChannelNumber, RelativeValue, (uint8)OCU_SET_RELATIVE_THRESHOLD_SID)))
    {
#endif

        compareEventStatus = Ocu_Ipw_SetRelThrd(ChannelNumber, RelativeValue);   

#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)
    }
    else
    {
        /* do nothing */
    }
#endif

    return compareEventStatus;
}
#endif /* {if (STD_ON == OCU_SET_RELATIVE_THRESHOLD_API)} */

#if (STD_ON == OCU_SET_ABSOLUTE_THRESHOLD_API)
/*!
 * @brief         The function is to set the value of the channel absolute threshold with an input data.
 *
 * @param[in]     ChannelNumber    The Ocu channel id
 * @param[in]     ReferenceValue   The channel reference compare value
 * @param[in]     AbsoluteValue    The absolute compare value
 *
 * @retval        OCU_CM_OUT_REF_INTERVAL: The compare match event will not occur inside the current
 *                reference interval.
 *                OCU_CM_IN_REF_INTERVAL: The compare match event will occur inside the current reference interval.
 */
FUNC(Ocu_ReturnType, OCU_CODE) Ocu_SetAbsoluteThreshold(VAR(Ocu_ChannelType, AUTOMATIC) ChannelNumber,\
   VAR(Ocu_ValueType, AUTOMATIC) ReferenceValue,\
   VAR(Ocu_ValueType, AUTOMATIC) AbsoluteValue)
{
    VAR(Ocu_ReturnType, AUTOMATIC)  compareEventStatus = OCU_CM_OUT_REF_INTERVAL;

#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)
    if(((Std_ReturnType)E_OK == Ocu_VerifyChConfigParameter(ChannelNumber, (uint8)OCU_SET_ABSOLUTE_THRESHOLD_SID)) && \
       ((Std_ReturnType)E_OK == Ocu_VerifyChCompaVal(ChannelNumber, ReferenceValue, (uint8)OCU_SET_ABSOLUTE_THRESHOLD_SID)) && \
       ((Std_ReturnType)E_OK == Ocu_VerifyChCompaVal(ChannelNumber, AbsoluteValue, (uint8)OCU_SET_ABSOLUTE_THRESHOLD_SID)))
    {
#endif
        compareEventStatus = Ocu_Ipw_SetAbsThrd(ChannelNumber, ReferenceValue, AbsoluteValue); 

#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)
    }
    else
    {
        /* do nothing */
    }
#endif

    return compareEventStatus;
}
#endif /* {if (STD_ON == OCU_SET_ABSOLUTE_THRESHOLD_API)} */

#if (STD_ON == OCU_NOTIFICATION_EN)
/*!
 * @brief         The notificaiton function.
 *
 * @param[in]     OcuHwChannel      The Ocu HW channel
 *
 * @retval        void
 */
FUNC(void, OCU_CODE) Ocu_Notification(VAR(Ocu_ChannelType, AUTOMATIC) OcuHwChannel)
{
    VAR(uint8, AUTOMATIC) ocuLogicChannel = 0;
    VAR(Ocu_NotificationType, AUTOMATIC) ocuNotificationPtr = NULL_PTR;
    
    switch ((uint32)g_ocuConfigPtr)
    {
        case (uint32)0:
            break;
    
        default:
            {
                ocuLogicChannel = (uint8)((*g_ocuConfigPtr->ocuHwToLogicChMapPtr)[OcuHwChannel]);
                ocuNotificationPtr = (*g_ocuConfigPtr->ocuChConfigPtr)[ocuLogicChannel].ocuChNotiPtr;

                if(NULL_PTR != ocuNotificationPtr)
                {
                    if((boolean)TRUE == g_ocuNotifiEnSts[ocuLogicChannel])
                    {
                        ocuNotificationPtr();
                    }
                    else
                    {
                        /* do nothing */
                    }
                }
                else
                {
                    /* do nothing */
                }                
                break;
            }
            
    }
}
#endif /* {if (STD_ON == OCU_NOTIFICATION_EN)} */

#if (STD_ON == OCU_VERSION_INFO_API)
/*!
 * @brief         The function is to get the Ocu version infomation.
 *
 * @param[in]     versioninfo      The pointer of the Ocu version information
 *
 * @retval        void
 */
FUNC(void, OCU_CODE) Ocu_GetVersionInfo(P2VAR(Std_VersionInfoType , AUTOMATIC, OCU_APPL_DATA) versioninfo)
{
#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)

    switch ((uint32)versioninfo)
    {
        case (uint32)0:
            (void)Det_ReportError((uint16)OCU_H_MODULE_ID, (uint8)OCU_INSTANCE_ID, (uint8)OCU_GET_VERSIONINFO_SID,\
            (uint8)OCU_E_PARAM_POINTER);
            break;
    
        default:
        {
#endif
            (versioninfo)->vendorID = (uint16)OCU_H_VENDOR_ID;
            (versioninfo)->moduleID = (uint16)OCU_H_MODULE_ID;

            (versioninfo)->sw_major_version = (uint8)OCU_H_SW_MAJOR_VERSION;
            (versioninfo)->sw_minor_version = (uint8)OCU_H_SW_MINOR_VERSION;
            (versioninfo)->sw_patch_version = (uint8)OCU_H_SW_PATCH_VERSION;

#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)
            break;
        }
    }   
#endif
}
#endif /* {if (STD_ON == OCU_VERSION_INFO_API)} */

/*!
 * @brief          This function initializes the Ocu driver.
 *
 * @param[in]      ConfigPtr     The pointer of the Ocu configuration parameter.
 *
 * @retval         None
 */
FUNC(void, OCU_CODE) Ocu_Init(P2CONST(Ocu_ConfigType, AUTOMATIC, OCU_APPL_CONST) ConfigPtr)
{
    VAR(Ocu_ChannelType, AUTOMATIC) ocuChannelNumber = 0U;
  
#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)
    VAR(Std_ReturnType, AUTOMATIC) apiValidFlag = (Std_ReturnType)E_NOT_OK;
    if(((Std_ReturnType)E_OK == Ocu_VerifyApiInvoke((uint8)OCU_INIT_SID)) && \
       ((Std_ReturnType)E_OK == Ocu_VerifyInitParam(ConfigPtr)))
    {
        apiValidFlag = (Std_ReturnType)E_OK;
#endif
        g_ocuConfigPtr = ConfigPtr;
        while (ocuChannelNumber < OCU_CH_COUNT_SUPPORTED)
        {
            g_ocuChSts[ocuChannelNumber] = OCU_CH_STS_INIT;
            g_ocuNotifiEnSts[ocuChannelNumber] = (boolean)FALSE;
            ocuChannelNumber++;
        }
        Ocu_Ipw_Init(&g_ocuConfigPtr->ocuHwConfig);

#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)
    }
    else
    {
        /* do nothing */
    }

    Ocu_FinishVerifyApiInvoke(apiValidFlag, (uint8)OCU_INIT_SID);
#endif

}

#if (STD_ON == OCU_DEINIT_API_ENABLE)
/*!
 * @brief          The function deinitializes the Ocu moudle.
 *
 * @param[in]      void
 *
 * @retval         void
 */
FUNC(void, OCU_CODE) Ocu_DeInit(void)
{
    VAR(Ocu_ChannelType, AUTOMATIC) ocuChannelNumber = 0U;

#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)

    VAR(Std_ReturnType, AUTOMATIC) apiValidFlag = (Std_ReturnType)E_NOT_OK;

    if((Std_ReturnType)E_OK == Ocu_VerifyApiInvoke((uint8)OCU_DEINIT_SID))
    {
        apiValidFlag = (Std_ReturnType)E_OK;

        while (ocuChannelNumber < OCU_CH_COUNT_SUPPORTED)
        {            
            switch ((Std_ReturnType)Ocu_VerifyChOperateSts(ocuChannelNumber, (uint8)OCU_DEINIT_SID))
            {
                case (Std_ReturnType)E_NOT_OK:
                    apiValidFlag = (Std_ReturnType)E_NOT_OK;
                    break;
                default:
                    {
                        /* do nothing */
                    } 
                    break;
            }

            ocuChannelNumber++;
        }

        switch (apiValidFlag)
        {
            case (Std_ReturnType)E_OK:
            {
#endif
                Ocu_Ipw_DeInit(&g_ocuConfigPtr->ocuHwConfig);

#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)

                ocuChannelNumber = 0U;
#endif

                while (ocuChannelNumber < OCU_CH_COUNT_SUPPORTED)
                {
                    g_ocuChSts[ocuChannelNumber] = OCU_CH_STS_UNINIT;
                    g_ocuNotifiEnSts[ocuChannelNumber] = (boolean)FALSE;

                    ocuChannelNumber++;
                }

                g_ocuConfigPtr = NULL_PTR;

#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)
                break;
            }
            default:
                {
                    /* do nothing */
                }
                break;
        }
    }
    else
    {
        /* do nothing */
    }

    Ocu_FinishVerifyApiInvoke(apiValidFlag, (uint8)OCU_DEINIT_SID); 
#endif
}
#endif /* {if (STD_ON == OCU_DEINIT_API_ENABLE)} */

/*!
 * @brief          The function starts the OCU channel by allowing all
 *                 compare match configured actions to be performed.
 *
 * @param[in]      ChannelNumber     The Ocu channel id.
 *
 * @retval         void
 */
FUNC(void, OCU_CODE) Ocu_StartChannel(VAR(Ocu_ChannelType, AUTOMATIC) ChannelNumber)
{
#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)
    if(((Std_ReturnType)E_OK == Ocu_VerifyChConfigParameter(ChannelNumber, (uint8)OCU_START_CHANNEL_SID)) && \
       ((Std_ReturnType)E_OK == Ocu_VerifyChOperateSts(ChannelNumber, (uint8)OCU_START_CHANNEL_SID)))
    {
#endif
       
        g_ocuChSts[ChannelNumber] = OCU_CH_STS_RUN;
        Ocu_Ipw_StartCh(ChannelNumber); 

#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)       
    }
    else
    {
        /* do nothing */
    }
#endif    
}

/*!
 * @brief          The function stops the OCU channel.
 *
 * @param[in]      ChannelNumber     The Ocu channel id.
 *
 * @retval         void
 */
FUNC(void, OCU_CODE) Ocu_StopChannel(VAR(Ocu_ChannelType, AUTOMATIC) ChannelNumber)
{
#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)
    if(((Std_ReturnType)E_OK == Ocu_VerifyChConfigParameter(ChannelNumber, (uint8)OCU_STOP_CHANNEL_SID)) && \
       ((Std_ReturnType)E_OK == Ocu_VerifyChOperateSts(ChannelNumber, (uint8)OCU_STOP_CHANNEL_SID)))
    {
#endif

        g_ocuChSts[ChannelNumber] = OCU_CH_STS_STOP;       
        Ocu_Ipw_StopCh(ChannelNumber); 

#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)
    }
    else
    {
        /* do nothing */
    }
#endif
}

#if (STD_ON == OCU_SET_PIN_ACTION_API)
/*!
 * @brief         The function is to set the pin action linked to the Ocu channel.
 *
 * @param[in]     ChannelNumber      The Ocu channel id
 * @param[in]     PinAction    The output pin action linked to the Ocu channel
 *
 * @retval        void
 */
FUNC(void, OCU_CODE) Ocu_SetPinAction(VAR(Ocu_ChannelType,   AUTOMATIC) ChannelNumber,\
    VAR(Ocu_PinActionType, AUTOMATIC) PinAction)
{
#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)
    if(((Std_ReturnType)E_OK == Ocu_VerifyChConfigParameter(ChannelNumber, (uint8)OCU_SET_PIN_ACTION_SID)) && \
       ((Std_ReturnType)E_OK == Ocu_VerifyLinkPinAct(PinAction)) && \
       ((Std_ReturnType)E_OK == Ocu_VerifyLinkPinEnSts(ChannelNumber, (uint8)OCU_SET_PIN_ACTION_SID)))
    {
#endif

        (OCU_CH_STS_RUN != g_ocuChSts[ChannelNumber]) ? (Ocu_Ipw_SetPinAction(ChannelNumber, PinAction, (boolean)FALSE)) : \
        (Ocu_Ipw_SetPinAction(ChannelNumber, PinAction, (boolean)TRUE));

#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)
    }
    else
    {
        /* do nothing */
    }
#endif
}
#endif /* {if (STD_ON == OCU_SET_PIN_ACTION_API)} */

#if (STD_ON == OCU_GET_COUNTER_API)
/*!
 * @brief         The function is to get the current value of the counter.
 *
 * @param[in]     ChannelNumber      The Ocu channel id
 *
 * @retval        Ocu_ValueType         The current value of the counter
 */
FUNC(Ocu_ValueType, OCU_CODE) Ocu_GetCounter(VAR(Ocu_ChannelType, AUTOMATIC) ChannelNumber)
{
    VAR(Ocu_ValueType, AUTOMATIC) returnValue = (Ocu_ValueType)0U;      

#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)
    switch ((Std_ReturnType)Ocu_VerifyChConfigParameter(ChannelNumber, (uint8)OCU_GET_COUNTER_SID))
    {
        case (Std_ReturnType)E_OK:
#endif
            returnValue = Ocu_Ipw_GetCnt(ChannelNumber);

#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)
            break;
        default:
            {
                /* do nothing */
            }
            break;
    }
#endif

    return (Ocu_ValueType)returnValue;
}
#endif /* {if (STD_ON == OCU_GET_COUNTER_API)} */

#if (STD_ON == OCU_NOTIFICATION_EN)
/*!
 * @brief         The function is to disable the channel notification.
 *
 * @param[in]     ChannelNumber      The Ocu channel id
 *
 * @retval        void
 */
FUNC(void, OCU_CODE) Ocu_DisableNotification(VAR(Ocu_ChannelType, AUTOMATIC) ChannelNumber)
{
#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)
    if(((Std_ReturnType)E_OK == Ocu_VerifyChConfigParameter(ChannelNumber, (uint8)OCU_DISABLE_NOTIFICATION_SID)) && \
       ((Std_ReturnType)E_OK == Ocu_VerifyChNotifi(ChannelNumber, (uint8)OCU_DISABLE_NOTIFICATION_SID)))
    {
#endif

        g_ocuNotifiEnSts[ChannelNumber] = (boolean)FALSE;

#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)
    }
    else
    {
        /* do nothing */
    }
#endif 
}
#endif /* {if (STD_ON == OCU_NOTIFICATION_EN)} */

#if (STD_ON == OCU_NOTIFICATION_EN)
/*!
 * @brief         The function is to enable the channel notification.
 *
 * @param[in]     ChannelNumber      The Ocu channel id
 *
 * @retval        void
 */
FUNC(void, OCU_CODE) Ocu_EnableNotification(VAR(Ocu_ChannelType, AUTOMATIC) ChannelNumber)
{
#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)
    if(((Std_ReturnType)E_OK == Ocu_VerifyChConfigParameter(ChannelNumber, (uint8)OCU_ENABLE_NOTIFICATION_SID)) && \
       ((Std_ReturnType)E_OK == Ocu_VerifyChNotifi(ChannelNumber, (uint8)OCU_ENABLE_NOTIFICATION_SID)))
    {
#endif

        g_ocuNotifiEnSts[ChannelNumber] = (boolean)TRUE;

#if (STD_ON == OCU_DEV_ERR_DETECT_ENABLE)
    }
    else
    {
        /* do nothing */
    }
#endif
}
#endif /* {if (STD_ON == OCU_NOTIFICATION_EN)} */

#define OCU_STOP_SEC_CODE
#include "Ocu_MemMap.h"
/**@} end of group OCU_Fuctions */
#ifdef __cplusplus
}
#endif  /* ifdef __cplusplus */
/**@} end of group OCU_Driver */
/**@} end of group G32A10xx_StdPeriphDriver */
