/*!
* @file     Pwm_Tmr.h
*
* @version  1.0.0
*
* @brief    Header file of AUTOSAR pwm driver by TMR
*
* @attention
*
* Project Name      : AUTOSAR MCAL
*
* Platform          : Arm
*
* Autosar Standard  : Classic Platform 4.4.0
*
* Compiled Version  : G32A10xx_MCAL_1_0_0_01-Otc-25
*
* 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 PWM_TMR_H
#define PWM_TMR_H

#ifdef __cplusplus
extern "C"{
#endif

#include "Pwm.h"

/** @addtogroup G32A10xx_StdPeriphDriver
  @{
*/

/** @defgroup PWM_Driver
  * @brief PWM driver modules
  @{
*/

/** @defgroup PWM_Macros
  @{
*/
/**************************************************************************
                  VENDOR ID & AUTOSAR VERSION INFO
**************************************************************************/
/** Vendor ID (vendorId) of the dedicated implementation of this module according to the AUTOSAR vendor list. */
#define PWM_TMR_H_VENDOR_ID                       0x00C1U
/** Module ID of this module, as defined in the BSW Module List. */
#define PWM_TMR_H_MODULE_ID                       0x0079U
/** Major version number of AUTOSAR release on which the appropriate implementation is based on. */
#define PWM_TMR_H_AR_RELEASE_MAJOR_VERSION        0x04U
/** Minor version number of AUTOSAR release on which the appropriate implementation is based on. */
#define PWM_TMR_H_AR_RELEASE_MINOR_VERSION        0x04U
/** Revision version number of AUTOSAR release on which the appropriate implementation is based on. */
#define PWM_TMR_H_AR_RELEASE_REVISION_VERSION     0x00U
/** Major version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define PWM_TMR_H_SW_MAJOR_VERSION                0x01U
/** Minor version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define PWM_TMR_H_SW_MINOR_VERSION                0x00U
/** Patch level version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define PWM_TMR_H_SW_PATCH_VERSION                0x00U

/**@} end of group PWM_Macros */

/**************************************************************************
                    VERSION INFOMATION VERIFICATION
**************************************************************************/
/* Make sure the vendor id is the same between Pwm_Tmr.h and Pwm.h */
#if (PWM_TMR_H_VENDOR_ID != PWM_H_VENDOR_ID)
    #error "Vendor id mismatch between Pwm_Tmr.h and Pwm.h " 
#endif
/* Make sure the AUTOSAR major version number is the same between Pwm_Tmr.h and Pwm.h */
#if (PWM_TMR_H_AR_RELEASE_MAJOR_VERSION != PWM_H_AR_RELEASE_MAJOR_VERSION)
    #error "AUTOSAR Major Version Number mismatch between Pwm_Tmr.h and Pwm.h "
#endif
/* Make sure the AUTOSAR minor version number is the same between Pwm_Tmr.h and Pwm.h */
#if (PWM_TMR_H_AR_RELEASE_MINOR_VERSION != PWM_H_AR_RELEASE_MINOR_VERSION)
    #error "AUTOSAR Minor Version Number mismatch between Pwm_Tmr.h and Pwm.h "
#endif
/* Make sure the AUTOSAR revision version number is the same between Pwm_Tmr.h and Pwm.h */
#if (PWM_TMR_H_AR_RELEASE_REVISION_VERSION != PWM_H_AR_RELEASE_REVISION_VERSION)
    #error "AUTOSAR Revision Version Number mismatch between Pwm_Tmr.h and Pwm.h "
#endif
/* Make sure the software major version number is the same between Pwm_Tmr.h and Pwm.h */
#if (PWM_TMR_H_SW_MAJOR_VERSION != PWM_H_SW_MAJOR_VERSION)
    #error "Software Major Version Number mismatch between Pwm_Tmr.h and Pwm.h "
#endif
/* Make sure the software minor version number is the same between Pwm_Tmr.h and Pwm.h */
#if (PWM_TMR_H_SW_MINOR_VERSION != PWM_H_SW_MINOR_VERSION)
    #error "Software Minor Version Number mismatch between Pwm_Tmr.h and Pwm.h "
#endif
/* Make sure the software patch version number is the same between Pwm_Tmr.h and Pwm.h */
#if (PWM_TMR_H_SW_PATCH_VERSION != PWM_H_SW_PATCH_VERSION)
    #error "Software Patch Version Number mismatch between Pwm_Tmr.h and Pwm.h "
#endif

/**************************************************************************
                    ENUMERATION DEFINITION
**************************************************************************/
/** @defgroup PWM_Enumerations
  @{
*/

/**
 * @brief    definition pwm tmr duty cycle value type
 */
typedef enum
{
    PWM_TMR_DUTY_CYCLE_EMPTY     = (uint16)0,       //!< pwm tmr duty cycle equals 0

    PWM_TMR_DUTY_CYCLE_HALF      = (uint16)0x4000,  //!< pwm tmr duty cycle equals 50%

    PWM_TMR_DUTY_CYCLE_FULL      = (uint16)0x8000,  //!< pwm tmr duty cycle equals 100%

    PWM_TMR_DUTY_CYCLE_MASK_VAL  = (uint16)0x7FFF  //!< pwm tmr duty cycle mask value

} Pwm_TmrDutyCycleValueType;

/**
 * @brief    definition pwm tmr channel state type
 */
typedef enum
{
    PWM_TMR_CHANNEL_IS_IDLE     = (uint8)0U,  //!< pwm tmr channel is in idle state

    PWM_TMR_CHANNEL_IS_RUNNING  = (uint8)1U   //!< pwm tmr channel is in running state

} Pwm_TmrChStateType;

/**@} end of group PWM_Enumerations */

/**************************************************************************
                    FUNCTION DECLARATION
**************************************************************************/
#define PWM_START_SEC_CODE
#include "Pwm_MemMap.h"

/** @defgroup PWM_Fuctions
  @{
*/

FUNC(void, PWM_CODE) Pwm_Tmr_Init(CONSTP2CONST(Pwm_TmrIpCfgType, AUTOMATIC, PWM_APPL_CONST) pTmrIpCfgPtr);

#if (STD_ON == PWM_DE_INIT_API)
FUNC(void, PWM_CODE) Pwm_Tmr_DeInit(CONSTP2CONST(Pwm_TmrIpCfgType, AUTOMATIC, PWM_APPL_CONST) pTmrIpCfgPtr);
#endif

#if ((STD_ON == PWM_SET_DUTY_CYCLE_API) || (STD_ON == PWM_SET_DUTY_CYCLE_SWSYNC))
FUNC(void, PWM_CODE) Pwm_Tmr_SetDutyCycle(VAR(uint8, AUTOMATIC) ChannelNumber, VAR(uint16, AUTOMATIC) DutyCycle,
                                          CONSTP2CONST(Pwm_TmrIpCfgType, AUTOMATIC, PWM_APPL_CONST) pTmrIpCfgPtr);
#endif

#if ((STD_ON == PWM_SET_PERIOD_AND_DUTY_API) || (STD_ON == PWM_SET_PERIOD_AND_DUTY_SWSYNC))
FUNC(void, PWM_CODE) Pwm_Tmr_SetPeriodAndDuty(VAR(uint8, AUTOMATIC) ChannelNumber,
                                              VAR(Pwm_PeriodType, AUTOMATIC) Period, VAR(uint16, AUTOMATIC) DutyCycle,
                                     CONSTP2CONST(Pwm_TmrIpCfgType, AUTOMATIC, PWM_APPL_CONST) pTmrIpCfgPtr);
#endif

#if (STD_ON == PWM_SET_OUTPUT_TO_IDLE_API)
FUNC(void, PWM_CODE) Pwm_Tmr_SetOutputToIdle(VAR(uint8, AUTOMATIC) ChannelNumber,
                     CONSTP2CONST(Pwm_TmrIpCfgType, AUTOMATIC, PWM_APPL_CONST) pTmrIpCfgPtr);
#endif

#if (STD_ON == PWM_GET_OUTPUT_STATE_API)
FUNC(Pwm_OutputStateType,PWM_CODE) Pwm_Tmr_GetOutputState(VAR(uint8, AUTOMATIC) ChannelNumber,
                         CONSTP2CONST(Pwm_TmrIpCfgType, AUTOMATIC, PWM_APPL_CONST) pTmrIpCfgPtr);
#endif

#if (STD_ON == PWM_NOTIFICATION_SUPPORTED)
FUNC(void, PWM_CODE) Pwm_Tmr_DisableNotification(VAR(uint8, AUTOMATIC) ChannelNumber,
                     CONSTP2CONST(Pwm_TmrIpCfgType, AUTOMATIC, PWM_APPL_CONST) pTmrIpCfgPtr);

FUNC(void, PWM_CODE) Pwm_Tmr_EnableNotification
                     (VAR(uint8, AUTOMATIC) ChannelNumber, VAR(Pwm_EdgeNotificationType, AUTOMATIC) Notification,
                      CONSTP2CONST(Pwm_TmrIpCfgType, AUTOMATIC, PWM_APPL_CONST) pTmrIpCfgPtr);
#endif

#if (STD_ON == PWM_LOW_POWER_STATE_ENABLE)
FUNC(Std_ReturnType, PWM_CODE) Pwm_Tmr_CheckChIdleState(void);

FUNC(void, PWM_CODE) Pwm_Tmr_SetPowerState(P2CONST(Pwm_TmrIpCfgType, AUTOMATIC, PWM_APPL_CONST) pTmrIpCfgPtr,
                                               VAR(Pwm_PowerStateType, AUTOMATIC) TargetPowerState);
#endif

#if (STD_ON == PWM_DUAL_CLOCK_MODE_SUPPORTED)
FUNC(void, PWM_CODE) Pwm_Tmr_SetClkPrescaler(VAR(Pwm_ClockDivisionType, AUTOMATIC) ClkPscMode,
                     CONSTP2CONST(Pwm_TmrIpCfgType, AUTOMATIC, PWM_APPL_CONST) pTmrIpCfgPtr);
#endif

#if (STD_ON == PWM_SET_OUTPUT_TO_ACTIVE)
FUNC (void, PWM_CODE) Pwm_Tmr_SetOutputToActive(VAR(uint8, AUTOMATIC) ChannelNumber,
                      CONSTP2CONST(Pwm_TmrIpCfgType, AUTOMATIC, PWM_APPL_CONST) pTmrIpCfgPtr);
#endif

#if (STD_ON == PWM_SOFTWARE_RESET_COUNTER)
FUNC(void, PWM_CODE) Pwm_Tmr_SoftwareResetCounter(VAR(uint8, AUTOMATIC) InstanceId);
#endif

#if (STD_ON == PWM_GET_CHANNEL_DUTYCYCLE)
FUNC(uint16, PWM_CODE) Pwm_Tmr_GetChDutyCycleValue(VAR(uint8, AUTOMATIC) ChannelNumber);
#endif

#if (STD_ON == PWM_TURN_ON_OFF_CHANNEL)
FUNC(void, PWM_CODE) Pwm_Tmr_TurnOnOffChannel(VAR(uint8, AUTOMATIC) ChannelNumber, VAR(boolean, AUTOMATIC) operaFlag,
                                              CONSTP2CONST(Pwm_TmrIpCfgType, AUTOMATIC, PWM_APPL_CONST) pTmrIpCfgPtr);
#endif

#if ((STD_ON == PWM_NOTIFICATION_SUPPORTED) || (STD_ON == PWM_OVERFLOW_CHECK_SUPPORTED))
FUNC(void , PWM_CODE) Pwm_Tmr_ProcessCommonInterrupt(CONST(uint8, AUTOMATIC) TmrModule);
#endif

#if ((STD_ON == PWM_OVERFLOW_CHECK_SUPPORTED) || (STD_ON == PWM_FAULT_CHECK_SUPPORTED))
FUNC(void , PWM_CODE) Pwm_Tmr1_ProcessTofAndFaultInterrupt(CONST(uint8, AUTOMATIC) TmrModule);
#endif

/**@} end of group PWM_Fuctions */

#define PWM_STOP_SEC_CODE
#include "Pwm_MemMap.h"

#ifdef __cplusplus
}
#endif

#endif

/**@} end of group PWM_Driver */
/**@} end of group G32A10xx_StdPeriphDriver */
