From 5d29fe79d30f430ae326d9dc57ccfaed6fe61328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Tue, 8 Mar 2016 16:10:33 +0100 Subject: Another full update of current work --- include/sensors/dht22.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 include/sensors/dht22.h (limited to 'include/sensors') diff --git a/include/sensors/dht22.h b/include/sensors/dht22.h new file mode 100644 index 0000000..aabb442 --- /dev/null +++ b/include/sensors/dht22.h @@ -0,0 +1,42 @@ +#include +#include +#include + +#include "../tasks.h" +#include "../timer.h" + +#ifndef _IOE_SENSOR_DHT22_H_ +#define _IOE_SENSOR_DHT22_H_ +#ifdef CONFIG_IOE_SENSOR_DHT22 + +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 /* CONFIG_IOE_SENSOR_DHT22 */ +#endif /* _IOE_SENSOR_DHT22_H_ */ -- cgit v1.2.3