aboutsummaryrefslogtreecommitdiffstats
path: root/src/linux
diff options
context:
space:
mode:
Diffstat (limited to 'src/linux')
-rw-r--r--src/linux/internal.h4
-rw-r--r--src/linux/timer.c22
-rw-r--r--src/linux/watchdog.c2
3 files changed, 14 insertions, 14 deletions
diff --git a/src/linux/internal.h b/src/linux/internal.h
index ac4f3f13..5a9ce907 100644
--- a/src/linux/internal.h
+++ b/src/linux/internal.h
@@ -2,7 +2,7 @@
#define __LINUX_INTERNAL_H
// Local definitions for micro-controllers running on linux
-#include <time.h> // struct timespec
+#include <stdint.h> // uint32_t
#include "autoconf.h" // CONFIG_CLOCK_FREQ
#define MAX_GPIO_LINES 256
@@ -22,7 +22,7 @@ int console_setup(char *name);
void console_sleep(struct timespec ts);
// timer.c
-int timer_check_periodic(struct timespec *ts);
+int timer_check_periodic(uint32_t *ts);
// watchdog.c
int watchdog_setup(void);
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)
diff --git a/src/linux/watchdog.c b/src/linux/watchdog.c
index d89fcd29..d514eb27 100644
--- a/src/linux/watchdog.c
+++ b/src/linux/watchdog.c
@@ -26,7 +26,7 @@ watchdog_setup(void)
void
watchdog_task(void)
{
- static struct timespec next_watchdog_time;
+ static uint32_t next_watchdog_time;
if (watchdog_fd < 0 || !timer_check_periodic(&next_watchdog_time))
return;
int ret = write(watchdog_fd, ".", 1);