airquality7 2.0.0.0
airquality7.h
Go to the documentation of this file.
1/*
2 * MikroSDK - MikroE Software Development Kit
3 * Copyright© 2020 MikroElektronika d.o.o.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge,
9 * publish, distribute, sublicense, and/or sell copies of the Software,
10 * and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22 * OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
33// ----------------------------------------------------------------------------
34
35#ifndef AIRQUALITY7_H
36#define AIRQUALITY7_H
37
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_i2c_master.h"
55
56// -------------------------------------------------------------- PUBLIC MACROS
66#define AIRQUALITY7_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
68 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
69 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
76#define AIRQUALITY7_RETVAL uint8_t
77#define airquality7_err_t uint8_t
78
79#define AIRQUALITY7_OK 0x00
80#define AIRQUALITY7_INIT_ERROR 0xFF
87#define AIRQUALITY7_CMD_SET_PPMCO2 0x08
88#define AIRQUALITY7_CMD_GET_STATUS 0x0C
89#define AIRQUALITY7_CMD_GET_REVISION 0x0D
90#define AIRQUALITY7_CMD_GET_R0 0x10
97#define AIRQUALITY7_DEV_ADDR 0x70
104#define AIRQUALITY7_ERR_OK 0x00
105#define AIRQUALITY7_ERR_CRC 0x01
112#define AIRQUALITY7_NULL 0x00
113#define AIRQUALITY7_DUMMY 0x00
117 // End group macro
118// --------------------------------------------------------------- PUBLIC TYPES
127typedef struct
128{
129 // Input pins
130
131 digital_in_t int_pin;
132
133 // Modules
134
135 i2c_master_t i2c;
136
137 // ctx variable
138
140
142
146typedef struct
147{
148 // Communication gpio pins
149
150 pin_name_t scl;
151 pin_name_t sda;
152
153 // Additional gpio pins
154
155 pin_name_t int_pin;
156
157 // static variable
158
159 uint32_t i2c_speed;
160 uint8_t i2c_address;
161
163
164 // End types group
165// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
166
172#ifdef __cplusplus
173extern "C"{
174#endif
175
185
194
203void airquality7_generic_write ( airquality7_t *ctx, uint8_t *data_buf );
204
214void airquality7_generic_read ( airquality7_t *ctx, uint8_t *data_buf );
215
226void airquality7_set_ppmco2( airquality7_t *ctx, uint8_t *ppmco2_value );
227
245 uint16_t *co2_ppm,
246 uint32_t *res_val_ohm,
247 uint8_t *err_byte );
248
266 uint8_t *month,
267 uint8_t *day,
268 uint8_t *ascii_code );
269
283
284#ifdef __cplusplus
285}
286#endif
287#endif // _AIRQUALITY7_H_
288
289 // End public_function group
291
292// ------------------------------------------------------------------------- END
#define airquality7_err_t
Definition airquality7.h:77
#define AIRQUALITY7_RETVAL
Definition airquality7.h:76
void airquality7_generic_write(airquality7_t *ctx, uint8_t *data_buf)
Generic write function.
void airquality7_cfg_setup(airquality7_cfg_t *cfg)
Config Object Initialization function.
airquality7_err_t airquality7_get_revision(airquality7_t *ctx, uint8_t *year, uint8_t *month, uint8_t *day, uint8_t *ascii_code)
Get Revision function.
void airquality7_set_ppmco2(airquality7_t *ctx, uint8_t *ppmco2_value)
Set CO2 [ppm] function.
airquality7_err_t airquality7_get_status(airquality7_t *ctx, uint16_t *tvoc_ppb, uint16_t *co2_ppm, uint32_t *res_val_ohm, uint8_t *err_byte)
Get Status function.
airquality7_err_t airquality7_get_r0_calib(airquality7_t *ctx, uint16_t *r0_kohm)
Get R0 Calibration function.
void airquality7_generic_read(airquality7_t *ctx, uint8_t *data_buf)
Generic read function.
AIRQUALITY7_RETVAL airquality7_init(airquality7_t *ctx, airquality7_cfg_t *cfg)
Initialization function.
Click configuration structure definition.
Definition airquality7.h:147
uint32_t i2c_speed
Definition airquality7.h:159
pin_name_t scl
Definition airquality7.h:150
pin_name_t int_pin
Definition airquality7.h:155
pin_name_t sda
Definition airquality7.h:151
uint8_t i2c_address
Definition airquality7.h:160
Click ctx object definition.
Definition airquality7.h:128
digital_in_t int_pin
Definition airquality7.h:131
i2c_master_t i2c
Definition airquality7.h:135
uint8_t slave_address
Definition airquality7.h:139