Home | History | Annotate | Line # | Download | only in i2c
hytp14var.h revision 1.2.6.1
      1 /* $NetBSD: hytp14var.h,v 1.2.6.1 2015/09/22 12:05:58 skrll Exp $ */
      2 
      3 /*-
      4  * Copyright (c) 2014 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Frank Kardel.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  * POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 /*
     33  * IST-AG P14 calibrated Hygro-/Temperature sensor module
     34  * Devices: HYT-271, HYT-221 and HYT-939
     35  *
     36  * see:
     37  * http://www.ist-ag.com/eh/ist-ag/resource.nsf/imgref/Download_AHHYTM_E2.1.pdf/
     38  *      $FILE/AHHYTM_E2.1.pdf
     39  */
     40 #ifndef _DEV_I2C_HYTP14VAR_H_
     41 #define _DEV_I2C_HYTP14VAR_H_
     42 
     43 #define HYTP14_DEFAULT_ADDR	0x28
     44 
     45 #define HYTP14_NUM_SENSORS	2
     46 
     47 /* the default measurement interval is 50 seconds */
     48 #define HYTP14_MR_INTERVAL	50
     49 
     50 struct hytp14_sc {
     51 	device_t	sc_dev;
     52 	i2c_tag_t	sc_tag;
     53 	i2c_addr_t	sc_addr;
     54 
     55 	int		sc_valid;   /* ENVSYS validity state for this sensor */
     56 	uint8_t		sc_data[4]; /* current sensor data */
     57 	uint8_t		sc_last[4]; /* last sensor data, before MR */
     58 
     59 	int		sc_numsensors;
     60 
     61 	callout_t	sc_mrcallout;
     62 	int32_t		sc_mrinterval;
     63 
     64 	struct sysmon_envsys *sc_sme;
     65 	envsys_data_t sc_sensors[HYTP14_NUM_SENSORS];
     66 };
     67 
     68 struct hytp14_sensor {
     69 	const char	  *desc;
     70 	enum envsys_units  type;
     71 	void		 (*refresh)(struct hytp14_sc *, envsys_data_t *);
     72 };
     73 
     74 #endif
     75