am2315var.h revision 1.1 1 /*
2 * Copyright (c) 2017 Brad Spencer <brad (at) anduin.eldar.org>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17 #ifndef _DEV_I2C_AM2315VAR_H_
18 #define _DEV_I2C_AM2315VAR_H_
19
20 #include <sys/time.h>
21
22 #define AM2315_NUM_SENSORS 2
23 #define AM2315_HUMIDITY_SENSOR 0
24 #define AM2315_TEMP_SENSOR 1
25
26 struct am2315_sc {
27 int sc_am2315debug;
28 device_t sc_dev;
29 i2c_tag_t sc_tag;
30 i2c_addr_t sc_addr;
31 kmutex_t sc_mutex;
32 kmutex_t sc_waitmutex;
33 kcondvar_t sc_condwait;
34 int sc_numsensors;
35 struct sysmon_envsys *sc_sme;
36 envsys_data_t sc_sensors[AM2315_NUM_SENSORS];
37 struct sysctllog *sc_am2315log;
38 int sc_readcount;
39 int sc_readticks;
40 };
41
42 struct am2315_sensor {
43 const char *desc;
44 enum envsys_units type;
45 };
46
47 #endif
48