/**
*   @file           Pwm_eMios_Types.h
*   @version        1.0.0
*
*   @brief          AUTOSAR Pwm - PWM eMios data types header file.
*   @details        PWM eMios data types header file.
*
*   @addtogroup     PWM_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 PWM_EMIOS_TYPES_H
#define PWM_EMIOS_TYPES_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 Pwm_eMios_Types_h_REF_1
* Violates MISRA 2012 Advisory Rule 20.1, #include directives should only be preceded by preprocessor directives or comments.
* <MA>_MemMap.h is included after each section define in order to set the current memory section as defined by AUTOSAR.
*
* @section Pwm_eMios_Types_h_REF_2
* 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 Pwm_eMios_Types_h_REF_3
* Violates MISRA 2012 Advisory Rule 2.5, A project should not contain unused macro declarations
* Macros that are in <MDL>.h or <MDL>_Cfg.h… that are needed for the client (and are used only in tests)
*
*/



/*===============================================================================================
*                                         INCLUDE FILES
 1) system and project includes
 2) needed interfaces from external units
 3) internal and external interfaces from this unit
===============================================================================================*/

#include "Pwm_Cfg.h"



/*===============================================================================================
*                               SOURCE FILE VERSION INFORMATION
===============================================================================================*/

/**
* @{
* @file           Pwm_eMios_Types.h
*/
#define PWM_EMIOS_TYPES_VENDOR_ID                         43
#define PWM_EMIOS_TYPES_AR_RELEASE_MAJOR_VERSION          4
#define PWM_EMIOS_TYPES_AR_RELEASE_MINOR_VERSION          3
#define PWM_EMIOS_TYPES_AR_RELEASE_REVISION_VERSION       1
#define PWM_EMIOS_TYPES_SW_MAJOR_VERSION                  1
#define PWM_EMIOS_TYPES_SW_MINOR_VERSION                  0
#define PWM_EMIOS_TYPES_SW_PATCH_VERSION                  0
/**@}*/



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

/* Check if header file and Pwm_Cfg header file are of the same vendor */
#if (PWM_EMIOS_TYPES_VENDOR_ID != PWM_CFG_VENDOR_ID)
    #error "Pwm_eMios_Types.h and Pwm_Cfg.h have different vendor IDs."
#endif

/* Check if header file and Pwm_Cfg header file are of the same AUTOSAR version */
#if ((PWM_EMIOS_TYPES_AR_RELEASE_MAJOR_VERSION    != PWM_CFG_AR_RELEASE_MAJOR_VERSION) || \
     (PWM_EMIOS_TYPES_AR_RELEASE_MINOR_VERSION    != PWM_CFG_AR_RELEASE_MINOR_VERSION) || \
     (PWM_EMIOS_TYPES_AR_RELEASE_REVISION_VERSION != PWM_CFG_AR_RELEASE_REVISION_VERSION))
    #error "AUTOSAR Version Numbers of Pwm_eMios_Types.h and Pwm_Cfg.h are different."
#endif

/* Check if header file and Pwm_Cfg header file are of the same software version */
#if ((PWM_EMIOS_TYPES_SW_MAJOR_VERSION != PWM_CFG_SW_MAJOR_VERSION) || \
     (PWM_EMIOS_TYPES_SW_MINOR_VERSION != PWM_CFG_SW_MINOR_VERSION) || \
     (PWM_EMIOS_TYPES_SW_PATCH_VERSION != PWM_CFG_SW_PATCH_VERSION))
    #error "Software Version Numbers of Pwm_eMios_Types.h and Pwm_Cfg.h are different."
#endif


#if (PWM_EMIOS_USED == STD_ON)



/*===============================================================================================
*                                       DEFINES AND MACROS
===============================================================================================*/

/**
* @brief    Bus Select: MC up counter
*/
/* @violates @ref Pwm_eMios_Types_h_REF_3 Macros that are in <MDL>.h or that are needed for the client */
#define MASTER_MODE_UP_COUNTER_U32                  (0x00000010UL)

/**
* @brief    Bus Select: MC up/down counter
*/
/* @violates @ref Pwm_eMios_Types_h_REF_3 Macros that are in <MDL>.h or that are needed for the client */
#define MASTER_MODE_UP_DOWN_COUNTER_U32             (0x00000014UL)

/**
* @brief    Bus Select: MCB up
*/
/* @violates @ref Pwm_eMios_Types_h_REF_3 Macros that are in <MDL>.h or that are needed for the client */
#define MASTER_MODE_UP_BUFFERED_COUNTER_U32         (0x00000050UL)

/**
* @brief    Bus Select: MCB up/down
*/
/* @violates @ref Pwm_eMios_Types_h_REF_3 Macros that are in <MDL>.h or that are needed for the client */
#define MASTER_MODE_UP_DOWN_BUFFERED_COUNTER_U32    (0x00000054UL)





/**
* @brief    OPWFMB Buffered with Flag on B Match (period)
*/
/* @violates @ref Pwm_eMios_Types_h_REF_3 Macros that are in <MDL>.h or that are needed for the client */
#define PWM_MODE_OPWFMB_U32                         (0x00000058UL)

/**
* @brief    Output Pulse Width and Frequency Modulation flag at match B, B update at match A 
*/
/* @violates @ref Pwm_eMios_Types_h_REF_3 Macros that are in <MDL>.h or that are needed for the client */
#define PWM_MODE_OPWFM_U32                          (0x00000018UL)

/**
* @brief    OPWMB Buffered with Flag on B Match (period)
*/
/* @violates @ref Pwm_eMios_Types_h_REF_3 Macros that are in <MDL>.h or that are needed for the client */
#define PWM_MODE_OPWMB_U32                          (0x00000060UL)

/**
* @brief    Output Pulse Width Modulation flag at match B, B update at match A
*/
/* @violates @ref Pwm_eMios_Types_h_REF_3 Macros that are in <MDL>.h or that are needed for the client */
#define PWM_MODE_OPWM_U32                           (0x00000021UL)

/**
* @brief    Output Pulse Width Modulation with Trigger
*/
/* @violates @ref Pwm_eMios_Types_h_REF_3 Macros that are in <MDL>.h or that are needed for the client */
#define PWM_MODE_OPWMT_U32                          (0x00000026UL)

/**
* @brief    Center Aligned Output Pulse Width Modulation Buffered with lead edge dead time
*/
/* @violates @ref Pwm_eMios_Types_h_REF_3 Macros that are in <MDL>.h or that are needed for the client */
#define PWM_MODE_OPWMCB_LEAD_DEADTIME_U32           (0x0000005DUL)

/**
* @brief    Center Aligned Output Pulse Width Modulation Buffered with trial edge dead time
*/
/* @violates @ref Pwm_eMios_Types_h_REF_3 Macros that are in <MDL>.h or that are needed for the client */
#define PWM_MODE_OPWMCB_TRAIL_DEADTIME_U32          (0x0000005CUL)

/**
* @brief    Double Action Output Compare
*/
/* @violates @ref Pwm_eMios_Types_h_REF_3 Macros that are in <MDL>.h or that are needed for the client */
#define PWM_MODE_DAOC_U32                           (0x00000006UL)





/**
* @brief    Bus select: counter bus[A]
*/
/* @violates @ref Pwm_eMios_Types_h_REF_3 Macros that are in <MDL>.h or that are needed for the client */
#define PWM_BUS_A_U32                               (0x00000000UL)

/**
* @brief   Bus select: channels [0,7]: counter busB, channels [8,15]: counter busC, channels [16,23]: counter busD
*/
/* @violates @ref Pwm_eMios_Types_h_REF_3 Macros that are in <MDL>.h or that are needed for the client */
#define PWM_BUS_DIVERSE_U32                         (0x00000200UL)

/**
* @brief   Bus select: counter bus[F]
*/
/* @violates @ref Pwm_eMios_Types_h_REF_3 Macros that are in <MDL>.h or that are needed for the client */
#define PWM_BUS_F_U32                               (0x00000400UL)

/**
* @brief   Bus select: internal counter
*/
/* @violates @ref Pwm_eMios_Types_h_REF_3 Macros that are in <MDL>.h or that are needed for the client */
#define PWM_BUS_INTERNAL_COUNTER_U32                (0x00000600UL)





/**
* @brief   Initialization option to set the channel prescaler value to 1
*/
/* @violates @ref Pwm_eMios_Types_h_REF_3 Macros that are in <MDL>.h or that are needed for the client */
#define PWM_PRES_1_U32                              (0x00000000UL)

/**
* @brief   Initialization option to set the channel prescaler value to 2
*/
/* @violates @ref Pwm_eMios_Types_h_REF_3 Macros that are in <MDL>.h or that are needed for the client */
#define PWM_PRES_2_U32                              (0x04000000UL)

/**
* @brief   Initialization option to set the channel prescaler value to 3
*/
/* @violates @ref Pwm_eMios_Types_h_REF_3 Macros that are in <MDL>.h or that are needed for the client */
#define PWM_PRES_3_U32                              (0x08000000UL)

/**
* @brief   Initialization option to set the channel prescaler value to 4
*/
/* @violates @ref Pwm_eMios_Types_h_REF_3 Macros that are in <MDL>.h or that are needed for the client */
#define PWM_PRES_4_U32                              (0x0C000000UL)



/**
* @brief   Initialization option to enable freeze mode for the channel
*/
/* @violates @ref Pwm_eMios_Types_h_REF_3 Macros that are in <MDL>.h or that are needed for the client */
#define PWM_FREEZE_ENABLE_U32                       (0x80000000UL)



/*===============================================================================================
*                                 STRUCTURES AND OTHER TYPEDEFS
===============================================================================================*/

#if ((PWM_SET_COUNTER_BUS_API == STD_ON) && \
     (PWM_EMIOS_16_BITS_VARIANT == STD_OFF) && \
     ((PWM_FEATURE_OPWMB == STD_ON) || (PWM_FEATURE_OPWM == STD_ON) || (PWM_FEATURE_OPWMT == STD_ON)))
/**
* @brief        unsigned long long integer at least 64 bit long.
*
*/
typedef unsigned long long Pwm_uint64;
#endif

/**
* @brief        eMIOS hardware module/channel ID type
*
*/
typedef uint8 Pwm_eMios_ChannelType;

/**
* @brief        eMIOS unified channel control register value
*
*/
typedef uint32 Pwm_eMios_ControlType;



#if ((PWM_SET_DUTY_CYCLE_NO_UPDATE_API == STD_ON) || (PWM_SET_PERIOD_AND_DUTY_NO_UPDATE_API == STD_ON) || (PWM_SET_PHASE_SHIFT_NO_UPDATE_API == STD_ON))
/**
* @brief        PWM signal update type
*
*/
typedef enum
{
    /** @brief  The signals are updated synchronous. This is the default generation mode */
    PWM_EMIOS_UPDATE_SYNCHRONOUS = 0,
    /** @brief  The signals are updated asynchronous */
    PWM_EMIOS_UPDATE_ASYNCHRONOUS
} Pwm_eMios_UpdateType;
#endif



/**
* @brief        eMIOS IP specific channel configuration structure type
*
*/
typedef struct
{
    /** @brief  PWM signal polarity: PWM_HIGH or PWM_LOW */
    CONST       (Pwm_OutputStateType,       PWM_CONST)                      ePwmPolarity;
    /** @brief  PWM signal idle state: PWM_HIGH or PWM_LOW */
    CONST       (Pwm_OutputStateType,       PWM_CONST)                      ePwmIdleState;
    /** @brief  Default value for duty cycle: [0-0x8000] (0-100%) */
    CONST       (uint16,                    PWM_CONST)                      u16PwmDefaultDutyCycle; 
    /** @brief  Default value for period */
    CONST       (Pwm_PeriodType,            PWM_CONST)                      nPwmDefaultPeriod;
    /** @brief  Assigned eMios channel ID */
    CONST       (Pwm_eMios_ChannelType,     PWM_CONST)                      u8HwChannel;
    /** @brief  eMios channel parameters */
    CONST       (Pwm_eMios_ControlType,     PWM_CONST)                      u32ControlValue;
    /** @brief  Leading edge of the output pulse */
    CONST       (Pwm_PeriodType,            PWM_CONST)                      nPwmOffset;
    /** @brief  Master mode used */
    CONST       (uint8,                     PWM_CONST)                      u8MasterMode;
#if (PWM_FEATURE_DAOC == STD_ON)
    /** @brief  Default value for period */
    CONST       (Pwm_PeriodType,            PWM_CONST)                      nPwmDaocModulo;
#endif
#if (PWM_FEATURE_OPWMT == STD_ON)
    /** @brief  Delay of trigger generation */
    CONST       (Pwm_PeriodType,            PWM_CONST)                      nPwmTriggerDelay;
#endif
#if (PWM_FEATURE_OPWMCB == STD_ON)
    /** @brief  Deadtime value */
    CONST       (Pwm_PeriodType,            PWM_CONST)                      nPwmDeadTime;
#endif
    /** @brief  Offset of trigger delay */
    CONST       (boolean,                   PWM_CONST)                      bPwmOffsetTriggerDelay;
} Pwm_eMios_ChannelConfigType;

/**
* @brief        eMIOS IP specific configuration structure type
*
*/
typedef struct
{
    /** @brief  Number of eMIOS channels in the PWM configuration */
    CONST       (Pwm_eMios_ChannelType,                     PWM_CONST)          u8NumChannels;
    /** @brief  Pointer to the configured channels for eMIOS */
    CONST       (Pwm_eMios_ChannelConfigType,               PWM_CONST)          (*pChannelsConfig)[]; 
} Pwm_eMios_IpConfigType;


#endif /* PWM_EMIOS_USED */

#ifdef __cplusplus
}
#endif

#endif /* PWM_EMIOS_TYPES_H */

/** @} */

