pwm_get_relative_duty_cycle(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– 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