mirror of
https://github.com/Dev-KATECH/ADM.git
synced 2026-05-17 01:43:59 +09:00
476 lines
18 KiB
C
476 lines
18 KiB
C
/*==================================================================================================
|
|
* Project : RTD AUTOSAR 4.4
|
|
* Platform : CORTEXM
|
|
* Peripheral : Emios Flexio
|
|
* Dependencies : none
|
|
*
|
|
* Autosar Version : 4.4.0
|
|
* Autosar Revision : ASR_REL_4_4_REV_0000
|
|
* Autosar Conf.Variant :
|
|
* SW Version : 0.9.0
|
|
* Build Version : S32K3_RTD_0_9_0__ASR_REL_4_4_REV_0000_20210326
|
|
*
|
|
* (c) Copyright 2020 - 2021 NXP Semiconductors
|
|
* All Rights Reserved.
|
|
*
|
|
* NXP Confidential. This software is owned or controlled by NXP and may only be
|
|
* used strictly in accordance with the applicable license terms. By expressly
|
|
* accepting such terms or by downloading, installing, activating and/or otherwise
|
|
* using the software, you are agreeing that you have read, and that you agree to
|
|
* comply with and are bound by, such license terms. If you do not agree to be
|
|
* bound by the applicable license terms, then you may not retain, install,
|
|
* activate or otherwise use the software.
|
|
==================================================================================================*/
|
|
|
|
#ifndef EMIOS_PWM_IP_H
|
|
#define EMIOS_PWM_IP_H
|
|
|
|
/**
|
|
* @file Emios_Pwm_Ip.h
|
|
*
|
|
* @addtogroup emios_pwm_ip Emios Pwm IPL
|
|
* @{
|
|
*/
|
|
|
|
#ifdef __cplusplus
|
|
extern "C"{
|
|
#endif
|
|
|
|
|
|
/*==================================================================================================
|
|
* INCLUDE FILES
|
|
* 1) system and project includes
|
|
* 2) needed interfaces from external units
|
|
* 3) internal and external interfaces from this unit
|
|
==================================================================================================*/
|
|
#include "StandardTypes.h"
|
|
#include "Emios_Pwm_Ip_Cfg.h"
|
|
#include "Emios_Pwm_Ip_Types.h"
|
|
|
|
/*==================================================================================================
|
|
* SOURCE FILE VERSION INFORMATION
|
|
==================================================================================================*/
|
|
#define EMIOS_PWM_IP_VENDOR_ID 43
|
|
#define EMIOS_PWM_IP_MODULE_ID 121
|
|
#define EMIOS_PWM_IP_AR_RELEASE_MAJOR_VERSION 4
|
|
#define EMIOS_PWM_IP_AR_RELEASE_MINOR_VERSION 4
|
|
#define EMIOS_PWM_IP_AR_RELEASE_REVISION_VERSION 0
|
|
#define EMIOS_PWM_IP_SW_MAJOR_VERSION 0
|
|
#define EMIOS_PWM_IP_SW_MINOR_VERSION 9
|
|
#define EMIOS_PWM_IP_SW_PATCH_VERSION 0
|
|
|
|
/*==================================================================================================
|
|
* FILE VERSION CHECKS
|
|
==================================================================================================*/
|
|
#ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
|
|
/* Check if header file and StandardTypes.h are of the same AUTOSAR version */
|
|
#if ((EMIOS_PWM_IP_AR_RELEASE_MAJOR_VERSION != STD_AR_RELEASE_MAJOR_VERSION) || \
|
|
(EMIOS_PWM_IP_AR_RELEASE_MINOR_VERSION != STD_AR_RELEASE_MINOR_VERSION))
|
|
#error "AUTOSAR Version Numbers of Emios_Pwm_Ip.h and StandardTypes.h are different"
|
|
#endif
|
|
#endif
|
|
|
|
/* Check if header file and Emios_Pwm_Ip_Cfg header file are of the same vendor */
|
|
#if (EMIOS_PWM_IP_VENDOR_ID != EMIOS_PWM_IP_CFG_VENDOR_ID)
|
|
#error "Vendor IDs of Emios_Pwm_Ip.h and Emios_Pwm_Ip_Cfg.h are different."
|
|
#endif
|
|
|
|
/* Check if header file and Emios_Pwm_Ip_Cfg header file are of the same AUTOSAR version */
|
|
#if ((EMIOS_PWM_IP_AR_RELEASE_MAJOR_VERSION != EMIOS_PWM_IP_CFG_AR_RELEASE_MAJOR_VERSION) || \
|
|
(EMIOS_PWM_IP_AR_RELEASE_MINOR_VERSION != EMIOS_PWM_IP_CFG_AR_RELEASE_MINOR_VERSION) || \
|
|
(EMIOS_PWM_IP_AR_RELEASE_REVISION_VERSION != EMIOS_PWM_IP_CFG_AR_RELEASE_REVISION_VERSION))
|
|
#error "AUTOSAR version numbers of Emios_Pwm_Ip.h and Emios_Pwm_Ip_Cfg.h are different."
|
|
#endif
|
|
|
|
/* Check if header file and Emios_Pwm_Ip_Cfg header file are of the same software version */
|
|
#if ((EMIOS_PWM_IP_SW_MAJOR_VERSION != EMIOS_PWM_IP_CFG_SW_MAJOR_VERSION) || \
|
|
(EMIOS_PWM_IP_SW_MINOR_VERSION != EMIOS_PWM_IP_CFG_SW_MINOR_VERSION) || \
|
|
(EMIOS_PWM_IP_SW_PATCH_VERSION != EMIOS_PWM_IP_CFG_SW_PATCH_VERSION))
|
|
#error "Software version numbers of Emios_Pwm_Ip.h and Emios_Pwm_Ip_Cfg.h are different."
|
|
#endif
|
|
|
|
/* Check if header file and Emios_Pwm_Ip_Types header file are of the same vendor */
|
|
#if (EMIOS_PWM_IP_VENDOR_ID != EMIOS_PWM_IP_TYPES_VENDOR_ID)
|
|
#error "Vendor IDs of Emios_Pwm_Ip.h and Emios_Pwm_Ip_Types.h are different."
|
|
#endif
|
|
|
|
/* Check if header file and Emios_Pwm_Ip_Types header file are of the same AUTOSAR version */
|
|
#if ((EMIOS_PWM_IP_AR_RELEASE_MAJOR_VERSION != EMIOS_PWM_IP_TYPES_AR_RELEASE_MAJOR_VERSION) || \
|
|
(EMIOS_PWM_IP_AR_RELEASE_MINOR_VERSION != EMIOS_PWM_IP_TYPES_AR_RELEASE_MINOR_VERSION) || \
|
|
(EMIOS_PWM_IP_AR_RELEASE_REVISION_VERSION != EMIOS_PWM_IP_TYPES_AR_RELEASE_REVISION_VERSION))
|
|
#error "AUTOSAR version numbers of Emios_Pwm_Ip.h and Emios_Pwm_Ip_Types.h are different."
|
|
#endif
|
|
|
|
/* Check if header file and Emios_Pwm_Ip_Types header file are of the same software version */
|
|
#if ((EMIOS_PWM_IP_SW_MAJOR_VERSION != EMIOS_PWM_IP_TYPES_SW_MAJOR_VERSION) || \
|
|
(EMIOS_PWM_IP_SW_MINOR_VERSION != EMIOS_PWM_IP_TYPES_SW_MINOR_VERSION) || \
|
|
(EMIOS_PWM_IP_SW_PATCH_VERSION != EMIOS_PWM_IP_TYPES_SW_PATCH_VERSION))
|
|
#error "Software version numbers of Emios_Pwm_Ip.h and Emios_Pwm_Ip_Types.h are different."
|
|
#endif
|
|
|
|
/*==================================================================================================
|
|
* CONSTANTS
|
|
==================================================================================================*/
|
|
|
|
/*==================================================================================================
|
|
* DEFINES AND MACROS
|
|
==================================================================================================*/
|
|
|
|
/*==================================================================================================
|
|
* ENUMS
|
|
==================================================================================================*/
|
|
|
|
/*==================================================================================================
|
|
* STRUCTURES AND OTHER TYPEDEFS
|
|
==================================================================================================*/
|
|
|
|
/*==================================================================================================
|
|
* GLOBAL VARIABLE DECLARATIONS
|
|
==================================================================================================*/
|
|
|
|
/*==================================================================================================
|
|
* FUNCTION PROTOTYPES
|
|
==================================================================================================*/
|
|
#define PWM_START_SEC_CODE
|
|
#include "Pwm_MemMap.h"
|
|
|
|
/**
|
|
* @brief Initialize PWM Mode
|
|
*
|
|
* @param[in] instance The eMIOS group id
|
|
* @param[in] pwmParam A pointer to the PWM configuration structure
|
|
* @return void
|
|
*/
|
|
void Emios_Pwm_Ip_InitChannel(uint8 instance,
|
|
Emios_Pwm_Ip_ChannelConfigType const *userChCfg);
|
|
|
|
/**
|
|
* @brief Reset eMIOS channel to GPIO mode (reset default)
|
|
*
|
|
* @param[in] instance The eMIOS group id
|
|
* @param[in] channel The channel in this eMIOS group
|
|
* @param[in] safeState The channel ouput pin state after de-init
|
|
* @return void
|
|
*/
|
|
void Emios_Pwm_Ip_DeInitChannel(uint8 instance,
|
|
uint8 channel);
|
|
|
|
/**
|
|
* @brief Allow the software to force the output flip-flop to the level corresponding
|
|
* to a match on leading edge. The FLAG bit is not set.
|
|
*
|
|
* @param[in] instance The eMIOS group id
|
|
* @param[in] channel The channel in this eMIOS group
|
|
* @return void
|
|
*/
|
|
void Emios_Pwm_Ip_ForceMatchLeadingEdge(uint8 instance,
|
|
uint8 channel,
|
|
boolean enable);
|
|
|
|
/**
|
|
* @brief Allow the software to force the output flip-flop to the level corresponding
|
|
* to a match on trailing edge. The FLAG bit is not set.
|
|
*
|
|
* @param[in] instance The eMIOS group id
|
|
* @param[in] channel The channel in this eMIOS group
|
|
* @return void
|
|
*/
|
|
void Emios_Pwm_Ip_ForceMatchTrailingEdge(uint8 instance,
|
|
uint8 channel,
|
|
boolean enable);
|
|
|
|
/**
|
|
* @brief Get Period value in PWM mode
|
|
*
|
|
* @param[in] instance The eMIOS group id
|
|
* @param[in] channel The channel in this eMIOS group
|
|
* @param[out] retPeriod A pointer to return period value
|
|
* @return uint32 Value of period
|
|
*/
|
|
uint16 Emios_Pwm_Ip_GetPeriod(uint8 instance,
|
|
uint8 channel);
|
|
|
|
/**
|
|
* @brief Set new Period value in PWM mode
|
|
*
|
|
* @param[in] instance The eMIOS group id
|
|
* @param[in] channel The channel in this eMIOS group
|
|
* @param[in] newPeriod New Period value
|
|
* @return void
|
|
*/
|
|
void Emios_Pwm_Ip_SetPeriod(uint8 instance,
|
|
uint8 channel,
|
|
uint16 newPeriod);
|
|
|
|
/**
|
|
* @brief Get Duty Cycle value in PWM mode
|
|
*
|
|
* @param[in] instance The eMIOS group id
|
|
* @param[in] channel The channel in this eMIOS group
|
|
* @return uint32 Value of duty cycle
|
|
*/
|
|
uint16 Emios_Pwm_Ip_GetDutyCycle(uint8 instance,
|
|
uint8 channel);
|
|
|
|
/**
|
|
* @brief Set new Duty Cycle value in PWM mode
|
|
*
|
|
* @param[in] instance The eMIOS group id
|
|
* @param[in] channel The channel in this eMIOS group
|
|
* @param[in] newDutyCycle New duty cycle value
|
|
* @return operation status
|
|
* - EMIOS_PWM_STATUS_SUCCESS : Operation was successful.
|
|
* - EMIOS_PWM_STATUS_ERROR : Operation failed, invalid input value.
|
|
*/
|
|
Emios_Pwm_Ip_StatusType Emios_Pwm_Ip_SetDutyCycle(uint8 instance,
|
|
uint8 channel,
|
|
uint16 newDutyCycle);
|
|
|
|
/**
|
|
* @brief Get Leading Edge Placement value in PWM mode
|
|
*
|
|
* @param[in] instance The eMIOS group id
|
|
* @param[in] channel The channel in this eMIOS group
|
|
* @return uint32 Value of leading edge placement in counter bus time base
|
|
*/
|
|
uint16 Emios_Pwm_Ip_GetPhaseShift(uint8 instance,
|
|
uint8 channel);
|
|
|
|
/**
|
|
* @brief Set new Leading edge placement value in PWM mode
|
|
*
|
|
* @param[in] instance The eMIOS group id
|
|
* @param[in] channel The channel in this eMIOS group
|
|
* @param[in] phaseShift New Phase Shift value
|
|
* @return void
|
|
*/
|
|
Emios_Pwm_Ip_StatusType Emios_Pwm_Ip_SetPhaseShift(uint8 instance,
|
|
uint8 channel,
|
|
uint16 phaseShift);
|
|
|
|
/**
|
|
* @brief Get dead time value in PWM mode
|
|
*
|
|
* @param[in] instance The eMIOS group id
|
|
* @param[in] channel The channel in this eMIOS group
|
|
* @return uint32 Value of Dead Time
|
|
*/
|
|
uint16 Emios_Pwm_Ip_GetDeadTime(uint8 instance,
|
|
uint8 channel);
|
|
|
|
/**
|
|
* @brief Set new dead time value in PWM mode
|
|
*
|
|
* @param[in] instance The eMIOS group id
|
|
* @param[in] channel The channel in this eMIOS group
|
|
* @param[in] newDeadTime New Dead Time value
|
|
* @return void
|
|
*/
|
|
void Emios_Pwm_Ip_SetDeadTime(uint8 instance,
|
|
uint8 channel,
|
|
uint16 newDeadTime);
|
|
|
|
/**
|
|
* @brief Get Trigger Placement value in PWM mode
|
|
*
|
|
* @param[in] instance The eMIOS group id
|
|
* @param[in] channel The channel in this eMIOS group
|
|
* @return uint32 Value of Trigger Placement
|
|
*/
|
|
uint32 Emios_Pwm_Ip_GetTriggerPlacement(uint8 instance,
|
|
uint8 channel);
|
|
|
|
/**
|
|
* @brief Set new Trigger Placement value in PWM mode
|
|
*
|
|
* @param[in] instance The eMIOS group id
|
|
* @param[in] channel The channel in this eMIOS group
|
|
* @param[in] newTriggerPlacement New Trigger Placement value
|
|
* @return void
|
|
*/
|
|
void Emios_Pwm_Ip_SetTriggerPlacement(uint8 instance,
|
|
uint8 channel,
|
|
uint32 newTriggerPlacement);
|
|
|
|
/**
|
|
* @brief Set a channel enters freeze state, should be setting
|
|
* EMIOS_AllowEnterDebugMode first.
|
|
*
|
|
* @param[in] instance The eMIOS group id
|
|
* @param[in] channel The channel in this eMIOS group
|
|
* @return operation status
|
|
* - EMIOS_PWM_STATUS_SUCCESS : Operation was successful.
|
|
* - EMIOS_PWM_STATUS_ERROR : Operation failed, invalid input value.
|
|
* - EMIOS_PWM_STATUS_ENABLE_GLOBAL_FRZ : Need call EMIOS_AllowEnterDebugMode first.
|
|
*/
|
|
Emios_Pwm_Ip_StatusType Emios_Pwm_Ip_ChannelEnterDebugMode(uint8 instance,
|
|
uint8 channel);
|
|
|
|
/**
|
|
* @brief Release a channel from freeze state
|
|
*
|
|
* @param[in] instance The eMIOS group id
|
|
* @param[in] channel The channel in this eMIOS group
|
|
* @return void
|
|
*/
|
|
void Emios_Pwm_Ip_ChannelStopDebugMode(uint8 instance,
|
|
uint8 channel);
|
|
|
|
/**
|
|
* @brief Get the Unified Channel FLAG event generated. Interrupt or DMA request.
|
|
*
|
|
* @param[in] instance The eMIOS group id
|
|
* @param[in] channel The channel in this eMIOS group
|
|
* @return The FLAG event response type
|
|
*/
|
|
Emios_Pwm_Ip_InterruptType Emios_Pwm_Ip_GetFlagRequest(uint8 instance,
|
|
uint8 channel);
|
|
|
|
/**
|
|
* @brief Allow the Unified Channel FLAG bit to generate an interrupt signal or
|
|
* a DMA request signal
|
|
*
|
|
* @param[in] instance The eMIOS group id
|
|
* @param[in] channel The channel in this eMIOS group
|
|
* @param[in] event The FLAG event response type
|
|
* @return void
|
|
*/
|
|
void Emios_Pwm_Ip_SetFlagRequest(uint8 instance,
|
|
uint8 channel,
|
|
Emios_Pwm_Ip_InterruptType event);
|
|
|
|
/**
|
|
* @brief Get the Unified Channel output pin logic level
|
|
*
|
|
* @param[in] instance The eMIOS group id
|
|
* @param[in] channel The channel in this eMIOS group
|
|
* @return The Emios channel output pin state HIGH/LOW
|
|
*/
|
|
Emios_Pwm_Ip_OutputStateType Emios_Pwm_Ip_GetOutputState(uint8 instance,
|
|
uint8 channel);
|
|
|
|
/**
|
|
* @brief Set the state of output pin
|
|
*
|
|
* @param[in] instance The eMIOS group id
|
|
* @param[in] channel The channel in this eMIOS group
|
|
* @param[in] outputState The state of output pin
|
|
* @return void
|
|
*/
|
|
void Emios_Pwm_Ip_SetOutputState(uint8 instance,
|
|
uint8 channel,
|
|
Emios_Pwm_Ip_OutputStateType outputState);
|
|
|
|
/**
|
|
* @brief Set the polarity and mode for current channel as normal
|
|
*
|
|
* @param[in] instance The eMIOS group id
|
|
* @param[in] channel The channel in this eMIOS group
|
|
* @param[in] dutyPercent the range of duty cycle value :0x00(0%) ->0x8000(100%)
|
|
* @param[in] polarity The polarity of channel
|
|
* @param[in] mode Mode of channel
|
|
* @return void
|
|
*/
|
|
void Emios_Pwm_Ip_SetOutputToNormal(uint8 instance,
|
|
uint8 channel,
|
|
uint16 dutyPercent,
|
|
Emios_Pwm_Ip_PolarityType polarity,
|
|
Emios_Pwm_Ip_PwmModeType mode);
|
|
|
|
/**
|
|
* @brief Get mode of operation of the Unified Channel
|
|
*
|
|
* @param[in] instance The eMIOS group id
|
|
* @param[in] channel The channel in this eMIOS group
|
|
* @return Emios_Pwm_Ip_PwmModeType
|
|
*/
|
|
Emios_Pwm_Ip_PwmModeType Emios_Pwm_Ip_GetChannelMode(uint8 instance,
|
|
uint8 channel);
|
|
|
|
/**
|
|
* @brief Get master bus channel
|
|
*
|
|
* @param[in] instance The eMIOS group id
|
|
* @param[in] channel The channel in this eMIOS group
|
|
* @return Emios_Pwm_Ip_PwmModeType
|
|
*/
|
|
uint8 Emios_Pwm_Ip_GetMasterBusChannel(uint8 instance,
|
|
uint8 channel);
|
|
|
|
/**
|
|
* @brief Set Prescaler Enable bit.
|
|
*
|
|
* @param[in] instance The eMIOS group id
|
|
* @param[in] channel The channel in this eMIOS group
|
|
* @param[in] value The value to set
|
|
* - 0 Prescaler disabled (no clock)
|
|
* - 1 Prescaler enabled
|
|
* @return void
|
|
*/
|
|
void Emios_Pwm_Ip_SetPreEnableClock(uint8 instance,
|
|
uint8 channel,
|
|
boolean value);
|
|
|
|
/**
|
|
* @brief Set Bus Select bits.
|
|
*
|
|
* @param[in] instance The eMIOS group id
|
|
* @param[in] channel The channel in this eMIOS group
|
|
* @param[in] value The value to set
|
|
* @return void
|
|
*/
|
|
void Emios_Pwm_Ip_SetBusSelected(uint8 instance,
|
|
uint8 channel,
|
|
Emios_Pwm_Ip_CounterBusSourceType value);
|
|
|
|
/**
|
|
* @brief This function set the value of the prescaler on eMios channels
|
|
*
|
|
* @param[in] instance The eMIOS group id
|
|
* @param[in] channel The channel in this eMIOS group
|
|
* @param[in] value The value to set
|
|
* @return void
|
|
*/
|
|
void Emios_Pwm_Ip_SetClockPs(uint8 instance,
|
|
uint8 channel,
|
|
Emios_Pwm_Ip_InternalClkPsType value);
|
|
|
|
/**
|
|
* @brief The function shall enable the output update for the corresponding channel.
|
|
*
|
|
* @param[in] instance Instance of EMIOS used.
|
|
* @param[in] channel EMIOS hardware channel used.
|
|
*/
|
|
void Emios_Pwm_Ip_ComparatorTransferEnable(uint8 instance, uint32 channelMask);
|
|
|
|
/**
|
|
* @brief The function shall disable the output update for the corresponding channel.
|
|
*
|
|
* @param[in] instance Instance of EMIOS used.
|
|
* @param[in] channel EMIOS hardware channel used.
|
|
*/
|
|
void Emios_Pwm_Ip_ComparatorTransferDisable(uint8 instance, uint32 channelMask);
|
|
|
|
/**
|
|
* @brief This function updates the duty cycle and-or period for the specified PWM channel.
|
|
* The value written does not take effect until calling SyncUpdate API.
|
|
*
|
|
* @param instance eMIOS hardware module index
|
|
*
|
|
* @return void
|
|
*
|
|
*/
|
|
void Emios_Pwm_Ip_SyncUpdate(uint8 instance);
|
|
|
|
#define PWM_STOP_SEC_CODE
|
|
#include "Pwm_MemMap.h"
|
|
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
/** @} */
|
|
|
|
#endif /* EMIOS_PWM_IP_H */
|