aboutsummaryrefslogtreecommitdiff
path: root/timer.h
diff options
context:
space:
mode:
authorDavid Phillips <david@yeah.nah.nz>2021-02-20 17:43:24 +1300
committerDavid Phillips <david@yeah.nah.nz>2021-02-27 21:54:56 +1300
commit27d6d2fc5a1647395a7a9074faf8362d6d0c358a (patch)
tree81f81c6b4a5a835e01968e0059271bb90c3768ab /timer.h
parente843e9da835f058e09810cfeba7c60d0b270e7b3 (diff)
downloadaltimeter-27d6d2fc5a1647395a7a9074faf8362d6d0c358a.tar.xz
Use more generic interface for barometer and timer
This patch abstracts the global symbols for getting barometer readings behind a "struct of function pointers" interface as popular in Linux Kernel, U-Boot and others. This means that unit testing can take place with mocked hardware peripherals. The old "global" drivers are still available, behind explicit function calls required to access the now-static functions. This patch also introduces a timer peripheral software module with the same model, to support future unit testing of altitude rate etc.
Diffstat (limited to 'timer.h')
-rw-r--r--timer.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/timer.h b/timer.h
new file mode 100644
index 0000000..2f2e4b3
--- /dev/null
+++ b/timer.h
@@ -0,0 +1,10 @@
+#pragma once
+
+#include <stdint.h>
+
+struct timer {
+ void (*init)(void);
+ uint16_t (*get_time)(void);
+};
+
+void get_system_timer(struct timer *);