aboutsummaryrefslogtreecommitdiff
path: root/data_manager.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 /data_manager.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 'data_manager.h')
-rw-r--r--data_manager.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/data_manager.h b/data_manager.h
index 83126f6..2197ef0 100644
--- a/data_manager.h
+++ b/data_manager.h
@@ -1,10 +1,15 @@
#pragma once
+#include <stdint.h>
+
struct data_ctx {
+ uint16_t timestamp;
float setting;
float pressure;
float altitude;
+ struct timer *timer;
+ struct barometer *barometer;
};
-void data_manager_init(struct data_ctx*);
+void data_manager_init(struct data_ctx*, struct timer*, struct barometer*);
void data_manager_tick(struct data_ctx*);