/*!
* @file     Pwm_PBcfg.c
*
* @version  1.0.0
*
* @brief    Code file of AUTOSAR Pwm parameter configuration(post-build)
*
* @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.
*/

#ifdef __cplusplus
extern "C" {
#endif

#include "Pwm.h"
#include "Pdl_TmrReg.h"

/** @addtogroup G32A10xx_StdPeriphDriver
  @{
*/

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

/** @defgroup PWM_Macros
  @{
*/
/*************************************************************************************************
*                              VENDOR ID & AUTOSAR VERSION RECORD INFO
*************************************************************************************************/
/** Vendor ID (vendorId) of the dedicated implementation of this module according to the AUTOSAR vendor list. */
#define PWM_PBCFG_VENDOR_ID                      0x00C1U
/** Module ID of this module, as defined in the BSW Module List [1]. */
#define PWM_PBCFG_MODULE_ID                      0x0079U
/** Major version number of AUTOSAR release on which the appropriate implementation is based on. */
#define PWM_PBCFG_AR_RELEASE_MAJOR_VERSION       0x04U
/** Minor version number of AUTOSAR release on which the appropriate implementation is based on. */
#define PWM_PBCFG_AR_RELEASE_MINOR_VERSION       0x04U
/** Revision version number of AUTOSAR release on which the appropriate implementation is based on. */
#define PWM_PBCFG_AR_RELEASE_REVISION_VERSION    0x00U
/** Major version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define PWM_PBCFG_SW_MAJOR_VERSION               0x01U
/** Minor version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define PWM_PBCFG_SW_MINOR_VERSION               0x00U
/** Patch level version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define PWM_PBCFG_SW_PATCH_VERSION               0x00U

/**@} end of group PWM_Macros */

/*************************************************************************************************
                                VERSION INFOMATION VERIFICATION
*************************************************************************************************/
/* Make sure the vendor id is the same between Pwm_PBcfg.c and Pwm.h */
#if (PWM_PBCFG_VENDOR_ID != PWM_H_VENDOR_ID)
    #error "Vendor id mismatch between Pwm_PBcfg.c and Pwm.h."
#endif
/* Make sure the AUTOSAR major version numbers is the same between Pwm_PBcfg.c and Pwm.h */
#if (PWM_PBCFG_AR_RELEASE_MAJOR_VERSION != PWM_H_AR_RELEASE_MAJOR_VERSION)
    #error "AUTOSAR Major Version Number mismatch between Pwm_PBcfg.c and Pwm.h."
#endif
/* Make sure the AUTOSAR minor version numbers is the same between Pwm_PBcfg.c and Pwm.h */
#if (PWM_PBCFG_AR_RELEASE_MINOR_VERSION != PWM_H_AR_RELEASE_MINOR_VERSION) 
    #error "AUTOSAR Minor Version Number mismatch between Pwm_PBcfg.c and Pwm.h."
#endif
/* Make sure the AUTOSAR revision version numbers is the same between Pwm_PBcfg.c and Pwm.h */
#if (PWM_PBCFG_AR_RELEASE_REVISION_VERSION != PWM_H_AR_RELEASE_REVISION_VERSION)
    #error "AUTOSAR Revision Version Number mismatch between Pwm_PBcfg.c and Pwm.h."
#endif
/* Make sure the software major version numbers is the same between Pwm_PBcfg.c and Pwm.h */
#if (PWM_PBCFG_SW_MAJOR_VERSION != PWM_H_SW_MAJOR_VERSION) 
    #error "Software Major Version Number mismatch between Pwm_PBcfg.c and Pwm.h."
#endif
/* Make sure the software minor version numbers is the same between Pwm_PBcfg.c and Pwm.h */
#if (PWM_PBCFG_SW_MINOR_VERSION != PWM_H_SW_MINOR_VERSION) 
    #error "Software Minor Version Number mismatch between Pwm_PBcfg.c and Pwm.h."
#endif
/* Make sure the software patch version numbers is the same between Pwm_PBcfg.c and Pwm.h */
#if (PWM_PBCFG_SW_PATCH_VERSION != PWM_H_SW_PATCH_VERSION)
    #error "Software Patch Version Number mismatch between Pwm_PBcfg.c and Pwm.h."
#endif

/* Make sure the vendor id is the same between Pwm_PBcfg.c and Pdl_TmrReg.h */
#if (PWM_PBCFG_VENDOR_ID != PDL_TMR_REG_H_VENDOR_ID)
    #error "Vendor id mismatch between Pwm_PBcfg.c and Pdl_TmrReg.h."
#endif
/* Make sure the AUTOSAR major version numbers is the same between Pwm_PBcfg.c and Pdl_TmrReg.h */
#if (PWM_PBCFG_AR_RELEASE_MAJOR_VERSION != PDL_TMR_REG_H_AR_RELEASE_MAJOR_VERSION)
    #error "AUTOSAR Major Version Number mismatch between Pwm_PBcfg.c and Pdl_TmrReg.h."
#endif
/* Make sure the AUTOSAR minor version numbers is the same between Pwm_PBcfg.c and Pdl_TmrReg.h */
#if (PWM_PBCFG_AR_RELEASE_MINOR_VERSION != PDL_TMR_REG_H_AR_RELEASE_MINOR_VERSION) 
    #error "AUTOSAR Minor Version Number mismatch between Pwm_PBcfg.c and Pdl_TmrReg.h."
#endif
/* Make sure the AUTOSAR revision version numbers is the same between Pwm_PBcfg.c and Pdl_TmrReg.h */
#if (PWM_PBCFG_AR_RELEASE_REVISION_VERSION != PDL_TMR_REG_H_AR_RELEASE_REVISION_VERSION)
    #error "AUTOSAR Revision Version Number mismatch between Pwm_PBcfg.c and Pdl_TmrReg.h."
#endif
/* Make sure the software major version numbers is the same between Pwm_PBcfg.c and Pdl_TmrReg.h */
#if (PWM_PBCFG_SW_MAJOR_VERSION != PDL_TMR_REG_H_SW_MAJOR_VERSION) 
    #error "Software Major Version Number mismatch between Pwm_PBcfg.c and Pdl_TmrReg.h."
#endif
/* Make sure the software minor version numbers is the same between Pwm_PBcfg.c and Pdl_TmrReg.h */
#if (PWM_PBCFG_SW_MINOR_VERSION != PDL_TMR_REG_H_SW_MINOR_VERSION) 
    #error "Software Minor Version Number mismatch between Pwm_PBcfg.c and Pdl_TmrReg.h."
#endif
/* Make sure the software patch version numbers is the same between Pwm_PBcfg.c and Pdl_TmrReg.h */
#if (PWM_PBCFG_SW_PATCH_VERSION != PDL_TMR_REG_H_SW_PATCH_VERSION)
    #error "Software Patch Version Number mismatch between Pwm_PBcfg.c and Pdl_TmrReg.h."
#endif

/*************************************************************************************************
                                         LOCAL VARIABLE
*************************************************************************************************/
#define PWM_START_SEC_CODE
#include "Pwm_MemMap.h"

/** @defgroup PWM_Fuctions
  @{
*/

extern FUNC(void, PWM_CODE) Pwm_Notification_Channel_0(void);

/**@} end of group PWM_Fuctions */

#define PWM_STOP_SEC_CODE
#include "Pwm_MemMap.h"

/*************************************************************************************************
                                         CONSTANT DEFINITION
*************************************************************************************************/
#define PWM_START_SEC_CONFIG_DATA_UNSPECIFIED
#include "Pwm_MemMap.h"

/** @defgroup PWM_Macros
  @{
*/

/** Pwm configured channels number */
#define PWM_CONFIGURED_CHANNEL_COUNT_PB            ((uint8) 1U)

/** Pwm configured Tmr modules number */
#define PWM_TMR_MODULE_COUNT_PB                   ((uint8) 1U)

/**@} end of group PWM_Macros */

/** @defgroup PWM_Variable
  @{
*/

/** PWM TMR channel configurations */
static CONST(Pwm_TmrChCfgType, PWM_CONST) Pwm_Tmr_ChannelCfg_PB[PWM_CONFIGURED_CHANNEL_COUNT_PB] =
{
    /** PwmChannel_0 - PwmChannelId_0 */
    {
        PWM_HIGH, //!< Channel polarity
        PWM_LOW, //!< Channel idle state
        ((uint16)16384), //!< duty cycle value
        PWM_TMR1_CH1, //!< Channel Name
        PWM_EDGE_COMPLEMENTARY_ALIGN, //!< Edge alignment  
        PWM_OUTPUT_MODE2, //!< pwm mode
        PortConfigSet_PortContainer_0_TMR1_CH1
    }
};

/** TMR module Configurations */
static CONST(Pwm_TmrRegValType, PWM_CONST) Pwm_Tmr_ModuleCfg_PB[PWM_TMR_MODULE_COUNT_PB] =
{
    /** Pwm Tmr Module 1 */
    {
        PWM_TMR1, //!< 
        25000U,
        (0 << TMR_CTRL1_CLKDIV_SHIFT), //!< 
        255U, //!< 
#if (STD_ON == PWM_DUAL_CLOCK_MODE_SUPPORTED)
        383U, //!< 
#endif
        (TMR_BDT_MOEN_MASK | TMR_BDT_AOEN_MASK | TMR_BDT_RMOS_MASK | TMR_BDT_IMOS_MASK | (uint32)0xBD)//!< 
#if (STD_ON == PWM_FAULT_CHECK_SUPPORTED)
        ,
        NULL_PTR  //!< Fault notification callback function
#endif
#if (STD_ON == PWM_OVERFLOW_CHECK_SUPPORTED)
        ,
        NULL_PTR  //!< Overflow notification callback function
#endif
    }
};

/** PWM TMR configuration */
static CONST(Pwm_TmrIpCfgType, PWM_CONST) Pwm_Tmr_Configuration_PB =
{
    PWM_CONFIGURED_CHANNEL_COUNT_PB, //!< Pwm Tmr configured channels number
    PWM_TMR_MODULE_COUNT_PB, //!< Pwm configured Tmr modules number
    &Pwm_Tmr_ChannelCfg_PB, //!< Pointer to PWM TMR channel configurations
    &Pwm_Tmr_ModuleCfg_PB //!< Pointer to TMR module Configurations
};

/** PWM channels configuration */
static CONST(Pwm_ChClassAndNotifyType, PWM_CONST) Pwm_ChannelsCfg_PB[PWM_CONFIGURED_CHANNEL_COUNT_PB] =
{
    /** PwmChannel_0 */
    {
        PWM_FIXED_PERIOD //!< Pwm Channel Class
        #if (STD_ON == PWM_NOTIFICATION_SUPPORTED)
            ,
            &Pwm_Notification_Channel_0 //!< Pwm notification callback function
        #endif
    }
};

/** Pwm configuration */
CONST(Pwm_ConfigType, Pwm_CONST) Pwm_Config =
{
    (Pwm_ChannelType)PWM_CONFIGURED_CHANNEL_COUNT_PB, //!< Pwm channels number
    &Pwm_ChannelsCfg_PB, //!< Pointer to Pwm channels configuration
    &Pwm_Tmr_Configuration_PB //!< Pointer to Pwm TMR configuration
    #if (STD_ON == PWM_NOTIFICATION_SUPPORTED)
        ,
        /** PWM Hardware to logic channel mapping. */
        {
            /** Index of channels 0-3 of Tmr Module 1 in the array of logic Pwm channels */
            (Pwm_ChannelType)0, (Pwm_ChannelType)255, (Pwm_ChannelType)255, (Pwm_ChannelType)255,
            /** Index of channels 0-3 of Tmr Module 2 in the array of logic Pwm channels */
            (Pwm_ChannelType)255, (Pwm_ChannelType)255, (Pwm_ChannelType)255, (Pwm_ChannelType)255,
            /** Index of channels 0-3 of Tmr Module 3 in the array of logic Pwm channels */
            (Pwm_ChannelType)255, (Pwm_ChannelType)255, (Pwm_ChannelType)255, (Pwm_ChannelType)255,
            /** Index of channels 0-3 of Tmr Module 4 in the array of logic Pwm channels */
            (Pwm_ChannelType)255, (Pwm_ChannelType)255, (Pwm_ChannelType)255, (Pwm_ChannelType)255
        }
    #endif
};

/**@} end of group PWM_Variable */

#define PWM_STOP_SEC_CONFIG_DATA_UNSPECIFIED
#include "Pwm_MemMap.h"

#ifdef __cplusplus
}
#endif

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