aboutsummaryrefslogtreecommitdiffstats
path: root/src/linux/timer.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2021-04-19 09:15:28 -0400
committerKevin O'Connor <kevin@koconnor.net>2021-04-19 09:50:40 -0400
commit8f9e497d6950bf47274cb084a6d3d8ca2b854976 (patch)
tree6162024d89695dafc78374fda1fe3cfbfbb13b85 /src/linux/timer.c
parente0aba590f94e89fa6210e653bf21bd129bde42d4 (diff)
downloadkutter-8f9e497d6950bf47274cb084a6d3d8ca2b854976.tar.gz
kutter-8f9e497d6950bf47274cb084a6d3d8ca2b854976.tar.xz
kutter-8f9e497d6950bf47274cb084a6d3d8ca2b854976.zip
linux: Rework timer_check_periodic() to use ticks
Avoid using a 'struct timespec' to simplify the code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/linux/timer.c')
-rw-r--r--src/linux/timer.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/linux/timer.c b/src/linux/timer.c
index 06330830..f1727ffa 100644
--- a/src/linux/timer.c
+++ b/src/linux/timer.c
@@ -75,17 +75,6 @@ timespec_read(void)
return ts;
}
-// Check if a given time has past
-int
-timer_check_periodic(struct timespec *ts)
-{
- if (timespec_is_before(TimerInfo.next_wake, *ts))
- return 0;
- *ts = TimerInfo.next_wake;
- ts->tv_sec += 2;
- return 1;
-}
-
/****************************************************************
* Timers
@@ -93,6 +82,17 @@ timer_check_periodic(struct timespec *ts)
DECL_CONSTANT("CLOCK_FREQ", CONFIG_CLOCK_FREQ);
+// Check if a given time has past
+int
+timer_check_periodic(uint32_t *ts)
+{
+ uint32_t lrt = TimerInfo.last_read_time;
+ if (timer_is_before(lrt, *ts))
+ return 0;
+ *ts = lrt + timer_from_us(2000000);
+ return 1;
+}
+
// Return the number of clock ticks for a given number of microseconds
uint32_t
timer_from_us(uint32_t us)