aboutsummaryrefslogtreecommitdiff
path: root/sensor_dht22.h
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2015-10-17 15:40:51 +0200
committerKarel Kočí <cynerd@email.cz>2015-10-17 15:40:51 +0200
commitb0d8f22f3492fbb3f6dc0e8026e63c803af59007 (patch)
treeeb9707612e87856962474885f2a18ae1621d214e /sensor_dht22.h
parent8fa9db4244f4ee33aa47561c569edfa62fe37928 (diff)
downloadavr-ioe-b0d8f22f3492fbb3f6dc0e8026e63c803af59007.tar.gz
avr-ioe-b0d8f22f3492fbb3f6dc0e8026e63c803af59007.tar.bz2
avr-ioe-b0d8f22f3492fbb3f6dc0e8026e63c803af59007.zip
Complete commit of current work
Diffstat (limited to 'sensor_dht22.h')
-rw-r--r--sensor_dht22.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/sensor_dht22.h b/sensor_dht22.h
new file mode 100644
index 0000000..0776b77
--- /dev/null
+++ b/sensor_dht22.h
@@ -0,0 +1,39 @@
+#include <avr/io.h>
+#include <util/delay.h>
+#include <stdint.h>
+
+#include "tasks.h"
+#include "timer.h"
+
+#ifndef _DHT22_H_
+#define _DHT22_H_
+
+struct dht22_value {
+ uint8_t integral;
+ uint8_t decimal;
+};
+
+struct dht22_port {
+ volatile uint8_t *DDR; // Address of DDR register
+ volatile uint8_t *PORT; // Address of PORT register
+ volatile uint8_t *PIN; // Address of PIN register
+ uint8_t MASK; // _BV() of index of port
+ volatile uint8_t *PCMSK; // Address of relevant PCMSK register
+ uint8_t PCMSK_MASK; // _BV() of index of PCMSK
+};
+
+extern const struct dht22_port dht22_ports[];
+
+/*
+ * Initialize port for sensor
+ */
+void dht22_init(uint8_t port);
+/*
+ * Read values from dht22
+ * rh - relative
+ * t - temperature
+ */
+int8_t dht22_read(uint8_t portindex, struct dht22_value *rh,
+ struct dht22_value *t);
+
+#endif /* _DHT22_H_ */