sgp40var.h revision 1.1 1 1.1 brad /* $NetBSD: sgp40var.h,v 1.1 2021/10/14 13:54:46 brad Exp $ */
2 1.1 brad
3 1.1 brad /*
4 1.1 brad * Copyright (c) 2021 Brad Spencer <brad (at) anduin.eldar.org>
5 1.1 brad *
6 1.1 brad * Permission to use, copy, modify, and distribute this software for any
7 1.1 brad * purpose with or without fee is hereby granted, provided that the above
8 1.1 brad * copyright notice and this permission notice appear in all copies.
9 1.1 brad *
10 1.1 brad * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 1.1 brad * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 1.1 brad * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 1.1 brad * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 1.1 brad * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 1.1 brad * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 1.1 brad * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 1.1 brad */
18 1.1 brad
19 1.1 brad #ifndef _DEV_I2C_SGP40VAR_H_
20 1.1 brad #define _DEV_I2C_SGP40VAR_H_
21 1.1 brad
22 1.1 brad #define SGP40_NUM_SENSORS 1
23 1.1 brad #define SGP40_VOC_SENSOR 0
24 1.1 brad
25 1.1 brad #define SGP40_DEFAULT_TEMP_COMP 25
26 1.1 brad #define SGP40_DEFAULT_RH_COMP 50
27 1.1 brad
28 1.1 brad
29 1.1 brad struct sgp40_sc {
30 1.1 brad int sc_sgp40debug;
31 1.1 brad device_t sc_dev;
32 1.1 brad i2c_tag_t sc_tag;
33 1.1 brad i2c_addr_t sc_addr;
34 1.1 brad kmutex_t sc_threadmutex; /* for the measurement kthread */
35 1.1 brad kmutex_t sc_mutex; /* for reading the i2c bus */
36 1.1 brad kcondvar_t sc_condvar;
37 1.1 brad struct lwp *sc_thread;
38 1.1 brad int sc_numsensors;
39 1.1 brad struct sysmon_envsys *sc_sme;
40 1.1 brad struct sysctllog *sc_sgp40log;
41 1.1 brad envsys_data_t sc_sensors[SGP40_NUM_SENSORS];
42 1.1 brad uint16_t sc_voc;
43 1.1 brad bool sc_vocvalid;
44 1.1 brad bool sc_ignorecrc;
45 1.1 brad int sc_readattempts;
46 1.1 brad bool sc_stopping;
47 1.1 brad int sc_tempcomp;
48 1.1 brad int sc_rhcomp;
49 1.1 brad };
50 1.1 brad
51 1.1 brad struct sgp40_sensor {
52 1.1 brad const char *desc;
53 1.1 brad enum envsys_units type;
54 1.1 brad };
55 1.1 brad
56 1.1 brad struct sgp40_timing {
57 1.1 brad uint16_t cmd;
58 1.1 brad int typicaldelay;
59 1.1 brad };
60 1.1 brad
61 1.1 brad #endif
62