Contiki-NG
iaq.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, Zolertia <http://www.zolertia.com>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the Institute nor the names of its contributors
14  * may be used to endorse or promote products derived from this software
15  * without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * This file is part of the Contiki operating system.
30  *
31  */
32 /* -------------------------------------------------------------------------- */
33 /**
34  * \addtogroup zoul-sensors
35  * @{
36  * \defgroup zoul-iaq-sensor IAQ driver (Indoor Air Quality) Sensor Module
37  * IAQ driver RE-Mote Indoor Air Quality Sensor Module
38  * Driver for the RE-Mote Sensor pack: Air Quality Sensor Module (IAQ)
39  * @{
40  * \file
41  * Header file for the RE-Mote Sensor IAQ
42  */
43 /* -------------------------------------------------------------------------- */
44 #ifndef IAQ_H_
45 #define IAQ_H_
46 /* -------------------------------------------------------------------------- */
47 #include <stdio.h>
48 #include "lib/sensors.h"
49 #include "dev/zoul-sensors.h"
50 #include "iaq.h"
51 #include "i2c.h"
52 #include "sys/timer.h"
53 #include "sys/rtimer.h"
54 /* -------------------------------------------------------------------------- */
55 /** \name IAQ address and definition
56  * @{
57  */
58 /* Address of the sensor: 1011010(1) Addr (R/W bit) */
59 #define IAQ_ADDR 0x5A
60 #define IAQ_SENSOR "iAQ"
61 /** @} */
62 /* -------------------------------------------------------------------------- */
63 /** \name IAQ sensor types in iAQ-Core module
64  * @{
65  */
66 extern const struct sensors_sensor iaq;
67 /** @} */
68 /* -------------------------------------------------------------------------- */
69 /** \name IAQ error values and definitions
70  * @{
71  */
72 #define IAQ_ACTIVE SENSORS_ACTIVE
73 #define IAQ_INIT_STATE SENSORS_HW_INIT
74 #define IAQ_ERROR (-1)
75 #define IAQ_SUCCESS 0x00
76 #define IAQ_FRAME_SIZE 0x09
77 
78 /* Variables used by external driver to get the state */
79 #define IAQ_INTERNAL_SUCCESS 0x00
80 #define IAQ_INTERNAL_RUNIN 0x10
81 #define IAQ_INTERNAL_BUSY 0x01
82 #define IAQ_INTERNAL_ERROR 0x80
83 
84 /* Value types for the sensor readings */
85 #define IAQ_CO2_VALUE 0x00
86 #define IAQ_VOC_VALUE 0x01
87 #define IAQ_STATUS 0x02
88 #define IAQ_DRIVER_STATUS 0x03
89 
90 /* Definition that corresponds with the two models of iAQ Sensor */
91 #ifdef IAQ_PULSE_MODE
92 #define IAQ_POLLING_TIME (CLOCK_SECOND * 11)
93 #else
94 #define IAQ_POLLING_TIME (CLOCK_SECOND)
95 #endif
96 /** @} */
97 /* -------------------------------------------------------------------------- */
98 /** \name IAQ enumeration and options
99  * @{
100  */
101 enum {
102  IAQ_INIT = 0,
103  IAQ_STARTED,
104 };
105 /** @} */
106 /* -------------------------------------------------------------------------- */
107 /** \name Readable IAQ-Core interface result conversion implementation as
108  * datasheet specification.
109  *
110  * @{
111  */
112 typedef struct iaq_struct_simple_td_reg {
113  uint16_t co2;
114  uint8_t status;
115  int32_t resistance;
116  uint16_t tvoc;
117 } __attribute__ ((packed)) simple_iaq_data;
118 /** @} */
119 /* -------------------------------------------------------------------------- */
120 #endif
121 /* -------------------------------------------------------------------------- */
122 /**
123  * @}
124  * @}
125  */
Timer library header file.
Implementation of a generic module controlling Zoul sensors.
Header file for the real-time timer module.
Header file for the RE-Mote Sensor IAQ.