aboutsummaryrefslogtreecommitdiffstats
path: root/src/sched.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-03-10 22:21:25 -0500
committerKevin O'Connor <kevin@koconnor.net>2017-03-11 11:14:06 -0500
commit69b927bfe9f9fd7a6ffe664a188ae4ad9462fd75 (patch)
tree22c0aa886e988ec89a1e00661b56687dcf1f9cd6 /src/sched.c
parent944d1768568239c4d9901726ff133bd43f56863e (diff)
downloadkutter-69b927bfe9f9fd7a6ffe664a188ae4ad9462fd75.tar.gz
kutter-69b927bfe9f9fd7a6ffe664a188ae4ad9462fd75.tar.xz
kutter-69b927bfe9f9fd7a6ffe664a188ae4ad9462fd75.zip
sched: Move functions within sched.c
Just code movement - no code changes. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/sched.c')
-rw-r--r--src/sched.c78
1 files changed, 38 insertions, 40 deletions
diff --git a/src/sched.c b/src/sched.c
index 83c02075..5f8baae9 100644
--- a/src/sched.c
+++ b/src/sched.c
@@ -17,9 +17,46 @@
* Timers
****************************************************************/
+// Return the number of clock ticks for a given number of microseconds
+uint32_t
+sched_from_us(uint32_t us)
+{
+ return timer_from_us(us);
+}
+
+// Return the current time (in clock ticks)
+uint32_t
+sched_read_time(void)
+{
+ return timer_read_time();
+}
+
+// Return true if time1 is before time2. Always use this function to
+// compare times as regular C comparisons can fail if the counter
+// rolls over.
+uint8_t
+sched_is_before(uint32_t time1, uint32_t time2)
+{
+ return (int32_t)(time1 - time2) < 0;
+}
+
static uint16_t millis;
-static struct timer ms_timer, sentinel_timer;
+// Check if ready for a recurring periodic event
+uint8_t
+sched_check_periodic(uint16_t time, uint16_t *pnext)
+{
+ uint16_t next = *pnext, cur;
+ irqstatus_t flag = irq_save();
+ cur = millis;
+ irq_restore(flag);
+ if ((int16_t)(cur - next) < 0)
+ return 0;
+ *pnext = cur + time;
+ return 1;
+}
+
+static struct timer ms_timer, sentinel_timer, *timer_list = &ms_timer;
// Default millisecond timer. This timer counts milliseconds. It
// also simplifies the timer code by ensuring there is always a timer
@@ -56,45 +93,6 @@ static struct timer sentinel_timer = {
.waketime = 0x80000000,
};
-// Check if ready for a recurring periodic event
-uint8_t
-sched_check_periodic(uint16_t time, uint16_t *pnext)
-{
- uint16_t next = *pnext, cur;
- irqstatus_t flag = irq_save();
- cur = millis;
- irq_restore(flag);
- if ((int16_t)(cur - next) < 0)
- return 0;
- *pnext = cur + time;
- return 1;
-}
-
-// Return the number of clock ticks for a given number of microseconds
-uint32_t
-sched_from_us(uint32_t us)
-{
- return timer_from_us(us);
-}
-
-// Return the current time (in clock ticks)
-uint32_t
-sched_read_time(void)
-{
- return timer_read_time();
-}
-
-// Return true if time1 is before time2. Always use this function to
-// compare times as regular C comparisons can fail if the counter
-// rolls over.
-uint8_t
-sched_is_before(uint32_t time1, uint32_t time2)
-{
- return (int32_t)(time1 - time2) < 0;
-}
-
-static struct timer *timer_list = &ms_timer;
-
// Schedule a function call at a supplied time.
void
sched_add_timer(struct timer *add)