ChibiOS/HAL  6.1.0
PWM Driver

Generic PWM Driver. More...

Collaboration diagram for PWM Driver:

Detailed Description

Generic PWM Driver.

This module implements a generic PWM (Pulse Width Modulation) driver.

Precondition
In order to use the PWM driver the HAL_USE_PWM option must be enabled in halconf.h.

Driver State Machine

The driver implements a state machine internally, not all the driver functionalities can be used in any moment, any transition not explicitly shown in the following diagram has to be considered an error and shall be captured by an assertion (if enabled).

dot_inline_dotgraph_10.png

PWM Operations.

This driver abstracts a generic PWM timer composed of:

A PWM channel output can be in two different states:

Note that the two states can be associated to both logical zero or one in the PWMChannelConfig structure.

Macros

#define PWM_CHANNELS   4
 Number of PWM channels per PWM driver. More...
 
#define pwm_lld_change_period(pwmp, period)
 Changes the period the PWM peripheral. More...
 

PWM output mode macros

#define PWM_OUTPUT_MASK   0x0FU
 Standard output modes mask. More...
 
#define PWM_OUTPUT_DISABLED   0x00U
 Output not driven, callback only. More...
 
#define PWM_OUTPUT_ACTIVE_HIGH   0x01U
 Positive PWM logic, active is logic level one. More...
 
#define PWM_OUTPUT_ACTIVE_LOW   0x02U
 Inverse PWM logic, active is logic level zero. More...
 

PWM duty cycle conversion

#define PWM_FRACTION_TO_WIDTH(pwmp, denominator, numerator)
 Converts from fraction to pulse width. More...
 
#define PWM_DEGREES_TO_WIDTH(pwmp, degrees)   PWM_FRACTION_TO_WIDTH(pwmp, 36000, degrees)
 Converts from degrees to pulse width. More...
 
#define PWM_PERCENTAGE_TO_WIDTH(pwmp, percentage)   PWM_FRACTION_TO_WIDTH(pwmp, 10000, percentage)
 Converts from percentage to pulse width. More...
 

Macro Functions

#define pwmChangePeriodI(pwmp, value)
 Changes the period the PWM peripheral. More...
 
#define pwmEnableChannelI(pwmp, channel, width)
 Enables a PWM channel. More...
 
#define pwmDisableChannelI(pwmp, channel)
 Disables a PWM channel. More...
 
#define pwmIsChannelEnabledI(pwmp, channel)   (((pwmp)->enabled & ((pwmchnmsk_t)1U << (pwmchnmsk_t)(channel))) != 0U)
 Returns a PWM channel status. More...
 
#define pwmEnablePeriodicNotificationI(pwmp)   pwm_lld_enable_periodic_notification(pwmp)
 Enables the periodic activation edge notification. More...
 
#define pwmDisablePeriodicNotificationI(pwmp)   pwm_lld_disable_periodic_notification(pwmp)
 Disables the periodic activation edge notification. More...
 
#define pwmEnableChannelNotificationI(pwmp, channel)   pwm_lld_enable_channel_notification(pwmp, channel)
 Enables a channel de-activation edge notification. More...
 
#define pwmDisableChannelNotificationI(pwmp, channel)   pwm_lld_disable_channel_notification(pwmp, channel)
 Disables a channel de-activation edge notification. More...
 

PLATFORM configuration options

#define PLATFORM_PWM_USE_PWM1   FALSE
 PWMD1 driver enable switch. More...
 

Typedefs

typedef struct PWMDriver PWMDriver
 Type of a structure representing a PWM driver. More...
 
typedef void(* pwmcallback_t) (PWMDriver *pwmp)
 Type of a PWM notification callback. More...
 
typedef uint32_t pwmmode_t
 Type of a PWM mode. More...
 
typedef uint8_t pwmchannel_t
 Type of a PWM channel. More...
 
typedef uint32_t pwmchnmsk_t
 Type of a channels mask. More...
 
typedef uint32_t pwmcnt_t
 Type of a PWM counter. More...
 

Data Structures

struct  PWMChannelConfig
 Type of a PWM driver channel configuration structure. More...
 
struct  PWMConfig
 Type of a PWM driver configuration structure. More...
 
struct  PWMDriver
 Structure representing a PWM driver. More...
 

Functions

void pwmInit (void)
 PWM Driver initialization. More...
 
void pwmObjectInit (PWMDriver *pwmp)
 Initializes the standard part of a PWMDriver structure. More...
 
void pwmStart (PWMDriver *pwmp, const PWMConfig *config)
 Configures and activates the PWM peripheral. More...
 
void pwmStop (PWMDriver *pwmp)
 Deactivates the PWM peripheral. More...
 
void pwmChangePeriod (PWMDriver *pwmp, pwmcnt_t period)
 Changes the period the PWM peripheral. More...
 
void pwmEnableChannel (PWMDriver *pwmp, pwmchannel_t channel, pwmcnt_t width)
 Enables a PWM channel. More...
 
void pwmDisableChannel (PWMDriver *pwmp, pwmchannel_t channel)
 Disables a PWM channel and its notification. More...
 
void pwmEnablePeriodicNotification (PWMDriver *pwmp)
 Enables the periodic activation edge notification. More...
 
void pwmDisablePeriodicNotification (PWMDriver *pwmp)
 Disables the periodic activation edge notification. More...
 
void pwmEnableChannelNotification (PWMDriver *pwmp, pwmchannel_t channel)
 Enables a channel de-activation edge notification. More...
 
void pwmDisableChannelNotification (PWMDriver *pwmp, pwmchannel_t channel)
 Disables a channel de-activation edge notification. More...
 
void pwm_lld_init (void)
 Low level PWM driver initialization. More...
 
void pwm_lld_start (PWMDriver *pwmp)
 Configures and activates the PWM peripheral. More...
 
void pwm_lld_stop (PWMDriver *pwmp)
 Deactivates the PWM peripheral. More...
 
void pwm_lld_enable_channel (PWMDriver *pwmp, pwmchannel_t channel, pwmcnt_t width)
 Enables a PWM channel. More...
 
void pwm_lld_disable_channel (PWMDriver *pwmp, pwmchannel_t channel)
 Disables a PWM channel and its notification. More...
 
void pwm_lld_enable_periodic_notification (PWMDriver *pwmp)
 Enables the periodic activation edge notification. More...
 
void pwm_lld_disable_periodic_notification (PWMDriver *pwmp)
 Disables the periodic activation edge notification. More...
 
void pwm_lld_enable_channel_notification (PWMDriver *pwmp, pwmchannel_t channel)
 Enables a channel de-activation edge notification. More...
 
void pwm_lld_disable_channel_notification (PWMDriver *pwmp, pwmchannel_t channel)
 Disables a channel de-activation edge notification. More...
 

Enumerations

Variables

PWMDriver PWMD1
 PWMD1 driver identifier. More...
 

Macro Definition Documentation

#define PWM_OUTPUT_MASK   0x0FU

Standard output modes mask.

Definition at line 41 of file hal_pwm.h.

#define PWM_OUTPUT_DISABLED   0x00U

Output not driven, callback only.

Definition at line 46 of file hal_pwm.h.

#define PWM_OUTPUT_ACTIVE_HIGH   0x01U

Positive PWM logic, active is logic level one.

Definition at line 51 of file hal_pwm.h.

#define PWM_OUTPUT_ACTIVE_LOW   0x02U

Inverse PWM logic, active is logic level zero.

Definition at line 56 of file hal_pwm.h.

#define PWM_FRACTION_TO_WIDTH (   pwmp,
  denominator,
  numerator 
)
Value:
((pwmcnt_t)((((pwmcnt_t)(pwmp)->period) * \
(pwmcnt_t)(numerator)) / (pwmcnt_t)(denominator)))
uint32_t pwmcnt_t
Type of a PWM counter.
Definition: hal_pwm_lld.h:83

Converts from fraction to pulse width.

Note
Be careful with rounding errors, this is integer math not magic. You can specify tenths of thousandth but make sure you have the proper hardware resolution by carefully choosing the clock source and prescaler settings, see PWM_COMPUTE_PSC.
Parameters
[in]pwmppointer to a PWMDriver object
[in]denominatordenominator of the fraction
[in]numeratornumerator of the fraction
Returns
The pulse width to be passed to pwmEnableChannel().
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 116 of file hal_pwm.h.

#define PWM_DEGREES_TO_WIDTH (   pwmp,
  degrees 
)    PWM_FRACTION_TO_WIDTH(pwmp, 36000, degrees)

Converts from degrees to pulse width.

Note
Be careful with rounding errors, this is integer math not magic. You can specify hundredths of degrees but make sure you have the proper hardware resolution by carefully choosing the clock source and prescaler settings, see PWM_COMPUTE_PSC.
Parameters
[in]pwmppointer to a PWMDriver object
[in]degreesdegrees as an integer between 0 and 36000
Returns
The pulse width to be passed to pwmEnableChannel().
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 133 of file hal_pwm.h.

#define PWM_PERCENTAGE_TO_WIDTH (   pwmp,
  percentage 
)    PWM_FRACTION_TO_WIDTH(pwmp, 10000, percentage)

Converts from percentage to pulse width.

Note
Be careful with rounding errors, this is integer math not magic. You can specify tenths of thousandth but make sure you have the proper hardware resolution by carefully choosing the clock source and prescaler settings, see PWM_COMPUTE_PSC.
Parameters
[in]pwmppointer to a PWMDriver object
[in]percentagepercentage as an integer between 0 and 10000
Returns
The pulse width to be passed to pwmEnableChannel().
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 149 of file hal_pwm.h.

#define pwmChangePeriodI (   pwmp,
  value 
)
Value:
{ \
(pwmp)->period = (value); \
pwm_lld_change_period(pwmp, value); \
}
#define pwm_lld_change_period(pwmp, period)
Changes the period the PWM peripheral.
Definition: hal_pwm_lld.h:181

Changes the period the PWM peripheral.

This function changes the period of a PWM unit that has already been activated using pwmStart().

Precondition
The PWM unit must have been activated using pwmStart().
Postcondition
The PWM unit period is changed to the new value.
Note
If a period is specified that is shorter than the pulse width programmed in one of the channels then the behavior is not guaranteed.
Parameters
[in]pwmppointer to a PWMDriver object
[in]valuenew cycle time in ticks
Function Class:This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 172 of file hal_pwm.h.

Referenced by pwmChangePeriod().

#define pwmEnableChannelI (   pwmp,
  channel,
  width 
)
Value:
do { \
(pwmp)->enabled |= ((pwmchnmsk_t)1U << (pwmchnmsk_t)(channel)); \
pwm_lld_enable_channel(pwmp, channel, width); \
} while (false)
void pwm_lld_enable_channel(PWMDriver *pwmp, pwmchannel_t channel, pwmcnt_t width)
Enables a PWM channel.
Definition: hal_pwm_lld.c:127
uint32_t pwmchnmsk_t
Type of a channels mask.
Definition: hal_pwm_lld.h:78

Enables a PWM channel.

Precondition
The PWM unit must have been activated using pwmStart().
Postcondition
The channel is active using the specified configuration.
Note
Depending on the hardware implementation this function has effect starting on the next cycle (recommended implementation) or immediately (fallback implementation).
Parameters
[in]pwmppointer to a PWMDriver object
[in]channelPWM channel identifier (0...channels-1)
[in]widthPWM pulse width as clock pulses number
Function Class:This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 191 of file hal_pwm.h.

Referenced by pwmEnableChannel().

#define pwmDisableChannelI (   pwmp,
  channel 
)
Value:
do { \
(pwmp)->enabled &= ~((pwmchnmsk_t)1U << (pwmchnmsk_t)(channel)); \
pwm_lld_disable_channel(pwmp, channel); \
} while (false)
uint32_t pwmchnmsk_t
Type of a channels mask.
Definition: hal_pwm_lld.h:78
void pwm_lld_disable_channel(PWMDriver *pwmp, pwmchannel_t channel)
Disables a PWM channel and its notification.
Definition: hal_pwm_lld.c:148

Disables a PWM channel.

Precondition
The PWM unit must have been activated using pwmStart().
Postcondition
The channel is disabled and its output line returned to the idle state.
Note
Depending on the hardware implementation this function has effect starting on the next cycle (recommended implementation) or immediately (fallback implementation).
Parameters
[in]pwmppointer to a PWMDriver object
[in]channelPWM channel identifier (0...channels-1)
Function Class:This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 210 of file hal_pwm.h.

Referenced by pwmDisableChannel().

#define pwmIsChannelEnabledI (   pwmp,
  channel 
)    (((pwmp)->enabled & ((pwmchnmsk_t)1U << (pwmchnmsk_t)(channel))) != 0U)

Returns a PWM channel status.

Precondition
The PWM unit must have been activated using pwmStart().
Parameters
[in]pwmppointer to a PWMDriver object
[in]channelPWM channel identifier (0...channels-1)
Function Class:This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 224 of file hal_pwm.h.

#define pwmEnablePeriodicNotificationI (   pwmp)    pwm_lld_enable_periodic_notification(pwmp)

Enables the periodic activation edge notification.

Precondition
The PWM unit must have been activated using pwmStart().
Note
If the notification is already enabled then the call has no effect.
Parameters
[in]pwmppointer to a PWMDriver object
Function Class:This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 236 of file hal_pwm.h.

Referenced by pwmEnablePeriodicNotification().

#define pwmDisablePeriodicNotificationI (   pwmp)    pwm_lld_disable_periodic_notification(pwmp)

Disables the periodic activation edge notification.

Precondition
The PWM unit must have been activated using pwmStart().
Note
If the notification is already disabled then the call has no effect.
Parameters
[in]pwmppointer to a PWMDriver object
Function Class:This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 248 of file hal_pwm.h.

Referenced by pwmDisablePeriodicNotification().

#define pwmEnableChannelNotificationI (   pwmp,
  channel 
)    pwm_lld_enable_channel_notification(pwmp, channel)

Enables a channel de-activation edge notification.

Precondition
The PWM unit must have been activated using pwmStart().
The channel must have been activated using pwmEnableChannel().
Note
If the notification is already enabled then the call has no effect.
Parameters
[in]pwmppointer to a PWMDriver object
[in]channelPWM channel identifier (0...channels-1)
Function Class:This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 262 of file hal_pwm.h.

Referenced by pwmEnableChannelNotification().

#define pwmDisableChannelNotificationI (   pwmp,
  channel 
)    pwm_lld_disable_channel_notification(pwmp, channel)

Disables a channel de-activation edge notification.

Precondition
The PWM unit must have been activated using pwmStart().
The channel must have been activated using pwmEnableChannel().
Note
If the notification is already disabled then the call has no effect.
Parameters
[in]pwmppointer to a PWMDriver object
[in]channelPWM channel identifier (0...channels-1)
Function Class:This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 276 of file hal_pwm.h.

Referenced by pwmDisableChannelNotification().

#define PWM_CHANNELS   4

Number of PWM channels per PWM driver.

Definition at line 37 of file hal_pwm_lld.h.

#define PLATFORM_PWM_USE_PWM1   FALSE

PWMD1 driver enable switch.

If set to TRUE the support for PWM1 is included.

Note
The default is FALSE.

Definition at line 53 of file hal_pwm_lld.h.

#define pwm_lld_change_period (   pwmp,
  period 
)

Changes the period the PWM peripheral.

This function changes the period of a PWM unit that has already been activated using pwmStart().

Precondition
The PWM unit must have been activated using pwmStart().
Postcondition
The PWM unit period is changed to the new value.
Note
The function has effect at the next cycle start.
If a period is specified that is shorter than the pulse width programmed in one of the channels then the behavior is not guaranteed.
Parameters
[in]pwmppointer to a PWMDriver object
[in]periodnew cycle time in ticks
Function Class:Not an API, this function is for internal use only.

Definition at line 181 of file hal_pwm_lld.h.

Typedef Documentation

typedef struct PWMDriver PWMDriver

Type of a structure representing a PWM driver.

Definition at line 83 of file hal_pwm.h.

typedef void(* pwmcallback_t) (PWMDriver *pwmp)

Type of a PWM notification callback.

Parameters
[in]pwmppointer to a PWMDriver object

Definition at line 90 of file hal_pwm.h.

typedef uint32_t pwmmode_t

Type of a PWM mode.

Definition at line 68 of file hal_pwm_lld.h.

typedef uint8_t pwmchannel_t

Type of a PWM channel.

Definition at line 73 of file hal_pwm_lld.h.

typedef uint32_t pwmchnmsk_t

Type of a channels mask.

Definition at line 78 of file hal_pwm_lld.h.

typedef uint32_t pwmcnt_t

Type of a PWM counter.

Definition at line 83 of file hal_pwm_lld.h.

Enumeration Type Documentation

enum pwmstate_t

Driver state machine possible states.

Enumerator
PWM_UNINIT 

Not initialized.

PWM_STOP 

Stopped.

PWM_READY 

Ready.

Definition at line 74 of file hal_pwm.h.

Function Documentation

void pwmInit ( void  )

PWM Driver initialization.

Note
This function is implicitly invoked by halInit(), there is no need to explicitly initialize the driver.
Function Class:Initializer, this function just initializes an object and can be invoked before the kernel is initialized.

Definition at line 56 of file hal_pwm.c.

References pwm_lld_init().

Referenced by halInit().

Here is the call graph for this function:

void pwmObjectInit ( PWMDriver pwmp)

Initializes the standard part of a PWMDriver structure.

Parameters
[out]pwmppointer to a PWMDriver object
Function Class:Initializer, this function just initializes an object and can be invoked before the kernel is initialized.

Definition at line 68 of file hal_pwm.c.

References PWMDriver::channels, PWMDriver::config, PWMDriver::enabled, PWM_STOP, and PWMDriver::state.

Referenced by pwm_lld_init().

void pwmStart ( PWMDriver pwmp,
const PWMConfig config 
)

Configures and activates the PWM peripheral.

Note
Starting a driver that is already in the PWM_READY state disables all the active channels.
Parameters
[in]pwmppointer to a PWMDriver object
[in]configpointer to a PWMConfig object
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 89 of file hal_pwm.c.

References PWMDriver::config, PWMDriver::enabled, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), PWMConfig::period, PWMDriver::period, pwm_lld_start(), PWM_READY, PWM_STOP, and PWMDriver::state.

Here is the call graph for this function:

void pwmStop ( PWMDriver pwmp)

Deactivates the PWM peripheral.

Parameters
[in]pwmppointer to a PWMDriver object
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 111 of file hal_pwm.c.

References PWMDriver::config, PWMDriver::enabled, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), pwm_lld_stop(), PWM_READY, PWM_STOP, and PWMDriver::state.

Here is the call graph for this function:

void pwmChangePeriod ( PWMDriver pwmp,
pwmcnt_t  period 
)

Changes the period the PWM peripheral.

This function changes the period of a PWM unit that has already been activated using pwmStart().

Precondition
The PWM unit must have been activated using pwmStart().
Postcondition
The PWM unit period is changed to the new value.
Note
If a period is specified that is shorter than the pulse width programmed in one of the channels then the behavior is not guaranteed.
Parameters
[in]pwmppointer to a PWMDriver object
[in]periodnew cycle time in ticks
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 143 of file hal_pwm.c.

References osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), PWM_READY, pwmChangePeriodI, and PWMDriver::state.

Here is the call graph for this function:

void pwmEnableChannel ( PWMDriver pwmp,
pwmchannel_t  channel,
pwmcnt_t  width 
)

Enables a PWM channel.

Precondition
The PWM unit must have been activated using pwmStart().
Postcondition
The channel is active using the specified configuration.
Note
Depending on the hardware implementation this function has effect starting on the next cycle (recommended implementation) or immediately (fallback implementation).
Parameters
[in]pwmppointer to a PWMDriver object
[in]channelPWM channel identifier (0...channels-1)
[in]widthPWM pulse width as clock pulses number
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 167 of file hal_pwm.c.

References osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), PWM_READY, pwmEnableChannelI, and PWMDriver::state.

Here is the call graph for this function:

void pwmDisableChannel ( PWMDriver pwmp,
pwmchannel_t  channel 
)

Disables a PWM channel and its notification.

Precondition
The PWM unit must have been activated using pwmStart().
Postcondition
The channel is disabled and its output line returned to the idle state.
Note
Depending on the hardware implementation this function has effect starting on the next cycle (recommended implementation) or immediately (fallback implementation).
Parameters
[in]pwmppointer to a PWMDriver object
[in]channelPWM channel identifier (0...channels-1)
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 196 of file hal_pwm.c.

References osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), PWM_READY, pwmDisableChannelI, and PWMDriver::state.

Here is the call graph for this function:

void pwmEnablePeriodicNotification ( PWMDriver pwmp)

Enables the periodic activation edge notification.

Precondition
The PWM unit must have been activated using pwmStart().
Note
If the notification is already enabled then the call has no effect.
Parameters
[in]pwmppointer to a PWMDriver object
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 218 of file hal_pwm.c.

References PWMConfig::callback, PWMDriver::config, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), PWM_READY, pwmEnablePeriodicNotificationI, and PWMDriver::state.

Here is the call graph for this function:

void pwmDisablePeriodicNotification ( PWMDriver pwmp)

Disables the periodic activation edge notification.

Precondition
The PWM unit must have been activated using pwmStart().
Note
If the notification is already disabled then the call has no effect.
Parameters
[in]pwmppointer to a PWMDriver object
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 241 of file hal_pwm.c.

References PWMConfig::callback, PWMDriver::config, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), PWM_READY, pwmDisablePeriodicNotificationI, and PWMDriver::state.

Here is the call graph for this function:

void pwmEnableChannelNotification ( PWMDriver pwmp,
pwmchannel_t  channel 
)

Enables a channel de-activation edge notification.

Precondition
The PWM unit must have been activated using pwmStart().
The channel must have been activated using pwmEnableChannel().
Note
If the notification is already enabled then the call has no effect.
Parameters
[in]pwmppointer to a PWMDriver object
[in]channelPWM channel identifier (0...channels-1)
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 266 of file hal_pwm.c.

References PWMChannelConfig::callback, PWMConfig::channels, PWMDriver::config, PWMDriver::enabled, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), PWM_READY, pwmEnableChannelNotificationI, and PWMDriver::state.

Here is the call graph for this function:

void pwmDisableChannelNotification ( PWMDriver pwmp,
pwmchannel_t  channel 
)

Disables a channel de-activation edge notification.

Precondition
The PWM unit must have been activated using pwmStart().
The channel must have been activated using pwmEnableChannel().
Note
If the notification is already disabled then the call has no effect.
Parameters
[in]pwmppointer to a PWMDriver object
[in]channelPWM channel identifier (0...channels-1)
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 294 of file hal_pwm.c.

References PWMChannelConfig::callback, PWMConfig::channels, PWMDriver::config, PWMDriver::enabled, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), PWM_READY, pwmDisableChannelNotificationI, and PWMDriver::state.

Here is the call graph for this function:

void pwm_lld_init ( void  )

Low level PWM driver initialization.

Function Class:Not an API, this function is for internal use only.

Definition at line 66 of file hal_pwm_lld.c.

References pwmObjectInit().

Referenced by pwmInit().

Here is the call graph for this function:

void pwm_lld_start ( PWMDriver pwmp)

Configures and activates the PWM peripheral.

Note
Starting a driver that is already in the PWM_READY state disables all the active channels.
Parameters
[in]pwmppointer to a PWMDriver object
Function Class:Not an API, this function is for internal use only.

Definition at line 83 of file hal_pwm_lld.c.

References PWM_STOP, and PWMDriver::state.

Referenced by pwmStart().

void pwm_lld_stop ( PWMDriver pwmp)

Deactivates the PWM peripheral.

Parameters
[in]pwmppointer to a PWMDriver object
Function Class:Not an API, this function is for internal use only.

Definition at line 102 of file hal_pwm_lld.c.

References PWM_READY, and PWMDriver::state.

Referenced by pwmStop().

void pwm_lld_enable_channel ( PWMDriver pwmp,
pwmchannel_t  channel,
pwmcnt_t  width 
)

Enables a PWM channel.

Precondition
The PWM unit must have been activated using pwmStart().
Postcondition
The channel is active using the specified configuration.
Note
The function has effect at the next cycle start.
Channel notification is not enabled.
Parameters
[in]pwmppointer to a PWMDriver object
[in]channelPWM channel identifier (0...channels-1)
[in]widthPWM pulse width as clock pulses number
Function Class:Not an API, this function is for internal use only.

Definition at line 127 of file hal_pwm_lld.c.

void pwm_lld_disable_channel ( PWMDriver pwmp,
pwmchannel_t  channel 
)

Disables a PWM channel and its notification.

Precondition
The PWM unit must have been activated using pwmStart().
Postcondition
The channel is disabled and its output line returned to the idle state.
Note
The function has effect at the next cycle start.
Parameters
[in]pwmppointer to a PWMDriver object
[in]channelPWM channel identifier (0...channels-1)
Function Class:Not an API, this function is for internal use only.

Definition at line 148 of file hal_pwm_lld.c.

void pwm_lld_enable_periodic_notification ( PWMDriver pwmp)

Enables the periodic activation edge notification.

Precondition
The PWM unit must have been activated using pwmStart().
Note
If the notification is already enabled then the call has no effect.
Parameters
[in]pwmppointer to a PWMDriver object
Function Class:Not an API, this function is for internal use only.

Definition at line 163 of file hal_pwm_lld.c.

void pwm_lld_disable_periodic_notification ( PWMDriver pwmp)

Disables the periodic activation edge notification.

Precondition
The PWM unit must have been activated using pwmStart().
Note
If the notification is already disabled then the call has no effect.
Parameters
[in]pwmppointer to a PWMDriver object
Function Class:Not an API, this function is for internal use only.

Definition at line 177 of file hal_pwm_lld.c.

void pwm_lld_enable_channel_notification ( PWMDriver pwmp,
pwmchannel_t  channel 
)

Enables a channel de-activation edge notification.

Precondition
The PWM unit must have been activated using pwmStart().
The channel must have been activated using pwmEnableChannel().
Note
If the notification is already enabled then the call has no effect.
Parameters
[in]pwmppointer to a PWMDriver object
[in]channelPWM channel identifier (0...channels-1)
Function Class:Not an API, this function is for internal use only.

Definition at line 193 of file hal_pwm_lld.c.

void pwm_lld_disable_channel_notification ( PWMDriver pwmp,
pwmchannel_t  channel 
)

Disables a channel de-activation edge notification.

Precondition
The PWM unit must have been activated using pwmStart().
The channel must have been activated using pwmEnableChannel().
Note
If the notification is already disabled then the call has no effect.
Parameters
[in]pwmppointer to a PWMDriver object
[in]channelPWM channel identifier (0...channels-1)
Function Class:Not an API, this function is for internal use only.

Definition at line 211 of file hal_pwm_lld.c.

Variable Documentation

PWMDriver PWMD1

PWMD1 driver identifier.

Note
The driver PWMD1 allocates the complex timer TIM1 when enabled.

Definition at line 42 of file hal_pwm_lld.c.