MCUSW
Pwm.h File Reference

Introduction

This file contains interface header for PWM MCAL driver.

Go to the source code of this file.

Data Structures

struct  Pwm_ChannelConfigType_PC
 Pwm channel configuration. More...
 
struct  Pwm_ConfigType_PC
 Pwm configuration structure. More...
 
struct  Pwm_ChannelConfigType
 Pwm channel configuration. More...
 
struct  Pwm_ConfigType
 Pwm configuration structure. More...
 
struct  Pwm_RegisterReadbackType
 PWM register readback structure. More...
 

Macros

#define PWM_USE_EPWM
 
#define PWM_DUTY_0_PERCENT   (0x0U)
 16bit value representing 0% of a period value More...
 
#define PWM_DUTY_100_PERCENT   (0x8000U)
 16 bit value representing 100% of a period value More...
 
#define PWM_DUTY_50_PERCENT   (0x4000U)
 16 bit value representing 50% of a period value More...
 
#define PWM_MAX_NUM_CHANNELS   (6U)
 
#define PWM_CHANNEL1   (0U)
 EPWM Channel 1, in MAIN DOMAIN. More...
 
#define PWM_CHANNEL2   (1U)
 EPWM Channel 2, in MAIN DOMAIN. More...
 
#define PWM_CHANNEL3   (2U)
 EPWM Channel 3, in MAIN DOMAIN. More...
 
#define PWM_CHANNEL4   (3U)
 EPWM Channel 4, in MAIN DOMAIN. More...
 
#define PWM_CHANNEL5   (4U)
 EPWM Channel 5, in MAIN DOMAIN. More...
 
#define PWM_CHANNEL6   (5U)
 EPWM Channel 6, in MAIN DOMAIN. More...
 
PWM Driver Module SW Version Info

Defines for PWM Driver version used for compatibility checks

#define PWM_SW_MAJOR_VERSION   (1U)
 Driver Implementation Major Version. More...
 
#define PWM_SW_MINOR_VERSION   (3U)
 Driver Implementation Minor Version. More...
 
#define PWM_SW_PATCH_VERSION   (2U)
 Driver Implementation Patch Version. More...
 
PWM Driver Module AUTOSAR Version Info

Defines for PWM Driver AUTOSAR version used for compatibility checks

#define PWM_AR_RELEASE_MAJOR_VERSION   (4U)
 AUTOSAR Major version specification implemented by PWM Driver. More...
 
#define PWM_AR_RELEASE_MINOR_VERSION   (3U)
 AUTOSAR Minor version specification implemented by PWM Driver. More...
 
#define PWM_AR_RELEASE_REVISION_VERSION   (1U)
 AUTOSAR Patch version specification implemented by PWM Driver. More...
 
PWM Driver ID Info
#define PWM_VENDOR_ID   ((uint16) 44U)
 Texas Instruments Vendor ID. More...
 
#define PWM_MODULE_ID   ((uint16) 121U)
 PWM Driver Module ID. More...
 
#define PWM_INSTANCE_ID   (PWM_INDEX)
 PWM Driver Instance ID. More...
 
PWM Error Codes

Error codes returned by PWM functions

#define PWM_E_INIT_FAILED   ((uint8)(0x10U))
 PWM driver configuration parameter error. More...
 
#define PWM_E_UNINIT   ((uint8)(0x11U))
 PWM driver Not initialized error. More...
 
#define PWM_E_PARAM_CHANNEL   ((uint8)(0x12U))
 PWM driver Invalid param. More...
 
#define PWM_E_PERIOD_UNCHANGEABLE   ((uint8)(0x13U))
 PWM driver Fixed period channel. More...
 
#define PWM_E_ALREADY_INITIALIZED   ((uint8)(0x14U))
 PWM driver Already initialized. More...
 
#define PWM_E_PARAM_POINTER   ((uint8)(0x15U))
 PWM driver pointer paramter error. More...
 
#define PWM_E_NOT_DISENGAGED   ((uint8)(0x16U))
 RunTime Error: API Pwm_SetPowerState is called while the PWM module is still in use. More...
 
PWM Service Ids

The Service Id is one of the argument to Det_ReportError function and is used to identify the source of the error

#define PWM_SID_INIT   ((uint8)(0x0U))
 PWM driver service ID for Initialization API. More...
 
#define PWM_SID_DEINIT   ((uint8)(0x1U))
 PWM driver service ID for De-Initialization API. More...
 
#define PWM_SID_SET_DUTY_CYCLE   ((uint8)(0x2U))
 PWM driver service ID for set duty cycle API. More...
 
#define PWM_SID_SET_PERIOD_AND_DUTY   ((uint8)(0x3U))
 PWM driver service ID for set duty cycle and period API. More...
 
#define PWM_SID_SET_OUTPUT_TO_IDLE   ((uint8)(0x4U))
 PWM driver service ID for set output state to idle API. More...
 
#define PWM_SID_GET_OUTPUT_STATE   ((uint8)(0x5U))
 PWM driver service ID for get output state API. More...
 
#define PWM_SID_DISABLE_NOTIFICATION   ((uint8)(0x6U))
 PWM driver service ID for disable notification API. More...
 
#define PWM_SID_ENABLE_NOTIFICATION   ((uint8)(0x7U))
 PWM driver service ID for Enable notification API. More...
 
#define PWM_SID_GET_VERSION_INFO   ((uint8)(0x8U))
 PWM driver service ID for Get version info API. More...
 
#define PWM_SID_REGISTER_READBACK   ((uint8)(0xDU))
 PWM driver service ID for Critical register read back API. More...
 
PWM Driver State Values

The PWM Driver State Values

#define PWM_STATUS_UNINIT   ((uint8)(0U))
 PWM driver Status uninitialized. More...
 
#define PWM_STATUS_INIT   ((uint8)(1U))
 PWM driver Status Initialized. More...
 

Typedefs

typedef uint32 Pwm_PeriodType
 typedef of period value More...
 
typedef uint32 Pwm_ChannelType
 PWM Channel type. More...
 
typedef uint32 Pwm_FrequencyType
 typedef of frequency value (Frequency in Hz) More...
 
typedef void(* Pwm_NotifyFuncType) (void)
 Notification callback function pointer. More...
 

Enumerations

enum  Pwm_OutputStateType { PWM_LOW = 0U, PWM_HIGH }
 Possible output states of a PWM channel. More...
 
enum  Pwm_EdgeNotificationType { PWM_RISING_EDGE = 1U, PWM_FALLING_EDGE = 2U, PWM_BOTH_EDGES = 3U }
 Possible edge notification. More...
 
enum  Pwm_ChannelClassType { PWM_FIXED_PERIOD = 0U, PWM_FIXED_PERIOD_SHIFTED, PWM_VARIABLE_PERIOD }
 Period type for pwm channels. Fixed periods prohibit changes to the period length with Pwm_SetPeriod( ). PWM_FIXED_PERIOD_SHIFTED type is not supported due to hardware restrictions of the PWM unit. More...
 
enum  Pwm_epwmOutputCh_t { EPWM_OUTPUT_CH_A = 0U, EPWM_OUTPUT_CH_B = 1U, EPWM_OUTPUT_CH_BOTH_A_AND_B = 2U }
 EPWM outputs in a single epwm channel. More...
 

Functions

void Pwm_Init (const Pwm_ConfigType *CfgPtr)
 Service for PWM initialization. More...
 
void Pwm_DeInit (void)
 Service for PWM de-initialization. More...
 
void Pwm_SetDutyCycle (Pwm_ChannelType ChannelNumber, uint16 DutyCycle)
 Service for setting Duty Cycle. More...
 
void Pwm_SetPeriodAndDuty (Pwm_ChannelType ChannelNumber, Pwm_PeriodType Period, uint16 DutyCycle)
 Service for setting Period and Duty Cycle. More...
 
void Pwm_SetOutputToIdle (Pwm_ChannelType ChannelNumber)
 Service to set the output of a channel immediately to idle. More...
 
void Pwm_DisableNotification (Pwm_ChannelType ChannelNumber)
 Service to disable the Edge Notification. More...
 
void Pwm_EnableNotification (Pwm_ChannelType ChannelNumber, Pwm_EdgeNotificationType Notification)
 Service to enable the Edge Notification. More...
 
void Pwm_GetVersionInfo (Std_VersionInfoType *versioninfo)
 This service returns the version information of this module. More...
 
Std_ReturnType Pwm_RegisterReadback (Pwm_ChannelType ChannelNumber, Pwm_RegisterReadbackType *RegRbPtr)
 This function reads the important registers of the hardware unit and returns the value in the structure. More...