@@ -32,10 +32,9 @@ union bme280_bus {
32
32
};
33
33
34
34
typedef int (* bme280_bus_check_fn )(const union bme280_bus * bus );
35
- typedef int (* bme280_reg_read_fn )(const union bme280_bus * bus ,
36
- uint8_t start , uint8_t * buf , int size );
37
- typedef int (* bme280_reg_write_fn )(const union bme280_bus * bus ,
38
- uint8_t reg , uint8_t val );
35
+ typedef int (* bme280_reg_read_fn )(const union bme280_bus * bus , uint8_t start , uint8_t * buf ,
36
+ int size );
37
+ typedef int (* bme280_reg_write_fn )(const union bme280_bus * bus , uint8_t reg , uint8_t val );
39
38
40
39
struct bme280_bus_io {
41
40
bme280_bus_check_fn check ;
@@ -44,37 +43,36 @@ struct bme280_bus_io {
44
43
};
45
44
46
45
#if BME280_BUS_SPI
47
- #define BME280_SPI_OPERATION (SPI_WORD_SET(8) | SPI_TRANSFER_MSB | \
48
- SPI_MODE_CPOL | SPI_MODE_CPHA)
46
+ #define BME280_SPI_OPERATION (SPI_WORD_SET(8) | SPI_TRANSFER_MSB | SPI_MODE_CPOL | SPI_MODE_CPHA)
49
47
extern const struct bme280_bus_io bme280_bus_io_spi ;
50
48
#endif
51
49
52
50
#if BME280_BUS_I2C
53
51
extern const struct bme280_bus_io bme280_bus_io_i2c ;
54
52
#endif
55
53
56
- #define BME280_REG_PRESS_MSB 0xF7
57
- #define BME280_REG_COMP_START 0x88
58
- #define BME280_REG_HUM_COMP_PART1 0xA1
59
- #define BME280_REG_HUM_COMP_PART2 0xE1
60
- #define BME280_REG_ID 0xD0
61
- #define BME280_REG_CONFIG 0xF5
62
- #define BME280_REG_CTRL_MEAS 0xF4
63
- #define BME280_REG_CTRL_HUM 0xF2
64
- #define BME280_REG_STATUS 0xF3
65
- #define BME280_REG_RESET 0xE0
66
-
67
- #define BMP280_CHIP_ID_SAMPLE_1 0x56
68
- #define BMP280_CHIP_ID_SAMPLE_2 0x57
69
- #define BMP280_CHIP_ID_MP 0x58
70
- #define BME280_CHIP_ID 0x60
71
- #define BME280_MODE_SLEEP 0x00
72
- #define BME280_MODE_FORCED 0x01
73
- #define BME280_MODE_NORMAL 0x03
74
- #define BME280_SPI_3W_DISABLE 0x00
75
- #define BME280_CMD_SOFT_RESET 0xB6
76
- #define BME280_STATUS_MEASURING 0x08
77
- #define BME280_STATUS_IM_UPDATE 0x01
54
+ #define BME280_REG_PRESS_MSB 0xF7
55
+ #define BME280_REG_COMP_START 0x88
56
+ #define BME280_REG_HUM_COMP_PART1 0xA1
57
+ #define BME280_REG_HUM_COMP_PART2 0xE1
58
+ #define BME280_REG_ID 0xD0
59
+ #define BME280_REG_CONFIG 0xF5
60
+ #define BME280_REG_CTRL_MEAS 0xF4
61
+ #define BME280_REG_CTRL_HUM 0xF2
62
+ #define BME280_REG_STATUS 0xF3
63
+ #define BME280_REG_RESET 0xE0
64
+
65
+ #define BMP280_CHIP_ID_SAMPLE_1 0x56
66
+ #define BMP280_CHIP_ID_SAMPLE_2 0x57
67
+ #define BMP280_CHIP_ID_MP 0x58
68
+ #define BME280_CHIP_ID 0x60
69
+ #define BME280_MODE_SLEEP 0x00
70
+ #define BME280_MODE_FORCED 0x01
71
+ #define BME280_MODE_NORMAL 0x03
72
+ #define BME280_SPI_3W_DISABLE 0x00
73
+ #define BME280_CMD_SOFT_RESET 0xB6
74
+ #define BME280_STATUS_MEASURING 0x08
75
+ #define BME280_STATUS_IM_UPDATE 0x01
78
76
79
77
#if defined CONFIG_BME280_MODE_NORMAL
80
78
#define BME280_MODE BME280_MODE_NORMAL
@@ -83,93 +81,86 @@ extern const struct bme280_bus_io bme280_bus_io_i2c;
83
81
#endif
84
82
85
83
#if defined CONFIG_BME280_TEMP_OVER_1X
86
- #define BME280_TEMP_OVER (1 << 5)
84
+ #define BME280_TEMP_OVER (1 << 5)
87
85
#elif defined CONFIG_BME280_TEMP_OVER_2X
88
- #define BME280_TEMP_OVER (2 << 5)
86
+ #define BME280_TEMP_OVER (2 << 5)
89
87
#elif defined CONFIG_BME280_TEMP_OVER_4X
90
- #define BME280_TEMP_OVER (3 << 5)
88
+ #define BME280_TEMP_OVER (3 << 5)
91
89
#elif defined CONFIG_BME280_TEMP_OVER_8X
92
- #define BME280_TEMP_OVER (4 << 5)
90
+ #define BME280_TEMP_OVER (4 << 5)
93
91
#elif defined CONFIG_BME280_TEMP_OVER_16X
94
- #define BME280_TEMP_OVER (5 << 5)
92
+ #define BME280_TEMP_OVER (5 << 5)
95
93
#endif
96
94
97
95
#if defined CONFIG_BME280_PRESS_OVER_1X
98
- #define BME280_PRESS_OVER (1 << 2)
96
+ #define BME280_PRESS_OVER (1 << 2)
99
97
#elif defined CONFIG_BME280_PRESS_OVER_2X
100
- #define BME280_PRESS_OVER (2 << 2)
98
+ #define BME280_PRESS_OVER (2 << 2)
101
99
#elif defined CONFIG_BME280_PRESS_OVER_4X
102
- #define BME280_PRESS_OVER (3 << 2)
100
+ #define BME280_PRESS_OVER (3 << 2)
103
101
#elif defined CONFIG_BME280_PRESS_OVER_8X
104
- #define BME280_PRESS_OVER (4 << 2)
102
+ #define BME280_PRESS_OVER (4 << 2)
105
103
#elif defined CONFIG_BME280_PRESS_OVER_16X
106
- #define BME280_PRESS_OVER (5 << 2)
104
+ #define BME280_PRESS_OVER (5 << 2)
107
105
#endif
108
106
109
107
#if defined CONFIG_BME280_HUMIDITY_OVER_1X
110
- #define BME280_HUMIDITY_OVER 1
108
+ #define BME280_HUMIDITY_OVER 1
111
109
#elif defined CONFIG_BME280_HUMIDITY_OVER_2X
112
- #define BME280_HUMIDITY_OVER 2
110
+ #define BME280_HUMIDITY_OVER 2
113
111
#elif defined CONFIG_BME280_HUMIDITY_OVER_4X
114
- #define BME280_HUMIDITY_OVER 3
112
+ #define BME280_HUMIDITY_OVER 3
115
113
#elif defined CONFIG_BME280_HUMIDITY_OVER_8X
116
- #define BME280_HUMIDITY_OVER 4
114
+ #define BME280_HUMIDITY_OVER 4
117
115
#elif defined CONFIG_BME280_HUMIDITY_OVER_16X
118
- #define BME280_HUMIDITY_OVER 5
116
+ #define BME280_HUMIDITY_OVER 5
119
117
#endif
120
118
121
119
#if defined CONFIG_BME280_STANDBY_05MS
122
- #define BME280_STANDBY 0
120
+ #define BME280_STANDBY 0
123
121
#elif defined CONFIG_BME280_STANDBY_62MS
124
- #define BME280_STANDBY (1 << 5)
122
+ #define BME280_STANDBY (1 << 5)
125
123
#elif defined CONFIG_BME280_STANDBY_125MS
126
- #define BME280_STANDBY (2 << 5)
124
+ #define BME280_STANDBY (2 << 5)
127
125
#elif defined CONFIG_BME280_STANDBY_250MS
128
- #define BME280_STANDBY (3 << 5)
126
+ #define BME280_STANDBY (3 << 5)
129
127
#elif defined CONFIG_BME280_STANDBY_500MS
130
- #define BME280_STANDBY (4 << 5)
128
+ #define BME280_STANDBY (4 << 5)
131
129
#elif defined CONFIG_BME280_STANDBY_1000MS
132
- #define BME280_STANDBY (5 << 5)
130
+ #define BME280_STANDBY (5 << 5)
133
131
#elif defined CONFIG_BME280_STANDBY_2000MS
134
- #define BME280_STANDBY (6 << 5)
132
+ #define BME280_STANDBY (6 << 5)
135
133
#elif defined CONFIG_BME280_STANDBY_4000MS
136
- #define BME280_STANDBY (7 << 5)
134
+ #define BME280_STANDBY (7 << 5)
137
135
#endif
138
136
139
137
#if defined CONFIG_BME280_FILTER_OFF
140
- #define BME280_FILTER 0
138
+ #define BME280_FILTER 0
141
139
#elif defined CONFIG_BME280_FILTER_2
142
- #define BME280_FILTER (1 << 2)
140
+ #define BME280_FILTER (1 << 2)
143
141
#elif defined CONFIG_BME280_FILTER_4
144
- #define BME280_FILTER (2 << 2)
142
+ #define BME280_FILTER (2 << 2)
145
143
#elif defined CONFIG_BME280_FILTER_8
146
- #define BME280_FILTER (3 << 2)
144
+ #define BME280_FILTER (3 << 2)
147
145
#elif defined CONFIG_BME280_FILTER_16
148
- #define BME280_FILTER (4 << 2)
146
+ #define BME280_FILTER (4 << 2)
149
147
#endif
150
148
151
- #define BME280_CTRL_MEAS_VAL (BME280_PRESS_OVER | \
152
- BME280_TEMP_OVER | \
153
- BME280_MODE)
154
- #define BME280_CONFIG_VAL (BME280_STANDBY | \
155
- BME280_FILTER | \
156
- BME280_SPI_3W_DISABLE)
149
+ #define BME280_CTRL_MEAS_VAL (BME280_PRESS_OVER | BME280_TEMP_OVER | BME280_MODE)
150
+ #define BME280_CONFIG_VAL (BME280_STANDBY | BME280_FILTER | BME280_SPI_3W_DISABLE)
157
151
158
-
159
- #define BME280_CTRL_MEAS_OFF_VAL (BME280_PRESS_OVER | \
160
- BME280_TEMP_OVER | \
161
- BME280_MODE_SLEEP)
152
+ #define BME280_CTRL_MEAS_OFF_VAL (BME280_PRESS_OVER | BME280_TEMP_OVER | BME280_MODE_SLEEP)
162
153
163
154
/* Convert to Q15.16 */
164
- #define BME280_TEMP_CONV 100
165
- #define BME280_TEMP_SHIFT 16
155
+ #define BME280_TEMP_CONV 100
156
+ #define BME280_TEMP_SHIFT 16
166
157
/* Treat UQ24.8 as Q23.8
167
158
* Need to divide by 1000 to convert to kPa
168
159
*/
169
- #define BME280_PRESS_CONV_KPA 1000
170
- #define BME280_PRESS_SHIFT 23
160
+ #define BME280_PRESS_CONV_KPA 1000
161
+ #define BME280_PRESS_SHIFT 23
171
162
/* Treat UQ22.10 as Q21.10 */
172
- #define BME280_HUM_SHIFT 21
163
+ #define BME280_HUM_SHIFT 21
173
164
174
165
struct bme280_reading {
175
166
/* Compensated values. */
@@ -232,11 +223,9 @@ int bme280_get_decoder(const struct device *dev, const struct sensor_decoder_api
232
223
233
224
void bme280_submit (const struct device * dev , struct rtio_iodev_sqe * iodev_sqe );
234
225
235
- int bme280_sample_fetch (const struct device * dev ,
236
- enum sensor_channel chan );
226
+ int bme280_sample_fetch (const struct device * dev , enum sensor_channel chan );
237
227
238
- int bme280_sample_fetch_helper (const struct device * dev ,
239
- enum sensor_channel chan ,
228
+ int bme280_sample_fetch_helper (const struct device * dev , enum sensor_channel chan ,
240
229
struct bme280_reading * reading );
241
230
242
231
#endif /* ZEPHYR_DRIVERS_SENSOR_BME280_BME280_H_ */
0 commit comments