/*!
* @file     Ocu.h
*
* @version  1.0.0
*
* @brief    TThe header of Ocu moudle API.
*           This header file includes the API definition 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.
*/

#ifndef OCU_H
#define OCU_H

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

#include "Std_Types.h"
#include "Ocu_Ipw_Types.h"
/** @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_H_VENDOR_ID                                    0x00C1U
/** Module ID of this module, as defined in the BSW Module List. */
#define OCU_H_MODULE_ID                                    0x007DU
/** Major version number of AUTOSAR release on which the appropriate implementation is based on. */ 
#define OCU_H_AR_RELEASE_MAJOR_VERSION                     0x04U
/** Minor version number of AUTOSAR release on which the appropriate implementation is based on. */
#define OCU_H_AR_RELEASE_MINOR_VERSION                     0x04U
/** Revision version number of AUTOSAR release on which the appropriate implementation is based on. */
#define OCU_H_AR_RELEASE_REVISION_VERSION                  0x00U
/** Major version number of the vendor specific implementation of the module. The numbering is vendor specific. */   
#define OCU_H_SW_MAJOR_VERSION                             0x01U
/** Minor version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define OCU_H_SW_MINOR_VERSION                             0x00U
/** Patch level version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define OCU_H_SW_PATCH_VERSION                             0x00U

/***********************************************************************************************************
                                  VERSION INFOMATION VERIFICATION
*************************************************************************************************************/
#ifdef ENABLE_INTERMODULE_MCAL_CHECK
/* Make sure the AUTOSAR major version number is the same between Ocu.h and Std_Types.h */
#if (OCU_H_AR_RELEASE_MAJOR_VERSION != STD_TYPES_H_AR_RELEASE_MAJOR_VERSION)
    #error "AUTOSAR Major Version Number mismatch between Ocu.h and Std_Types.h"
#endif
/* Make sure the AUTOSAR minor version number is the same between Ocu.h and Std_Types.h */
#if (OCU_H_AR_RELEASE_MINOR_VERSION != STD_TYPES_H_AR_RELEASE_MINOR_VERSION)
    #error "AUTOSAR Minor Version Number mismatch between Ocu.h and Std_Types.h"
#endif
#endif  
/* Make sure the vendor ids are the same between Ocu.h and Ocu_Ipw_Types.h */
#if (OCU_H_VENDOR_ID != OCU_IPW_TYPES_H_VENDOR_ID)
    #error "Vendor ids mismatch between Ocu.h and Ocu_Ipw_Types.h"
#endif  /* {if(OCU_H_VENDOR_ID != OCU_IPW_TYPES_H_VENDOR_ID)} */

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

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

/***********************************************************************************************************
                                            MACRO DEFINITION
************************************************************************************************************/
/** The hardware id of the OCU driver */
#define OCU_INSTANCE_ID                     (0U)
/** The error of calling the API without module initialization-AUTOSAR Standard */
#define OCU_E_UNINIT                        (0x02U)
/** The error of calling the API with an invalid channel Identifier-AUTOSAR Standard */
#define OCU_E_PARAM_INVALID_CHANNEL         (0x03U)
/** The error of calling API Ocu_SetPinState() with an invalid pin state or the channel 
 *   is in the RUNNING state-AUTOSAR Standard 
 */
#define OCU_E_PARAM_INVALID_STATE           (0x04U)
/** The error of calling API Ocu_SetPinAction() with an invalid pin action-AUTOSAR Standard */
#define OCU_E_PARAM_INVALID_ACTION          (0x05U)
/** The error of calling Ocu_DisableNotification() or Ocu_EnableNotification() with a channel 
 *   that a NULL pointer is configured as the notification callback-AUTOSAR Standard
 */
#define OCU_E_NO_VALID_NOTIF                (0x06U)
/** The error of calling API Ocu_Init() when the OCU driver has already been initialized-AUTOSAR Standard */
#define OCU_E_ALREADY_INITIALIZED           (0x07U)
/** The error of calling API Ocu_GetVersionInfo() with a NULL parameter-AUTOSAR Standard */
#define OCU_E_PARAM_POINTER                 (0x08U)
/** The error of calling API Ocu_StartChannel() with a channel that is in RUNNING state-AUTOSAR Standard */
#define OCU_E_BUSY                          (0x09U)
/** The error of calling Ocu_SetPinState() or Ocu_SetPinAction() with a invalid channel */
#define OCU_E_PARAM_NO_PIN                  (0x0AU)
/** The error of calling API Ocu_Init with wrong parameter-AUTOSAR Standard */
#define OCU_E_INIT_FAILED                   (0x0BU)
/**
 *   The error of calling Ocu_SetAbsoluteThreshold() or Ocu_SetRelativeThreshold() with a compare 
 *   match parameter more than maximum supported counter value for a channel-AUTOSAR Standard
 */
#define OCU_E_PARAM_INVALID_VALUE           (0x1BU)

/** The OCU channel status uninitialized */
#define OCU_CH_STS_UNINIT    ((Ocu_ChStsType)0)
/** The OCU channel status initialized */
#define OCU_CH_STS_INIT      ((Ocu_ChStsType)1)
/** The OCU channel status stopped */
#define OCU_CH_STS_STOP      ((Ocu_ChStsType)2)
/** The OCU channel status RUNNING */
#define OCU_CH_STS_RUN       ((Ocu_ChStsType)3)
/**@} end of group OCU_Macros */
/**********************************************************************************************************************
                                             ENUMERATION DEFINITION
***********************************************************************************************************************/
/** @defgroup OCU_Enumerations
  @{
*/
/**
 * @brief   Defines Ocu module functions service ids.
 */
typedef enum
{
    OCU_INIT_SID                       =    0U, //!< The service ID of Ocu_Init function
    OCU_DEINIT_SID                     =    1U, //!< The service ID of Ocu_DeInit function
    OCU_START_CHANNEL_SID              =    2U, //!< The service ID of Ocu_StartChannel function
    OCU_STOP_CHANNEL_SID               =    3U, //!< The service ID of Ocu_StopChannel function
    OCU_SET_PIN_STATE_SID              =    4U, //!< The service ID of Ocu_SetPinState function
    OCU_SET_PIN_ACTION_SID             =    5U, //!< The service ID of Ocu_SetPinAction function
    OCU_GET_COUNTER_SID                =    6U, //!< The service ID of Ocu_GetCounter function
    OCU_SET_ABSOLUTE_THRESHOLD_SID     =    7U, //!< The service ID of Ocu_SetAbsoluteThreshold function
    OCU_SET_RELATIVE_THRESHOLD_SID     =    8U, //!< The service ID of Ocu_SetRelativeThreshold function
    OCU_GET_VERSIONINFO_SID            =    9U, //!< The service ID of Ocu_GetVersionInfo function
    OCU_DISABLE_NOTIFICATION_SID       =    10U, //!< The service ID of Ocu_DisableNotification function
    OCU_ENABLE_NOTIFICATION_SID        =    11U, //!< The service ID of Ocu_EnableNotification function
    OCU_SET_CLOCK_MODE_SID             =    122U //!< The service ID of Ocu_SetClkPsc function
}Ocu_ServiceIdType;
/**@} end of group OCU_Enumerations */

/**********************************************************************************************************************
                                             OTHER TYPE DEFINITION
***********************************************************************************************************************/
/** @defgroup OCU_Typedef
  @{
*/
/** The channel status type. */
typedef uint8 Ocu_ChStsType;

/**@} end of group OCU_Typedef */

/** @defgroup OCU_Structure
  @{
*/
/**
 * @brief The channel configuration struct type.
 */
typedef struct
{
    VAR(boolean, OCU_VAR)  ocuEnChOutPin;  //!< Channel output pin enable
#if (STD_ON == OCU_NOTIFICATION_EN)
    CONST(Ocu_NotificationType, OCU_CONST) ocuChNotiPtr; //!< The pointer of notification function
#endif /* {if(STD_ON == OCU_NOTIFICATION_EN)} */
} Ocu_ChConfigType;

/**
 * @brief   The configuration structure of the Ocu-AUTOSAR Standard 
 */
typedef struct
{
    CONST(Ocu_ChannelType, OCU_CONST) ocuChCnt;  //!< The number of OCU channels
    CONST(Ocu_ChConfigType, OCU_CONST) (*ocuChConfigPtr)[];  //!< The pointer of the OCU channel configuration     
    CONST(Ocu_HwConfigType, OCU_CONST) ocuHwConfig;  //!< The OCU hardware configuration

#if (STD_ON == OCU_NOTIFICATION_EN)
    CONST(Ocu_ChannelType, OCU_CONST) (*ocuHwToLogicChMapPtr)[]; //!< Hardware channle to logical channle Map
#endif  /* {if (STD_ON == OCU_NOTIFICATION_EN)} */   
} Ocu_ConfigType;
/**@} end of group OCU_Structure */
/**********************************************************************************************************************
                                             GLOBAL VARIABLE
***********************************************************************************************************************/
/** @defgroup OCU_Variable
  @{
*/
#define OCU_START_SEC_CONFIG_DATA_UNSPECIFIED
#include "Ocu_MemMap.h"

OCU_CONFIGURATION_POST_BUILD

#define OCU_STOP_SEC_CONFIG_DATA_UNSPECIFIED
#include "Ocu_MemMap.h"

#define OCU_START_SEC_VAR_NO_INIT_UNSPECIFIED
#include "Ocu_MemMap.h"

extern 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"

extern VAR(boolean, OCU_VAR) g_ocuNotifiEnSts[OCU_CH_COUNT_SUPPORTED];

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

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

#if (STD_ON == OCU_DEINIT_API_ENABLE)
FUNC (void, OCU_CODE) Ocu_DeInit(void);
#endif  /* {if (STD_ON == OCU_DEINIT_API_ENABLE)} */

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

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

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

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

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

#ifdef OCU_SET_CLOCK_MODE_API_ENABLE
#if (STD_ON == OCU_SET_CLOCK_MODE_API_ENABLE)
FUNC(void, OCU_CODE) Ocu_SetClkPsc(VAR(Ocu_TmrPrescalerType, AUTOMATIC) OcuPrescalerType);
#endif  /* {if (STD_ON == OCU_SET_CLOCK_MODE_API_ENABLE)} */
#endif  /* ifdef OCU_SET_CLOCK_MODE_API_ENABLE */

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

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

#if (STD_ON == OCU_NOTIFICATION_EN)
FUNC (void, OCU_CODE) Ocu_DisableNotification(VAR(Ocu_ChannelType, AUTOMATIC) ChannelNumber);
#endif  /* {if (STD_ON == OCU_NOTIFICATION_EN)} */

#if (STD_ON == OCU_NOTIFICATION_EN)
FUNC (void, OCU_CODE) Ocu_EnableNotification(VAR(Ocu_ChannelType, AUTOMATIC) ChannelNumber);
#endif  /* {if (STD_ON == OCU_NOTIFICATION_EN)} */

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

#if (STD_ON == OCU_NOTIFICATION_EN)
FUNC(void, OCU_CODE) Ocu_Notification(VAR(Ocu_ChannelType, AUTOMATIC) OcuHwChannel);
#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 */

#endif /* OCU_H */
/**@} end of group OCU_Driver */
/**@} end of group G32A10xx_StdPeriphDriver */
