summaryrefslogtreecommitdiffstats
path: root/pressure_control/firmware/sensor.h
diff options
context:
space:
mode:
Diffstat (limited to 'pressure_control/firmware/sensor.h')
-rw-r--r--pressure_control/firmware/sensor.h29
1 files changed, 26 insertions, 3 deletions
diff --git a/pressure_control/firmware/sensor.h b/pressure_control/firmware/sensor.h
index a6230ad..8f3c4e5 100644
--- a/pressure_control/firmware/sensor.h
+++ b/pressure_control/firmware/sensor.h
@@ -4,10 +4,33 @@
#include <stdint.h>
-void sensor_trigger_read(void);
-void sensor_init(void);
+struct sensor {
+ /* ADMUX */
+ uint8_t adc_mux;
+ /* The sensor value offset, in millivolts.
+ * This value is subtracted from the measured voltage before
+ * processing. */
+ uint16_t mv_offset;
+ /* The Full Scale Output (maximum) output value of the sensor,
+ * in millivolts. */
+ uint16_t full_scale_mv;
+ /* The pressure at Full Scale Output, in millibar. */
+ uint16_t full_scale_mbar;
+};
+
+#define DEFINE_SENSOR(name, mux, _mv_offset, _full_scale_mv, _full_scale_mbar) \
+ struct sensor name = { \
+ .adc_mux = mux, \
+ .mv_offset = _mv_offset, \
+ .full_scale_mv = _full_scale_mv, \
+ .full_scale_mbar = _full_scale_mbar, \
+ }
+
+void sensor_trigger_read(struct sensor *s);
+void sensor_init(struct sensor *s);
/* Callback for sensor value reporting. */
-extern void sensor_result(uint16_t millibar_result_value);
+extern void sensor_result(struct sensor *s,
+ uint16_t millibar_result_value);
#endif /* SENSOR_H_ */
bues.ch cgit interface