@@ -32,10 +32,9 @@ union bme280_bus {
3232};
3333
3434typedef 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 );
3938
4039struct bme280_bus_io {
4140 bme280_bus_check_fn check ;
@@ -44,37 +43,36 @@ struct bme280_bus_io {
4443};
4544
4645#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)
4947extern const struct bme280_bus_io bme280_bus_io_spi ;
5048#endif
5149
5250#if BME280_BUS_I2C
5351extern const struct bme280_bus_io bme280_bus_io_i2c ;
5452#endif
5553
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
7876
7977#if defined CONFIG_BME280_MODE_NORMAL
8078#define BME280_MODE BME280_MODE_NORMAL
@@ -83,93 +81,86 @@ extern const struct bme280_bus_io bme280_bus_io_i2c;
8381#endif
8482
8583#if defined CONFIG_BME280_TEMP_OVER_1X
86- #define BME280_TEMP_OVER (1 << 5)
84+ #define BME280_TEMP_OVER (1 << 5)
8785#elif defined CONFIG_BME280_TEMP_OVER_2X
88- #define BME280_TEMP_OVER (2 << 5)
86+ #define BME280_TEMP_OVER (2 << 5)
8987#elif defined CONFIG_BME280_TEMP_OVER_4X
90- #define BME280_TEMP_OVER (3 << 5)
88+ #define BME280_TEMP_OVER (3 << 5)
9189#elif defined CONFIG_BME280_TEMP_OVER_8X
92- #define BME280_TEMP_OVER (4 << 5)
90+ #define BME280_TEMP_OVER (4 << 5)
9391#elif defined CONFIG_BME280_TEMP_OVER_16X
94- #define BME280_TEMP_OVER (5 << 5)
92+ #define BME280_TEMP_OVER (5 << 5)
9593#endif
9694
9795#if defined CONFIG_BME280_PRESS_OVER_1X
98- #define BME280_PRESS_OVER (1 << 2)
96+ #define BME280_PRESS_OVER (1 << 2)
9997#elif defined CONFIG_BME280_PRESS_OVER_2X
100- #define BME280_PRESS_OVER (2 << 2)
98+ #define BME280_PRESS_OVER (2 << 2)
10199#elif defined CONFIG_BME280_PRESS_OVER_4X
102- #define BME280_PRESS_OVER (3 << 2)
100+ #define BME280_PRESS_OVER (3 << 2)
103101#elif defined CONFIG_BME280_PRESS_OVER_8X
104- #define BME280_PRESS_OVER (4 << 2)
102+ #define BME280_PRESS_OVER (4 << 2)
105103#elif defined CONFIG_BME280_PRESS_OVER_16X
106- #define BME280_PRESS_OVER (5 << 2)
104+ #define BME280_PRESS_OVER (5 << 2)
107105#endif
108106
109107#if defined CONFIG_BME280_HUMIDITY_OVER_1X
110- #define BME280_HUMIDITY_OVER 1
108+ #define BME280_HUMIDITY_OVER 1
111109#elif defined CONFIG_BME280_HUMIDITY_OVER_2X
112- #define BME280_HUMIDITY_OVER 2
110+ #define BME280_HUMIDITY_OVER 2
113111#elif defined CONFIG_BME280_HUMIDITY_OVER_4X
114- #define BME280_HUMIDITY_OVER 3
112+ #define BME280_HUMIDITY_OVER 3
115113#elif defined CONFIG_BME280_HUMIDITY_OVER_8X
116- #define BME280_HUMIDITY_OVER 4
114+ #define BME280_HUMIDITY_OVER 4
117115#elif defined CONFIG_BME280_HUMIDITY_OVER_16X
118- #define BME280_HUMIDITY_OVER 5
116+ #define BME280_HUMIDITY_OVER 5
119117#endif
120118
121119#if defined CONFIG_BME280_STANDBY_05MS
122- #define BME280_STANDBY 0
120+ #define BME280_STANDBY 0
123121#elif defined CONFIG_BME280_STANDBY_62MS
124- #define BME280_STANDBY (1 << 5)
122+ #define BME280_STANDBY (1 << 5)
125123#elif defined CONFIG_BME280_STANDBY_125MS
126- #define BME280_STANDBY (2 << 5)
124+ #define BME280_STANDBY (2 << 5)
127125#elif defined CONFIG_BME280_STANDBY_250MS
128- #define BME280_STANDBY (3 << 5)
126+ #define BME280_STANDBY (3 << 5)
129127#elif defined CONFIG_BME280_STANDBY_500MS
130- #define BME280_STANDBY (4 << 5)
128+ #define BME280_STANDBY (4 << 5)
131129#elif defined CONFIG_BME280_STANDBY_1000MS
132- #define BME280_STANDBY (5 << 5)
130+ #define BME280_STANDBY (5 << 5)
133131#elif defined CONFIG_BME280_STANDBY_2000MS
134- #define BME280_STANDBY (6 << 5)
132+ #define BME280_STANDBY (6 << 5)
135133#elif defined CONFIG_BME280_STANDBY_4000MS
136- #define BME280_STANDBY (7 << 5)
134+ #define BME280_STANDBY (7 << 5)
137135#endif
138136
139137#if defined CONFIG_BME280_FILTER_OFF
140- #define BME280_FILTER 0
138+ #define BME280_FILTER 0
141139#elif defined CONFIG_BME280_FILTER_2
142- #define BME280_FILTER (1 << 2)
140+ #define BME280_FILTER (1 << 2)
143141#elif defined CONFIG_BME280_FILTER_4
144- #define BME280_FILTER (2 << 2)
142+ #define BME280_FILTER (2 << 2)
145143#elif defined CONFIG_BME280_FILTER_8
146- #define BME280_FILTER (3 << 2)
144+ #define BME280_FILTER (3 << 2)
147145#elif defined CONFIG_BME280_FILTER_16
148- #define BME280_FILTER (4 << 2)
146+ #define BME280_FILTER (4 << 2)
149147#endif
150148
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)
157151
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)
162153
163154/* 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
166157/* Treat UQ24.8 as Q23.8
167158 * Need to divide by 1000 to convert to kPa
168159 */
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
171162/* Treat UQ22.10 as Q21.10 */
172- #define BME280_HUM_SHIFT 21
163+ #define BME280_HUM_SHIFT 21
173164
174165struct bme280_reading {
175166 /* Compensated values. */
@@ -232,11 +223,9 @@ int bme280_get_decoder(const struct device *dev, const struct sensor_decoder_api
232223
233224void bme280_submit (const struct device * dev , struct rtio_iodev_sqe * iodev_sqe );
234225
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 );
237227
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 ,
240229 struct bme280_reading * reading );
241230
242231#endif /* ZEPHYR_DRIVERS_SENSOR_BME280_BME280_H_ */
0 commit comments