xref: /netbsd-src/sys/dev/i2c/aht20var.h (revision 50bf6d2dfdf0cd11a30fb00e366be19f1fdc740c)
1 /*	$NetBSD: aht20var.h,v 1.1 2022/11/17 19:20:06 brad Exp $	*/
2 
3 /*
4  * Copyright (c) 2022 Brad Spencer <brad@anduin.eldar.org>
5  *
6  * Permission to use, copy, modify, and distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #ifndef _DEV_I2C_AHT20VAR_H_
20 #define _DEV_I2C_AHT20VAR_H_
21 
22 #define AHT20_NUM_SENSORS	2
23 #define AHT20_HUMIDITY_SENSOR 0
24 #define AHT20_TEMP_SENSOR 1
25 
26 struct aht20_sc {
27 	int 		sc_aht20debug;
28 	device_t 	sc_dev;
29 	i2c_tag_t 	sc_tag;
30 	i2c_addr_t 	sc_addr;
31 	kmutex_t 	sc_mutex;
32 	int 		sc_numsensors;
33 	struct sysmon_envsys *sc_sme;
34 	struct sysctllog *sc_aht20log;
35 	envsys_data_t 	sc_sensors[AHT20_NUM_SENSORS];
36 	bool 		sc_ignorecrc;
37 	int 		sc_readattempts;
38 };
39 
40 struct aht20_sensor {
41 	const char     *desc;
42 	enum envsys_units type;
43 };
44 
45 struct aht20_timing {
46 	uint8_t cmd;
47 	int     typicaldelay;
48 };
49 
50 #endif
51