Skip to content

Commit

Permalink
pwm: hack: ignore duty and period caching
Browse files Browse the repository at this point in the history
We used to have problem with not properly working failsafe when caching
duty and period values. Because the ardupilot was sending the same
value, the RCIO stopped outputting constant PWM because of failsafe
feature. Therefore we do not cache the values so that this does not happen.
  • Loading branch information
staroselskii authored and AlexeyBulatov committed Apr 28, 2021
1 parent 812ab6e commit b674211
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions drivers/pwm/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -581,12 +581,6 @@ int pwm_apply_state(struct pwm_device *pwm, const struct pwm_state *state)

chip = pwm->chip;

if (state->period == pwm->state.period &&
state->duty_cycle == pwm->state.duty_cycle &&
state->polarity == pwm->state.polarity &&
state->enabled == pwm->state.enabled)
return 0;

if (chip->ops->apply) {
err = chip->ops->apply(chip, pwm, state);
if (err)
Expand Down Expand Up @@ -627,17 +621,14 @@ int pwm_apply_state(struct pwm_device *pwm, const struct pwm_state *state)
pwm->state.polarity = state->polarity;
}

if (state->period != pwm->state.period ||
state->duty_cycle != pwm->state.duty_cycle) {
err = chip->ops->config(pwm->chip, pwm,
state->duty_cycle,
state->period);
if (err)
return err;
err = chip->ops->config(pwm->chip, pwm,
state->duty_cycle,
state->period);
if (err)
return err;

pwm->state.duty_cycle = state->duty_cycle;
pwm->state.period = state->period;
}
pwm->state.duty_cycle = state->duty_cycle;
pwm->state.period = state->period;

if (state->enabled != pwm->state.enabled) {
if (state->enabled) {
Expand Down

0 comments on commit b674211

Please sign in to comment.