hytp14reg.h revision 1.1.2.2 1 /* $NetBSD: hytp14reg.h,v 1.1.2.2 2014/05/18 17:45:37 rmind 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_HYTP14REG_H_
41 #define _DEV_I2C_HYTP14REG_H_
42
43 #define HYTP14_DEFAULT_ADDR 0x28
44
45 #define HYTP14_CMD_SEND 0x50 /* send command */
46 #define HYTP14_CMD_RESP 0x51 /* receive response */
47
48 #define HYTP14_CMD_START_NOM 0x80 /* end command mode (or power-off) */
49 #define HYTP14_CMD_START_CM 0xA0 /* start command mode (within 10ms after power-up) */
50 #define HYTP14_CMD_GET_REV 0xB0 /* get revison */
51
52 #define HYTP14_NUM_WORDS 32
53 #define HYTP14_READ_OFFSET 0x00 /* command offset to read EEPROM words */
54 #define HYTP14_WRITE_OFFSET 0x40 /* command offset to write EEPROM words */
55
56 #define HYTP14_READ_EEPROM(_X_) (HYTP14_READ_OFFSET + (_X_) & (HYTP14_NUM_WORDS - 1))
57 #define HYTP14_WRITE_EEPROM(_X_) (HYTP14_WRITE_OFFSET + (_X_) & (HYTP14_NUM_WORDS - 1))
58
59 #define HYTP14_EEADDR_I2CADDR 0x1C /* I2C address EEPROD word address */
60
61 #define HYTP14_RESP_CMDMODE 0x80 /* command mode response */
62 #define HYTP14_RESP_STALE 0y40 /* stale measurement data */
63
64 #define HYTP14_DIAG_ERR_CFG 0x20 /* configuration error */
65 #define HYTP14_DIAG_ERR_RAMPRTY 0x10 /* RAM parity error */
66 #define HYTP14_DIAG_ERR_UNCEEP 0x08 /* uncorrectable EEPROM error */
67 #define HYTP14_DIAG_ERR_COREEP 0x04 /* correctable EEPROM error */
68
69 #define HYTP14_RESP_MASK 0x03
70 #define HYTP14_RESP_BUSY 0x00 /* device is busy */
71 #define HYTP14_RESP_ACK 0x01 /* positive acknowlege */
72 #define HYTP14_RESP_NACK 0x02 /* negative acknowlege */
73
74 #define HYTP14_ST_CMDMODE 0x8000 /* command mode */
75 #define HYTP14_ST_STALE 0x4000 /* stale measurement data */
76 #define HYTP14_HYG_RAWVAL(_X_) ((_X_) & 0x3FFF)
77 #define HYTP14_HYG_SCALE (1<<14)
78 #define HYTP14_TEMP_RAWVAL(_X_) (((_X_) >> 2) & 0x3FFF)
79 #define HYTP14_TEMP_SCALE (1<<14)
80 #define HYTP14_TEMP_FACTOR 165
81 #define HYTP14_TEMP_OFFSET (-40)
82
83 #endif
84 /*
85 * $Log: hytp14reg.h,v $
86 * Revision 1.1.2.2 2014/05/18 17:45:37 rmind
87 * sync with head
88 *
89 * Revision 1.1 2014/05/18 11:46:23 kardel
90 * add HYT-221/271/939 humidity/temperature I2C sensor
91 * extend envsys(4) framework by %rH (relative humidity)
92 *
93 */
94