Skip to content

Commit

Permalink
dt: pwm: add support for specifying frequency in Hz and kHz
Browse files Browse the repository at this point in the history
Add a pair of dt macros for specifying the pwm frequency in hertz or
kilohertz: PWM_HZ and PWM_KHZ. This is then converted in period
nanoseconds so it works as expected with the other definitions.

Signed-off-by: Fabio Baltieri <[email protected]>
  • Loading branch information
fabiobaltieri authored and MaureenHelm committed Apr 27, 2022
1 parent 1e02dd0 commit 82634ed
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/zephyr/dt-bindings/pwm/pwm.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
#define PWM_MSEC(x) (PWM_USEC(x) * 1000UL)
/** Specify PWM period in seconds */
#define PWM_SEC(x) (PWM_MSEC(x) * 1000UL)
/** Specify PWM frequency in hertz */
#define PWM_HZ(x) (PWM_SEC(1UL) / (x))
/** Specify PWM frequency in kilohertz */
#define PWM_KHZ(x) (PWM_HZ((x) * 1000UL))

/** @} */

Expand Down

0 comments on commit 82634ed

Please sign in to comment.