pwm_get_relative_duty_cycle(9)
π pwm_get_relative_duty_cycle(9) π
okay bestie, welcome to the Kernel API Manual β this one is lowkey a little utility icon and weβre gonna get into it π
πΈ NAME πΈ
pwm_get_relative_duty_cycle β get a relative duty cycle value. thatβs the whole vibe, periodt β¨
π SYNOPSIS π
unsigned int pwm_get_relative_duty_cycle (const struct pwm_state *state
, unsigned int scale );
π¦ ARGUMENTS π¦
stateβ the PWM state youβre extracting the duty cycle from π«Άscaleβ the target scale of the relative duty cycle, no cap π«
β¨ DESCRIPTION β¨
so this function converts the absolute duty cycle stored in state β which is expressed in nanosecond β into a value relative to the period. itβs literally giving βnormalize my duty cycleβ and honestly? iconic ππ
for example, if you want to get the duty_cycle expressed in percent, you call:
pwm_get_state(pwm, state); duty = pwm_get_relative_duty_cycle(state, 100);
π RETURN π
you get the rounded relative duty cycle multiplied by scale β thatβs the whole return-value moment, bestie β¨
π₯ SEE ALSO π₯
kernel file: ./include/linux/pwm.h β home base fr fr.
also the SEE ALSO squad is: enum pwm_polarity(9), struct pwm_args(9), struct pwm_waveform(9), struct pwm_device(9), pwm_get_state(9), pwm_init_state(9), pwm_set_relative_duty_cycle(9), struct pwm_capture(9), struct pwm_ops(9), struct pwm_chip(9), pwmchip_supports_waveform(9), pwm_config(9), pwm_enable(9), pwm_disable(9), pwm_might_sleep(9) π
okay bye ily π source/version: ./include/linux Β· date: October 2026 π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms