bmx280var.h revision 1.1 1 1.1 brad /* $NetBSD: bmx280var.h,v 1.1 2022/12/03 01:04:43 brad Exp $ */
2 1.1 brad
3 1.1 brad /*
4 1.1 brad * Copyright (c) 2022 Brad Spencer <brad (at) anduin.eldar.org>
5 1.1 brad *
6 1.1 brad * Permission to use, copy, modify, and distribute this software for any
7 1.1 brad * purpose with or without fee is hereby granted, provided that the above
8 1.1 brad * copyright notice and this permission notice appear in all copies.
9 1.1 brad *
10 1.1 brad * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 1.1 brad * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 1.1 brad * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 1.1 brad * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 1.1 brad * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 1.1 brad * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 1.1 brad * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 1.1 brad */
18 1.1 brad
19 1.1 brad #ifndef _DEV_IC_BMX280VAR_H_
20 1.1 brad #define _DEV_IC_BMX280VAR_H_
21 1.1 brad
22 1.1 brad #define BMX280_NUM_SENSORS 3
23 1.1 brad #define BMX280_TEMP_SENSOR 0
24 1.1 brad #define BMX280_PRESSURE_SENSOR 1
25 1.1 brad #define BMX280_HUMIDITY_SENSOR 2
26 1.1 brad
27 1.1 brad struct bmx280_calibration_blob {
28 1.1 brad uint16_t dig_T1;
29 1.1 brad int16_t dig_T2;
30 1.1 brad int16_t dig_T3;
31 1.1 brad
32 1.1 brad uint16_t dig_P1;
33 1.1 brad int16_t dig_P2;
34 1.1 brad int16_t dig_P3;
35 1.1 brad int16_t dig_P4;
36 1.1 brad int16_t dig_P5;
37 1.1 brad int16_t dig_P6;
38 1.1 brad int16_t dig_P7;
39 1.1 brad int16_t dig_P8;
40 1.1 brad int16_t dig_P9;
41 1.1 brad uint8_t dig_H1;
42 1.1 brad int16_t dig_H2;
43 1.1 brad uint8_t dig_H3;
44 1.1 brad int16_t dig_H4;
45 1.1 brad int16_t dig_H5;
46 1.1 brad int8_t dig_H6;
47 1.1 brad };
48 1.1 brad
49 1.1 brad struct bmx280_sc {
50 1.1 brad int sc_bmx280debug;
51 1.1 brad device_t sc_dev;
52 1.1 brad i2c_tag_t sc_tag;
53 1.1 brad i2c_addr_t sc_addr;
54 1.1 brad struct spi_handle *sc_sh;
55 1.1 brad kmutex_t sc_mutex;
56 1.1 brad int sc_numsensors;
57 1.1 brad struct sysmon_envsys *sc_sme;
58 1.1 brad struct sysctllog *sc_bmx280log;
59 1.1 brad envsys_data_t sc_sensors[BMX280_NUM_SENSORS];
60 1.1 brad struct bmx280_calibration_blob sc_cal_blob;
61 1.1 brad bool sc_has_humidity;
62 1.1 brad int sc_readattempts;
63 1.1 brad int sc_osrs_t;
64 1.1 brad int sc_osrs_p;
65 1.1 brad int sc_osrs_h;
66 1.1 brad int sc_irr_samples;
67 1.1 brad uint8_t sc_previous_irr;
68 1.1 brad bool sc_bmx280dump;
69 1.1 brad int sc_waitfactor_t;
70 1.1 brad int sc_waitfactor_p;
71 1.1 brad int sc_waitfactor_h;
72 1.1 brad void (*sc_func_attach)(struct bmx280_sc *);
73 1.1 brad int (*sc_func_acquire_bus)(struct bmx280_sc *);
74 1.1 brad void (*sc_func_release_bus)(struct bmx280_sc *);
75 1.1 brad int (*sc_func_read_register)(struct bmx280_sc *, uint8_t, uint8_t *, size_t);
76 1.1 brad int (*sc_func_write_register)(struct bmx280_sc *, uint8_t *, size_t);
77 1.1 brad };
78 1.1 brad
79 1.1 brad struct bmx280_sensor {
80 1.1 brad const char *desc;
81 1.1 brad enum envsys_units type;
82 1.1 brad };
83 1.1 brad
84 1.1 brad struct bmx280_osrs_list {
85 1.1 brad const int text;
86 1.1 brad uint8_t mask;
87 1.1 brad };
88 1.1 brad
89 1.1 brad struct bmx280_irr_list {
90 1.1 brad const int text;
91 1.1 brad uint8_t mask;
92 1.1 brad };
93 1.1 brad
94 1.1 brad #endif
95