aboutsummaryrefslogtreecommitdiffstats
path: root/src/gpiocmds.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-03-24 23:01:08 -0400
committerKevin O'Connor <kevin@koconnor.net>2017-03-26 22:45:58 -0400
commit60e488eb177a35084669cb85d81131ce95eac959 (patch)
tree2a0b406f4e0b6e54ef495140573daf6426ca6b0e /src/gpiocmds.c
parent14340ac4df4c58bab4b5fc4c9e4746e33958c081 (diff)
downloadkutter-60e488eb177a35084669cb85d81131ce95eac959.tar.gz
kutter-60e488eb177a35084669cb85d81131ce95eac959.tar.xz
kutter-60e488eb177a35084669cb85d81131ce95eac959.zip
timer: Allow board code to define its own timer_is_before implementation
Move sched_is_before() from sched.c to timer_is_before() in the board specific timer code. This allows the board code to provide its own definition. Also, remove the sched_from_us() and sched_read_time() wrapper functions and change the callers to directly invoke timer_from_us() / timer_read_time(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/gpiocmds.c')
-rw-r--r--src/gpiocmds.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/gpiocmds.c b/src/gpiocmds.c
index e3351b44..6dd29059 100644
--- a/src/gpiocmds.c
+++ b/src/gpiocmds.c
@@ -7,6 +7,7 @@
#include "basecmd.h" // oid_alloc
#include "board/gpio.h" // struct gpio_out
#include "board/irq.h" // irq_disable
+#include "board/misc.h" // timer_is_before
#include "command.h" // DECL_COMMAND
#include "sched.h" // sched_add_timer
@@ -117,7 +118,7 @@ soft_pwm_toggle_event(struct timer *timer)
waketime += s->on_duration;
else
waketime += s->off_duration;
- if (s->flags & SPF_CHECK_END && !sched_is_before(waketime, s->end_time)) {
+ if (s->flags & SPF_CHECK_END && !timer_is_before(waketime, s->end_time)) {
// End of normal pulsing - next event loads new pwm settings
s->timer.func = soft_pwm_load_event;
waketime = s->end_time;
@@ -189,13 +190,13 @@ command_schedule_soft_pwm_out(uint32_t *args)
next_flags |= SPF_NEXT_CHECK_END;
}
irq_disable();
- if (s->flags & SPF_CHECK_END && sched_is_before(s->end_time, time))
+ if (s->flags & SPF_CHECK_END && timer_is_before(s->end_time, time))
shutdown("next soft pwm extends existing pwm");
s->end_time = time;
s->next_on_duration = next_on_duration;
s->next_off_duration = next_off_duration;
s->flags |= next_flags;
- if (s->flags & SPF_TOGGLING && sched_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
} else {
// Schedule the loading of the pwm parameters at the requested time