Home | History | Annotate | Line # | Download | only in i2c
      1 /*	$NetBSD: sht4xvar.h,v 1.1 2021/10/03 17:27:02 brad Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 2021 Brad Spencer <brad (at) 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_SHT4XVAR_H_
     20 #define _DEV_I2C_SHT4XVAR_H_
     21 
     22 #define SHT4X_NUM_SENSORS	2
     23 #define SHT4X_HUMIDITY_SENSOR 0
     24 #define SHT4X_TEMP_SENSOR 1
     25 
     26 #define SHT4X_RES_NAME 7
     27 #define SHT4X_PULSE_NAME 6
     28 
     29 struct sht4x_sc {
     30 	int 		sc_sht4xdebug;
     31 	device_t 	sc_dev;
     32 	i2c_tag_t 	sc_tag;
     33 	i2c_addr_t 	sc_addr;
     34 	kmutex_t 	sc_mutex;
     35 	int 		sc_numsensors;
     36 	struct sysmon_envsys *sc_sme;
     37 	struct sysctllog *sc_sht4xlog;
     38 	envsys_data_t 	sc_sensors[SHT4X_NUM_SENSORS];
     39 	bool 		sc_ignorecrc;
     40 	char 		sc_resolution[SHT4X_RES_NAME];
     41 	int 		sc_readattempts;
     42 	bool 		sc_heateron;
     43 	int 		sc_heaterval;
     44 	char            sc_heaterpulse[SHT4X_PULSE_NAME];
     45 };
     46 
     47 struct sht4x_sensor {
     48 	const char     *desc;
     49 	enum envsys_units type;
     50 };
     51 
     52 struct sht4x_timing {
     53 	uint8_t cmd;
     54 	int     typicaldelay;
     55 };
     56 
     57 struct sht4x_resolution {
     58 	const char     *text;
     59 	uint8_t        cmd;
     60 };
     61 
     62 struct sht4x_heaterpulse {
     63 	const char     *length;
     64 };
     65 
     66 struct sht4x_heateron_command {
     67 	int            heatervalue;
     68 	const char     *pulselength;
     69 	uint8_t        cmd;
     70 };
     71 
     72 #endif
     73