aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-12-15 23:43:24 -0500
committerKevin O'Connor <kevin@koconnor.net>2017-12-16 20:21:38 -0500
commit57c27f75aef049b850d0869df8d82223476c018d (patch)
treed9238387da04a2b92bbaec88d67c0f54cae49270
parent8d62318c5f26dab136d61df502f6ed52e729b516 (diff)
downloadkutter-57c27f75aef049b850d0869df8d82223476c018d.tar.gz
kutter-57c27f75aef049b850d0869df8d82223476c018d.tar.xz
kutter-57c27f75aef049b850d0869df8d82223476c018d.zip
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>
-rw-r--r--src/gpiocmds.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/gpiocmds.c b/src/gpiocmds.c
index 52e3d8d5..54465459 100644
--- a/src/gpiocmds.c
+++ b/src/gpiocmds.c
@@ -142,7 +142,7 @@ soft_pwm_load_event(struct timer *timer)
s->flags = flags;
gpio_out_write(s->pin, flags & SPF_ON);
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))
return SF_DONE;
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->next_on_duration = next_on_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)) {
// soft_pwm_toggle_event() will schedule a load event when ready
} else {