PWM Driver (Pwm)
Generates pulse-width-modulated signals with configurable duty cycle and period.
Funktionen — Übersicht
void Pwm_Init (const Pwm_ConfigType* ConfigPtr);Service for PWM initialization.void Pwm_DeInit (void);Service for PWM De - Initialization.void Pwm_SetDutyCycle (Pwm_ChannelType ChannelNumber, uint16 DutyCycle);Service sets the duty cycle of the PWM channel.void Pwm_SetPeriodAndDuty (Pwm_ChannelType ChannelNumber, Pwm_PeriodType Period, uint16 DutyCycle);Service sets the period and the duty cycle of a PWM channelvoid Pwm_SetOutputToIdle (Pwm_ChannelType ChannelNumber);Service sets the PWM output to the configured Idle state.Pwm_OutputStateType Pwm_GetOutputState (Pwm_ChannelType ChannelNumber);Service to read the internal state of the PWM out put signal.void Pwm_DisableNotification (Pwm_ChannelType ChannelNumber);Service to disable the PWM signal edge notification.void Pwm_EnableNotification (Pwm_ChannelType ChannelNumber, Pwm_EdgeNotificationType Notification);Service to enable the PWM signal edge notification according to notification pa rameter.Std_ReturnType Pwm_SetPowerState (Pwm_PowerStateRequestResultType* Result);This API configures the Pwm module so that it enters the already prepared power st ate, chosen between a predefined set of...Std_ReturnType Pwm_GetCurrentPowerState (Pwm_PowerStateType* CurrentPowerState, Pwm_PowerStateRequestResultType* Result);This API returns the current power state of the PWM HW unit.Std_ReturnType Pwm_GetTargetPowerState (Pwm_PowerStateType* TargetPowerState, Pwm_PowerStateRequestResultType* Result);This API returns the Target power state of the PWM HW unit.Std_ReturnType Pwm_PreparePowerState (Pwm_PowerStateType PowerState, Pwm_PowerStateRequestResultType* Result);This API starts the needed process to allow the PWM HW module to enter the requested power state.void Pwm_GetVersionInfo (Std_VersionInfoType* versioninfo);Service returns the version information of this module.void Pwm_Main_PowerTransitionManager (void);This API is cyclically called and supervises the power state transitions, checking for the readiness of the module and issuing...void Pwm_ (void);The Pwm module shall call the function Pwm_ Notification_ accordingly to the last call of Pwm_ Enable Notification for channel.void IoHwAb_Pwm_NotifyReadyForPower (void);The API shall be invoked by the PWM Driver when the requested power state preparation for mode is completed.
Typen — Übersicht
Pwm_ChannelTypeNume ric identifier of a PWM channel.Pwm_PeriodTypeDefinition of the period of a PWM channel.enum Pwm_OutputStateTypeOutput state of a PWM channel.Pwm_EdgeNotificationTypeDefinition of the type of edge notification of a PWM channel.Pwm_ChannelClassTypeDefines the class of a PWM channelstruct Pwm_ConfigTypeThis is the type of data structure containing the initialization data for the PWM driver.enum Pwm_PowerStateRequestResultTypeResult of the requests related to power state transitions.enum Pwm_PowerStateTypePower state currently active or set as target power state.
Funktionen & Typen — Detailansicht
function Pwm_Init [SWS_Pwm_00095] 📄 PDF
void Pwm_Init (const Pwm_ConfigType* ConfigPtr);
Service for PWM initialization.
The synchronous function Pwm_Init serves as the central service for initializing the entire PWM driver ([SWS_Pwm_00095]). It is provided via header file Pwm.h and has the hexadecimal service ID 0x00 ([SWS_Pwm_00095]). As the sole input parameter, ConfigPtr is passed, which acts as a pointer to the driver-specific configuration set of type Pwm_ConfigType ([SWS_Pwm_00095]). The interface has no return value and uses neither output parameters nor input/output parameters ([SWS_Pwm_00095]).
Regarding runtime behavior, Pwm_Init is synchronous and specified as non-reentrant (Non Reentrant) ([SWS_Pwm_00095]). A concurrent or interrupting call to this function from multiple threads, tasks, or interrupt service routines is therefore strictly impermissible. Execution is typically expected to occur once during system startup in the ECU initialization phase prior to further use of the PWM channels. Question Q-ff3f1cf769dfed70 (open)
To safeguard the permissible call sequence, the module monitors its state: If service Pwm_Init is called when the PWM driver is already initialized, the module reports the development error PWM_E_ALREADY_INITIALIZED with the identifier 0x14 ([SWS_Pwm_50002]). Repeated initialization is thus treated as an error.
This text was created by an AI. AUTOSAR specifications are authoritative.
Implementer's Guide to follow (complexity I1)
function Pwm_DeInit [SWS_Pwm_00096] 📄 PDF
void Pwm_DeInit (void);
Service for PWM De - Initialization.
Usage and signature
The function Pwm_DeInit serves as a service for de-initializing the PWM driver ([SWS_Pwm_00096]). It is provided via the header file Pwm.h and carries the service ID 0x01 ([SWS_Pwm_00096]). The interface has the signature void Pwm_DeInit(void), accepts neither input nor output parameters, and returns no value to the caller ([SWS_Pwm_00096]).
The call to Pwm_DeInit is executed synchronously ([SWS_Pwm_00096]). The calling control flow thus remains in the function until the de-initialization steps of the PWM module are completed.
Concurrency and Limitations
The following boundary conditions regarding concurrency apply to the execution:
- Non-reentrant: The service is specified as non-reentrant ([SWS_Pwm_00096]). Simultaneous or interrupting calls from multiple threads, tasks, or ISRs are not permitted.
- Call context: Due to the synchronous semantics and the lack of reentrancy, the call is likely to take place typically during a controlled shutdown phase at task level. Question Q-f1afc58637cba5cf (open)
Error handling
Neither return values nor specific error codes are defined in the specification of Pwm_DeInit ([SWS_Pwm_00096]). Any runtime or state errors are presumably likely to be logged or caught via module-internal monitoring mechanisms such as the development error tracer (DET), since direct error feedback via the function interface is not provided. Question (open)
This text was automatically generated based on the specification AUTOSAR Classic R20-11.
function Pwm_SetDutyCycle [SWS_Pwm_91000] 📄 PDF
void Pwm_SetDutyCycle (Pwm_ChannelType ChannelNumber, uint16 DutyCycle);
Service sets the duty cycle of the PWM channel.
function Pwm_SetPeriodAndDuty [SWS_Pwm_91001] 📄 PDF
void Pwm_SetPeriodAndDuty (Pwm_ChannelType ChannelNumber, Pwm_PeriodType Period, uint16 DutyCycle);
Service sets the period and the duty cycle of a PWM channel
function Pwm_SetOutputToIdle [SWS_Pwm_91002] 📄 PDF
void Pwm_SetOutputToIdle (Pwm_ChannelType ChannelNumber);
Service sets the PWM output to the configured Idle state.
function Pwm_GetOutputState [SWS_Pwm_00100] 📄 PDF
Pwm_OutputStateType Pwm_GetOutputState (Pwm_ChannelType ChannelNumber);
Service to read the internal state of the PWM out put signal.
function Pwm_DisableNotification [SWS_Pwm_91003] 📄 PDF
void Pwm_DisableNotification (Pwm_ChannelType ChannelNumber);
Service to disable the PWM signal edge notification.
The function Pwm_DisableNotification serves to disable the edge notification (Signal Edge Notification) of a specific PWM channel [SWS_Pwm_91003]. The function declaration and associated type definitions are provided via the header file Pwm.h [SWS_Pwm_91003].
Parameters and Return Value
The interface has the service ID 0x06 and exhibits the following signature characteristics [SWS_Pwm_91003]:
ChannelNumber(in): Numeric identifier of the PWM channel to be configured of typePwm_ChannelType[SWS_Pwm_91003].
There are neither input/output parameters (inout) nor pure output parameters (out) [SWS_Pwm_91003]. The function returns no return value (void) to the caller [SWS_Pwm_91003].
Synchronization Behavior and Concurrency
The call to Pwm_DisableNotification operates asynchronously [SWS_Pwm_91003]. With respect to multithreading behavior, the service is reentrant as long as different channel numbers are addressed [SWS_Pwm_91003].
Interpretation: Because reentrancy is explicitly restricted to different channels, the function is presumably not reentrant for the same PWM channel [SWS_Pwm_91003]. Question Q-005e97fd25679da7 (open) Simultaneous calls for the identical channel are therefore likely to have to be synchronized against each other on the caller side.
Curated usage notes based on the specification AUTOSAR Classic R20-11.
function Pwm_EnableNotification [SWS_Pwm_91004] 📄 PDF
void Pwm_EnableNotification (Pwm_ChannelType ChannelNumber, Pwm_EdgeNotificationType Notification);
Service to enable the PWM signal edge notification according to notification pa rameter.
use
The function Pwm_EnableNotification serves to enable signal edge notifications for a specific PWM channel according to the passed notification parameter [SWS_Pwm_91004]. The service is provided via the header file Pwm.h, has service ID 0x07, and returns no value (void) to the caller [SWS_Pwm_91004].
When calling the interface, two mandatory input parameters must be passed [SWS_Pwm_91004]:
ChannelNumber(of typePwm_ChannelType): Numeric identifier of the PWM channel to be addressed [SWS_Pwm_91004].Notification(of typePwm_EdgeNotificationType): Defines the type of edge notification with the permitted valuesPWM_RISING_EDGE,PWM_FALLING_EDGE, orPWM_BOTH_EDGES[SWS_Pwm_91004].
Semantics and concurrency
The execution of the service is specified as asynchronous [SWS_Pwm_91004]. Regarding concurrency, Pwm_EnableNotification is designed to be reentrant for different channel numbers [SWS_Pwm_91004]. In the event of simultaneous or interrupting access to the same PWM channel, the service is presumably non-reentrant; such a call must therefore be safeguarded on the caller side. Question Q-73309ed8589161a3 (open)
Error Handling and Boundary Conditions
The specification excerpt defines neither specific return values nor error messages for the Development Error Tracer (DET) or the Diagnostic Event Manager (DEM) for this function [SWS_Pwm_91004]. Likewise, specifications regarding permitted call contexts or task-related execution sequences are absent. Since no preconditions are stated, the function call is likely to be permissible only after successful initialization of the PWM driver. Question Q-7f428f59a20175c2 (open)
This usage note was generated automatically based on the specification excerpt of AUTOSAR Classic R20-11.
function Pwm_SetPowerState [SWS_Pwm_00166] 📄 PDF
Std_ReturnType Pwm_SetPowerState (Pwm_PowerStateRequestResultType* Result);
This API configures the Pwm module so that it enters the already prepared power st ate, chosen between a predefined set of configured ones.
The synchronous function Pwm_SetPowerState sets the PWM module to a previously prepared state from a preconfigured selection of power states [SWS_Pwm_00166]. The declaration is available via header Pwm.h [SWS_Pwm_00166].
Usage and return values
The function takes no input parameters and passes the detailed result via the pointer parameter Result of type Pwm_PowerStateRequestResultType* [SWS_Pwm_00166]:
- If the mode could be changed successfully, the function returns
E_OKand setsResulttoPWM_SERVICE_ACCEPTED[SWS_Pwm_00166]. - If the request is rejected, the call returns
E_NOT_OK[SWS_Pwm_00166].
Error handling
In case of an error (return value E_NOT_OK), Result specifies the cause of the failure [SWS_Pwm_00166]:
PWM_NOT_INIT: The PWM module is not initialized [SWS_Pwm_00166].PWM_SEQUENCE_ERROR: An invalid API call sequence has occurred [SWS_Pwm_00166].PWM_HW_FAILURE: An error in the hardware module prevents entry into the requested power state [SWS_Pwm_00166].
Concurrency and Constraints
Pwm_SetPowerState is non-reentrant (Non Reentrant) and, to avoid a sequence error, requires that the target state was prepared prior to the call [SWS_Pwm_00166].
This text was created by an AI based on the AUTOSAR specification.
Implementer's Guide to follow (complexity I1)
function Pwm_GetCurrentPowerState [SWS_Pwm_00177] 📄 PDF
Std_ReturnType Pwm_GetCurrentPowerState (Pwm_PowerStateType* CurrentPowerState, Pwm_PowerStateRequestResultType* Result);
This API returns the current power state of the PWM HW unit. AUTOSAR CP R20 - of Document ID : AUTOSAR_SWS_PWMDriver
function Pwm_GetTargetPowerState [SWS_Pwm_00180] 📄 PDF
Std_ReturnType Pwm_GetTargetPowerState (Pwm_PowerStateType* TargetPowerState, Pwm_PowerStateRequestResultType* Result);
This API returns the Target power state of the PWM HW unit.
function Pwm_PreparePowerState [SWS_Pwm_00183] 📄 PDF
Std_ReturnType Pwm_PreparePowerState (Pwm_PowerStateType PowerState, Pwm_PowerStateRequestResultType* Result);
This API starts the needed process to allow the PWM HW module to enter the requested power state. AUTOSAR CP R20 - of Document ID : AUTOSAR_SWS_PWMDriver
use
The synchronous function Pwm_PreparePowerState initiates the required preparation process so that the PWM hardware module can transition into a requested power state [SWS_Pwm_00183]. The desired target state is passed via parameter PowerState, while the detailed result is provided via the output pointer Result [SWS_Pwm_00183]. If the preparation was initiated successfully, the function returns E_OK and sets Result to PWM_SERVICE_ACCEPTED [SWS_Pwm_00183].
Error handling
If the service is rejected, the function returns E_NOT_OK and reports the specific cause via Result [SWS_Pwm_00183]:
PWM_NOT_INIT: The PWM module is not initialized [SWS_Pwm_00183].PWM_SEQUENCE_ERROR: Invalid call sequence, as the current power state already corresponds to the target state [SWS_Pwm_00183].PWM_POWER_STATE_NOT_SUPP: The module does not support the requested power state [SWS_Pwm_00183].PWM_TRANS_NOT_POSSIBLE: A direct transition is not possible or the hardware peripheral is still busy [SWS_Pwm_00183].
Concurrency and Interaction
The function is non-reentrant (Non Reentrant) and therefore must not be called concurrently for the same module [SWS_Pwm_00183]. After successful preparation by Pwm_PreparePowerState, downstream actions that do not take effect immediately must be executed to finalize the power state transition [SWS_Pwm_00190].
This usage note was generated automatically based on specification R20-11.
Implementer's Guide to follow (complexity I1)
function Pwm_GetVersionInfo [SWS_Pwm_00103] 📄 PDF
void Pwm_GetVersionInfo (Std_VersionInfoType* versioninfo);
Service returns the version information of this module.
function Pwm_Main_PowerTransitionManager [SWS_Pwm_00189] 📄 PDF
void Pwm_Main_PowerTransitionManager (void);
This API is cyclically called and supervises the power state transitions, checking for the readiness of the module and issuing the callbacks Io Hw Ab_ Pwm_ Notify Ready For Power State
The interface Pwm_Main_PowerTransitionManager is used for the cyclic monitoring of power state transitions of the PWM driver according to [SWS_Pwm_00189]. It has service ID 0x0d, takes no input parameters, and returns no value (signature void Pwm_Main_PowerTransitionManager(void)).
As part of its cyclic execution, the function checks the operational readiness of the module for the respective power state. As soon as readiness is established, it triggers the notification callbacks IoHwAb_Pwm_NotifyReadyForPowerState<Mode> that are referenced via the configuration parameter PwmPowerStateReadyCbkRef [SWS_Pwm_00189].
The function is intended for a cyclic call context and is provided via the header file SchM_Pwm.h. Consequently, the periodic call is likely to typically occur in the context of the BSW scheduler (Schedule Manager) [SWS_Pwm_00189]. Specific error codes, error handling mechanisms via DET or DEM, and special reentrancy conditions are not defined in the module specification for this service. Question Q-b9b0431e7ccbca88 (open)
This text was generated by an AI based on the AUTOSAR specification R20-11.
Implementer's Guide to follow (complexity I1)
function Pwm_ [SWS_Pwm_00105] 📄 PDF
void Pwm_Notification_<#Channel> (void);
The Pwm module shall call the function Pwm_ Notification_<#Channel> accordingly to the last call of Pwm_ Enable Notification for channel <#Channel>.
The channel-specific notification function Pwm_Notification_<#Channel> is called synchronously by the PWM module as soon as the edge event configured for the respective channel occurs [SWS_Pwm_00105]. The function has the signature void Pwm_Notification_<#Channel>(void), accepts no input parameters, and returns no value [SWS_Pwm_00105]. It is declared in the file Pwm_Externals.h and must be provided by the user [SWS_Pwm_00105].
The call is made depending on the last call to Pwm_EnableNotification for the channel in question [SWS_Pwm_00105]. The triggering events are based on the values of Pwm_EdgeNotificationType, which distinguishes rising (PWM_RISING_EDGE), falling (PWM_FALLING_EDGE), or both signal edges (PWM_BOTH_EDGES) [SWS_Pwm_00109]. Prior to signal generation and event notification, the PWM module must have been initialized via Pwm_Init with a hardware-dependent Pwm_ConfigType structure [SWS_Pwm_00095], [SWS_Pwm_00111].
With regard to concurrency, the reentrancy of the callback function is explicitly defined as user-dependent (PWM user implementation dependant) [SWS_Pwm_00105]. The exact execution context (such as whether the call occurs directly in an interrupt service routine or in task context) is likely to depend on the underlying driver implementation (interpretation). Question Q-327872e0e8fecb37 (open) Specific error codes, return values, or standardized DET or DEM messages do not exist for this notification interface [SWS_Pwm_00105].
This text was created by an AI and is based on the specification AUTOSAR Classic Release R20-11.
function IoHwAb_Pwm_NotifyReadyForPower [SWS_Pwm_00198] 📄 PDF
void IoHwAb_Pwm_NotifyReadyForPowerState<#Mode> (void);
The API shall be invoked by the PWM Driver when the requested power state preparation for mode <#Mode> is completed.
The function IoHwAb_Pwm_NotifyReadyForPower (declared in the syntax as IoHwAb_Pwm_NotifyReadyForPowerState<#Mode>) is provided via the header IoHwAb_Pwm.h and serves as a callback interface in AUTOSAR power management [SWS_Pwm_00198].
Regarding usage, interface properties, and system interaction, the following mandatory requirements apply:
- Usage and call context: The interface has the service ID
0x60and is executed synchronously [SWS_Pwm_00198]. It must mandatory be called by the PWM driver as soon as the device-side preparation for a requested power state of a mode has been successfully completed [SWS_Pwm_00198]. - Parameters and return values: The function signature defines neither input, input/output, nor output parameters and has no return value (
void) [SWS_Pwm_00198]. Interpretation: The assignment to the respective power mode is likely to be derived directly from the mode-specific function name in the source code. Question Q-ab761160ed91de78 (open) - Concurrency and restrictions: The function is specified as non-reentrant (
Non Reentrant) [SWS_Pwm_00198]. Calls must consequently not occur in parallel or nested within the same driver context. - Interaction: In the cross-module sequence, the call signals to the higher-level I/O hardware abstraction that the driver stage is ready for the transition to the desired operating state [SWS_Pwm_00198].
In the specification sources, no specific error codes or notifications to DET or DEM are provided for this function [SWS_Pwm_00198].
This text was created by an AI; all statements are based exclusively on the AUTOSAR specification.
Implementer's Guide to follow (complexity I1)
type Pwm_ChannelType [SWS_Pwm_00106] 📄 PDF
Nume ric identifier of a PWM channel.
type Pwm_PeriodType [SWS_Pwm_00107] 📄 PDF
Definition of the period of a PWM channel.
type Pwm_OutputStateType [SWS_Pwm_00108] 📄 PDF
Output state of a PWM channel.
The enumeration type Pwm_OutputStateType defines the output state of a PWM channel within the Classic AUTOSAR driver Pwm [SWS_Pwm_00108]. The type definition is provided via the header file Pwm.h for calling software units and driver applications [SWS_Pwm_00108].
The value range of this enumeration distinguishes two uniquely defined states of the channel [SWS_Pwm_00108]:
PWM_HIGH(numerical value0x00): Indicates that the PWM channel in question is in the high state [SWS_Pwm_00108].PWM_LOW(numerical value0x01): Indicates that the PWM channel in question is in the low state [SWS_Pwm_00108].
Regarding call context and intended use, the element itself as a type does not define any interface functions [SWS_Pwm_00108]. Interpretation: The values are typically likely to serve as parameters or return values in API functions of the module to signal the current or desired logical level state of a channel. Question Q-9c142d658ab7fcfd (open)
Since this is an elementary type definition, no specific error handlings regarding DET or DEM exist, nor are there any requirements for reentrancy or synchronous execution within the specification scope [SWS_Pwm_00108].
This text was generated by an AI based on the specification AUTOSAR Classic R20-11.
Implementer's Guide to follow (complexity I1)
type Pwm_EdgeNotificationType [SWS_Pwm_00109] 📄 PDF
Definition of the type of edge notification of a PWM channel.
type Pwm_ChannelClassType [SWS_Pwm_00110] 📄 PDF
Defines the class of a PWM channel
type Pwm_ConfigType [SWS_Pwm_00111] 📄 PDF
This is the type of data structure containing the initialization data for the PWM driver.
type Pwm_PowerStateRequestResultType [SWS_Pwm_00165] 📄 PDF
Result of the requests related to power state transitions.
The enumeration type Pwm_PowerStateRequestResultType provides the result of requests for changing the power management mode (power state transitions) in the PWM driver according to [SWS_Pwm_00165]. The type definition is available via the header Pwm.h [SWS_Pwm_00165].
The type maps both the successful transition and specific error conditions [SWS_Pwm_00165]:
PWM_SERVICE_ACCEPTED(0x00): The requested power state change was executed successfully [SWS_Pwm_00165].PWM_NOT_INIT(0x01): The PWM module is not yet initialized [SWS_Pwm_00165].PWM_SEQUENCE_ERROR(0x02): The call sequence of the API is invalid [SWS_Pwm_00165].PWM_HW_FAILURE(0x03): A hardware failure prevents entering the requested power state [SWS_Pwm_00165].PWM_POWER_STATE_NOT_SUPP(0x04): The requested state is not supported by the module [SWS_Pwm_00165].PWM_TRANS_NOT_POSSIBLE(0x05): A direct state transition is not possible or the hardware peripheral is still busy [SWS_Pwm_00165].
Callers must evaluate the result to determine whether a state change took effect immediately. Interpretation: The type is likely to typically serve as the return value or output parameter of corresponding power management functions in order to inform higher-level modules about transition conflicts or hardware blockages. Question Q-fd06829e5c030906 (open)
This text was generated by an AI and serves as guidance. The AUTOSAR specification is authoritative.
Implementer's Guide to follow (complexity I1)
type Pwm_PowerStateType [SWS_Pwm_00197] 📄 PDF
Power state currently active or set as target power state.
The enumeration type Pwm_PowerStateType is used in the PWM module to describe power states [SWS_Pwm_00197]. It represents either the currently active operating state or a newly specified target power state of the driver [SWS_Pwm_00197]. This data type is provided via the header file Pwm.h [SWS_Pwm_00197].
The specification defines the following values and value ranges for the enumeration [SWS_Pwm_00197]:
PWM_FULL_POWER(value0x00): Designates the full power state (“Full Power”) [SWS_Pwm_00197].- Value range
1..255: Defines graduated power modes with progressively decreasing power consumption (“power modes with decreasing power consumptions”) [SWS_Pwm_00197].
Regarding the usage context, the type is likely to serve as an input parameter when requesting a power-saving mode and as a return value during status queries, since the type represents both active and target states [SWS_Pwm_00197]. Question Q-f0423f8b958d7e91 (open) Specific API functions, error handling (DET/DEM), and concurrency restrictions are not included for this data type in the present specification excerpt and are therefore omitted [SWS_Pwm_00197].
This text was generated by an AI based on the AUTOSAR specification R20-11.
Implementer's Guide to follow (complexity I1)
Request a governed re-review of this record. The record is not changed immediately.
- Record
AUTOSAR/AP/record/CP_MOD_Pwm- Status
- unspecified
- Version
AUTOSAR/AP/record/CP_MOD_Pwm@rel:R20-11#e8f5496f- Content hash
e8f5496f- Source
- https://www.autosar.org/fileadmin/standards/R20-11/CP/AUTOSAR_SWS_PWMDriver.pdf#nameddest=SWS_Pwm_00095
gemini-3.8-flash-low· 2026-10-13 · German original