gpiocmds: Clear SPF_NEXT_* flags on new schedule_soft_pwm_out

Properly handle the (unlikely) case that a schedule_soft_pwm_out
command is received before a previous command is fully processed,

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2017-12-15 23:43:24 -05:00
parent 8d62318c5f
commit 57c27f75ae
1 changed files with 2 additions and 2 deletions

View File

@ -142,7 +142,7 @@ soft_pwm_load_event(struct timer *timer)
s->flags = flags; s->flags = flags;
gpio_out_write(s->pin, flags & SPF_ON); gpio_out_write(s->pin, flags & SPF_ON);
if (!(flags & SPF_TOGGLING)) { if (!(flags & SPF_TOGGLING)) {
// Pin is in an always on (value=255) or always off (value=0) state // Pin is in an always on (value=256) or always off (value=0) state
if (!(flags & SPF_CHECK_END)) if (!(flags & SPF_CHECK_END))
return SF_DONE; return SF_DONE;
s->timer.waketime = s->end_time = s->end_time + s->max_duration; s->timer.waketime = s->end_time = s->end_time + s->max_duration;
@ -199,7 +199,7 @@ command_schedule_soft_pwm_out(uint32_t *args)
s->end_time = time; s->end_time = time;
s->next_on_duration = next_on_duration; s->next_on_duration = next_on_duration;
s->next_off_duration = next_off_duration; s->next_off_duration = next_off_duration;
s->flags |= next_flags; s->flags = (s->flags & 0xf) | next_flags;
if (s->flags & SPF_TOGGLING && timer_is_before(s->timer.waketime, time)) { if (s->flags & SPF_TOGGLING && timer_is_before(s->timer.waketime, time)) {
// soft_pwm_toggle_event() will schedule a load event when ready // soft_pwm_toggle_event() will schedule a load event when ready
} else { } else {