summaryrefslogtreecommitdiffstats
path: root/pressure_control/firmware/main.h
diff options
context:
space:
mode:
Diffstat (limited to 'pressure_control/firmware/main.h')
-rw-r--r--pressure_control/firmware/main.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/pressure_control/firmware/main.h b/pressure_control/firmware/main.h
index edb8694..d8cb6aa 100644
--- a/pressure_control/firmware/main.h
+++ b/pressure_control/firmware/main.h
@@ -6,6 +6,27 @@
#include <stdint.h>
+typedef uint16_t jiffies_t;
+typedef int16_t s_jiffies_t;
+
+/* Jiffies timing helpers derived from the Linux Kernel sources.
+ * These inlines deal with timer wrapping correctly.
+ *
+ * time_after(a, b) returns true if the time a is after time b.
+ *
+ * Do this with "<0" and ">=0" to only test the sign of the result. A
+ * good compiler would generate better code (and a really good compiler
+ * wouldn't care). Gcc is currently neither.
+ */
+#define time_after(a, b) ((s_jiffies_t)(b) - (s_jiffies_t)(a) < 0)
+#define time_before(a, b) time_after(b, a)
+
+#define JIFFIES_PER_SECOND 1000
+#define msec_to_jiffies(msec) ((jiffies_t)((uint32_t)JIFFIES_PER_SECOND * (uint32_t)(msec) / (uint32_t)1000))
+
+jiffies_t get_jiffies(void);
+
+
struct pressure_config {
/* Desired pressure in mBar */
uint16_t desired;
bues.ch cgit interface