diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2017-07-27 12:05:29 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2017-08-08 00:27:27 -0400 |
commit | 62f77f6bc56e0fcffdcdd4dcf2cfd6a7669099f2 (patch) | |
tree | 2f711635897b054d1f82f1d967028b8a1573a19f /src/adccmds.c | |
parent | 88a10fb31cce34bf3d3a740a70f661d1656b28c5 (diff) | |
download | kutter-62f77f6bc56e0fcffdcdd4dcf2cfd6a7669099f2.tar.gz kutter-62f77f6bc56e0fcffdcdd4dcf2cfd6a7669099f2.tar.xz kutter-62f77f6bc56e0fcffdcdd4dcf2cfd6a7669099f2.zip |
sched: Don't count milliseconds in the periodic timer
It's not necessary to keep a millisecond counter. Replace the two
users of sched_check_periodic() with explicit task wakeup flags.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/adccmds.c')
-rw-r--r-- | src/adccmds.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/adccmds.c b/src/adccmds.c index 526325ad..55900ab1 100644 --- a/src/adccmds.c +++ b/src/adccmds.c @@ -18,6 +18,8 @@ struct analog_in { uint8_t state, sample_count; }; +static struct task_wake analog_wake; + static uint_fast8_t analog_in_event(struct timer *timer) { @@ -42,6 +44,7 @@ analog_in_event(struct timer *timer) } if (a->value < a->min_value || a->value > a->max_value) shutdown("adc out of range"); + sched_wake_task(&analog_wake); a->next_begin_time += a->rest_time; a->timer.waketime = a->next_begin_time; return SF_RESCHEDULE; @@ -83,8 +86,7 @@ DECL_COMMAND(command_query_analog_in, void analog_in_task(void) { - static uint16_t next; - if (!sched_check_periodic(3, &next)) + if (!sched_check_wake(&analog_wake)) return; uint8_t oid; struct analog_in *a; |