Skip to content

Commit 02862ce

Browse files
authored
Merge pull request #28 from coffee-and-telesense/trim_bosch_library
Trim bosch library
2 parents dd9db27 + 89d9031 commit 02862ce

File tree

7 files changed

+242
-393
lines changed

7 files changed

+242
-393
lines changed

libs/bme68x/Inc/bme68x.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ extern "C"
238238
* \code
239239
* int8_t bme68x_set_conf(struct bme68x_conf *conf, struct bme68x_dev *dev);
240240
* \endcode
241-
* @details This API is used to set the oversampling, filter and odr configuration
241+
* @details This API is used to set the oversampling and filter configuration
242242
*
243243
* @param[in] conf : Desired sensor configuration.
244244
* @param[in,out] dev : Structure instance of bme68x_dev.
@@ -255,8 +255,7 @@ extern "C"
255255
* \code
256256
* int8_t bme68x_get_conf(struct bme68x_conf *conf, struct bme68x_dev *dev);
257257
* \endcode
258-
* @details This API is used to get the oversampling, filter and odr
259-
* configuration
258+
* @details This API is used to get the oversampling and filter configuration
260259
*
261260
* @param[out] conf : Present sensor configuration.
262261
* @param[in,out] dev : Structure instance of bme68x_dev.

libs/bme68x/Inc/bme68x_defs.h

Lines changed: 1 addition & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -262,35 +262,6 @@
262262
/* Filter coefficient of 128 */
263263
#define BME68X_FILTER_SIZE_127 UINT8_C(7)
264264

265-
/* ODR/Standby time macros */
266-
267-
/* Standby time of 0.59ms */
268-
#define BME68X_ODR_0_59_MS UINT8_C(0)
269-
270-
/* Standby time of 62.5ms */
271-
#define BME68X_ODR_62_5_MS UINT8_C(1)
272-
273-
/* Standby time of 125ms */
274-
#define BME68X_ODR_125_MS UINT8_C(2)
275-
276-
/* Standby time of 250ms */
277-
#define BME68X_ODR_250_MS UINT8_C(3)
278-
279-
/* Standby time of 500ms */
280-
#define BME68X_ODR_500_MS UINT8_C(4)
281-
282-
/* Standby time of 1s */
283-
#define BME68X_ODR_1000_MS UINT8_C(5)
284-
285-
/* Standby time of 10ms */
286-
#define BME68X_ODR_10_MS UINT8_C(6)
287-
288-
/* Standby time of 20ms */
289-
#define BME68X_ODR_20_MS UINT8_C(7)
290-
291-
/* No standby time */
292-
#define BME68X_ODR_NONE UINT8_C(8)
293-
294265
/* Operating mode macros */
295266

296267
/* Sleep operation mode */
@@ -299,20 +270,6 @@
299270
/* Forced operation mode */
300271
#define BME68X_FORCED_MODE UINT8_C(1)
301272

302-
/* Parallel operation mode */
303-
#define BME68X_PARALLEL_MODE UINT8_C(2)
304-
305-
/* Sequential operation mode */
306-
#define BME68X_SEQUENTIAL_MODE UINT8_C(3)
307-
308-
/* SPI page macros */
309-
310-
/* SPI memory page 0 */
311-
#define BME68X_MEM_PAGE0 UINT8_C(0x10)
312-
313-
/* SPI memory page 1 */
314-
#define BME68X_MEM_PAGE1 UINT8_C(0x00)
315-
316273
/* Coefficient index macros */
317274

318275
/* Length for all coefficients */
@@ -527,12 +484,6 @@
527484
/* Mask for IIR filter */
528485
#define BME68X_FILTER_MSK UINT8_C(0X1c)
529486

530-
/* Mask for ODR[3] */
531-
#define BME68X_ODR3_MSK UINT8_C(0x80)
532-
533-
/* Mask for ODR[2:0] */
534-
#define BME68X_ODR20_MSK UINT8_C(0xe0)
535-
536487
/* Mask for temperature oversampling */
537488
#define BME68X_OST_MSK UINT8_C(0Xe0)
538489

@@ -572,15 +523,6 @@
572523
/* Mask for heater stability */
573524
#define BME68X_HEAT_STAB_MSK UINT8_C(0x10)
574525

575-
/* Mask for SPI memory page */
576-
#define BME68X_MEM_PAGE_MSK UINT8_C(0x10)
577-
578-
/* Mask for reading a register in SPI */
579-
#define BME68X_SPI_RD_MSK UINT8_C(0x80)
580-
581-
/* Mask for writing a register in SPI */
582-
#define BME68X_SPI_WR_MSK UINT8_C(0x7f)
583-
584526
/* Mask for the H1 calibration coefficient */
585527
#define BME68X_BIT_H1_DATA_MSK UINT8_C(0x0f)
586528

@@ -595,12 +537,6 @@
595537
/* Pressure oversampling bit position */
596538
#define BME68X_OSP_POS UINT8_C(2)
597539

598-
/* ODR[3] bit position */
599-
#define BME68X_ODR3_POS UINT8_C(7)
600-
601-
/* ODR[2:0] bit position */
602-
#define BME68X_ODR20_POS UINT8_C(5)
603-
604540
/* Run gas bit position */
605541
#define BME68X_RUN_GAS_POS UINT8_C(4)
606542

@@ -700,17 +636,6 @@ typedef void (*bme68x_delay_us_fptr_t)(uint32_t period, void *intf_ptr);
700636
* @param[in] len: Length of the data array
701637
*/
702638

703-
/*
704-
* @brief Interface selection Enumerations
705-
*/
706-
enum bme68x_intf
707-
{
708-
/*! SPI interface */
709-
BME68X_SPI_INTF,
710-
/*! I2C interface */
711-
BME68X_I2C_INTF
712-
};
713-
714639
/* Structure definitions */
715640

716641
/*
@@ -859,7 +784,7 @@ struct bme68x_calib_data
859784
};
860785

861786
/*
862-
* @brief BME68X sensor settings structure which comprises of ODR,
787+
* @brief BME68X sensor settings structure which comprises of
863788
* over-sampling and filter settings.
864789
*/
865790
struct bme68x_conf
@@ -875,12 +800,6 @@ struct bme68x_conf
875800

876801
/*! Filter coefficient. Refer @ref filter*/
877802
uint8_t filter;
878-
879-
/*!
880-
* Standby time between sequential mode measurement profiles.
881-
* Refer @ref odr
882-
*/
883-
uint8_t odr;
884803
};
885804

886805
/*
@@ -905,12 +824,6 @@ struct bme68x_heatr_conf
905824

906825
/*! Variable to store the length of the heating profile */
907826
uint8_t profile_len;
908-
909-
/*!
910-
* Variable to store heating duration for parallel mode
911-
* in milliseconds
912-
*/
913-
uint16_t shared_heatr_dur;
914827
};
915828

916829
/*
@@ -940,9 +853,6 @@ struct bme68x_dev
940853
*/
941854
uint32_t variant_id;
942855

943-
/*! SPI/I2C interface */
944-
enum bme68x_intf intf;
945-
946856
/*! Memory page used */
947857
uint8_t mem_page;
948858

libs/bme68x/Inc/bme68x_driver.h

Lines changed: 13 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ typedef struct
6868
struct bme68x_heatr_conf heatr_conf;
6969

7070
/** Structure to store sensor measurement data. */
71-
/** @todo: May modify this to be an array in order to support parallel mode */
7271
/** @note: Since we're not using floating point, the data will be as follows:
7372
* - Temperature in degrees celsius x100
7473
* - Pressure in Pascal
@@ -77,16 +76,6 @@ typedef struct
7776
*/
7877
struct bme68x_data sensor_data;
7978

80-
// /** Array to store multiple sensor data values (for parallel mode). */
81-
// struct bme68x_data sensor_data[3];
82-
83-
/** @todo: Similar to a sensor_data array, n_fields and i_fields are for parallel mode support */
84-
// /** Number of data fields in parallel mode. */
85-
// uint8_t n_fields;
86-
87-
// /** Index for tracking sensor data fields. */
88-
// uint8_t i_fields;
89-
9079
/** Last operation mode used by the sensor. */
9180
uint8_t last_opmode;
9281
} bme68x_sensor_t;
@@ -146,22 +135,18 @@ void bme_set_TPH(bme68x_sensor_t *bme, uint8_t os_temp, uint8_t os_pres, uint8_t
146135
* @param[in] bme Pointer to bme68x sensor interface
147136
* @param[in] temp Heater temperature in degree Celsius
148137
* @param[in] dur Heating duration in milliseconds
149-
* @todo: Implement similar functions for sequential and parallel modes, as needed.
150138
*/
151139
void bme_set_heaterprof(bme68x_sensor_t *bme, uint16_t temp, uint16_t dur);
152140

153141
/**
154142
* @brief Set the operation mode
155143
*
156-
* Set the desired operation mode.
157-
* @todo: Initially, we will only support forced mode, which performs a single measurement
158-
* and allows for automatically returning to sleep mode. The gas sensor heater only operates
159-
* during measurement in this mode.
160-
* In parallel mode, multiple TPHG cycles are performed, the sensor does not return to sleep
161-
* mode automatically, and the gas sensor heater operates in parallel to TPH measurement.
144+
* Set the desired operation mode. Currently supports sleep mode and forced mode for
145+
* a single, low-power measurment which may automatically return to sleep mode.
146+
* The gas sensor heater only operates during measurement in this mode.
162147
*
163148
* @param[in] bme Pointer to bme68x sensor interface
164-
* @param[in] opmode BME68X_SLEEP_MODE, BME68X_FORCED_MODE, BME68X_PARALLEL_MODE, BME68X_SEQUENTIAL_MODE
149+
* @param[in] opmode BME68X_SLEEP_MODE, BME68X_FORCED_MODE
165150
*/
166151
void bme_set_opmode(bme68x_sensor_t *bme, uint8_t opmode);
167152

@@ -177,33 +162,12 @@ void bme_set_opmode(bme68x_sensor_t *bme, uint8_t opmode);
177162
*/
178163
uint8_t bme_fetch_data(bme68x_sensor_t *bme);
179164

180-
/**
181-
* @brief Get a single data field
182-
*
183-
* @todo: Implement as needed
184-
*
185-
* @param[in] bme Pointer to bme68x sensor interface
186-
* @param[out] data Structure where the data is to be stored
187-
* @return Number of new fields remaining
188-
*/
189-
// uint8_t bme_get_data(bme68x_sensor_t *bme, bme68x_data &data);
190-
191-
/**
192-
* @brief Function to get whole sensor data
193-
*
194-
* @todo: Implement as needed
195-
*
196-
* @param[in] bme Pointer to bme68x sensor interface
197-
* @return Sensor data
198-
*/
199-
// bme68x_data *bme_get_alldata(bme68x_sensor_t *bme);
200-
201165
/**
202166
* @brief Get the measurement duration in microseconds
203167
*
204168
* Calls bme68x_get_meas_dur, which calculates the total measurement duration
205169
* based on the total number of samples to be taken, as determined by the oversampling
206-
* for each value; if not operating in parallel mode, a wake-up duration of 1ms is added.
170+
* for each value; a wake-up duration of 1ms is added.
207171
*
208172
* @param[in] bme Pointer to bme68x sensor interface
209173
* @param[in] opmode Operation mode of the sensor. Attempts to use the last one if nothing is set
@@ -269,14 +233,16 @@ int8_t bme_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t length, void *intf
269233
* while (1)
270234
* {
271235
* bme_set_opmode(&bme, BME68X_FORCED_MODE);
236+
* // @todo: May adjust the specific timing function called here, but it should be based on bme_get_meas_dur
237+
* bme_delay_us(bme_get_meas_dur(&bme, BME68X_SLEEP_MODE), &hi2c1);
272238
* int fetch_success = bme_fetch_data(&bme);
273239
* if (fetch_success) {
274-
debug_print("%d, ", bme.sensor_data.temperature);
275-
debug_print("%d, ", bme.sensor_data.pressure);
276-
debug_print("%d, ", bme.sensor_data.humidity);
277-
debug_print("%d, ", bme.sensor_data.gas_resistance);
278-
debug_print("%X, \r\n", bme.sensor_data.status);
279-
}
240+
* debug_print("%d, ", bme.sensor_data.temperature);
241+
* debug_print("%d, ", bme.sensor_data.pressure);
242+
* debug_print("%d, ", bme.sensor_data.humidity);
243+
* debug_print("%d, ", bme.sensor_data.gas_resistance);
244+
* debug_print("%X, \r\n", bme.sensor_data.status);
245+
* }
280246
* }
281247
* }
282248
* @endcode

0 commit comments

Comments
 (0)