Scroll to navigation

PWM_INIT_STATE(9) Pulse-Width Modulation (PWM) PWM_INIT_STATE(9)

NAME

pwm_init_state - prepare a new state to be applied with pwm_apply_state

SYNOPSIS

void pwm_init_state(const struct pwm_device * pwm, struct pwm_state * state);

ARGUMENTS

pwm

PWM device

state

state to fill with the prepared PWM state

DESCRIPTION

This functions prepares a state that can later be tweaked and applied to the PWM device with pwm_apply_state. This is a convenient function that first retrieves the current PWM state and the replaces the period and polarity fields with the reference values defined in pwm->args. Once the function returns, you can adjust the ->enabled and ->duty_cycle fields according to your needs before calling pwm_apply_state.

->duty_cycle is initially set to zero to avoid cases where the current ->duty_cycle value exceed the pwm_args->period one, which would trigger an error if the user calls pwm_apply_state without adjusting ->duty_cycle first.

COPYRIGHT

January 2017 Kernel Hackers Manual 4.8.