-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbme688.h
142 lines (127 loc) · 4.45 KB
/
bme688.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/**
* Copyright (C) 2021 Bosch Sensortec GmbH. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifdef __cplusplus
extern "C" {
#endif /*__cplusplus */
#include "bme68x.h"
#include "bme68x_defs.h"
#include <zephyr/drivers/i2c.h>
#include <zephyr/drivers/sensor.h>
#define BME68X_VALID_DATA (BME68X_NEW_DATA_MSK|BME68X_GASM_VALID_MSK|BME68X_HEAT_STAB_MSK)
typedef enum{
bme688_mode_sleep = 0x00,
bme688_mode_forced = 0x01,
bme688_mode_parallel = 0x02,
bme688_mode_sequencial = 0x03
} bme688_mode_t;
struct bme688_config {
struct i2c_dt_spec i2c;
};
typedef struct{
uint16_t heater_temperature;
uint16_t heater_duration;
uint16_t *heater_temperature_profile;
uint16_t *heater_duration_profile;
uint8_t heater_profile_len;
uint8_t op_mode;
}bme688_heater_config_t;
/*!
* @brief Function to select the interface between SPI and I2C.
*
* @param[in] bme : Structure instance of bme68x_dev
* @param[in] intf : Interface selection parameter
*
* @return Status of execution
* @retval 0 -> Success
* @retval < 0 -> Failure Info
*/
int bme688_init(const struct device * dev);
void bme688_set_mode(bme688_mode_t v_mode);
void bme688_set_oversampling(uint8_t osTemp, uint8_t osPres, uint8_t osHum);
void bme688_set_heater_config(bme688_heater_config_t *heater_config);
void bme688_set_mode_default_conf(bme688_mode_t v_mode);
void bme688_wait_for_measure();
int bme688_sample_fetch(const struct device *dev,enum sensor_channel chan);
uint8_t bme688_data_get(const struct device *dev, struct bme68x_data *data);
/*!
* @brief Function for reading the sensor's registers through I2C bus.
*
* @param[in] reg_addr : Register address.
* @param[out] reg_data : Pointer to the data buffer to store the read data.
* @param[in] len : No of bytes to read.
* @param[in] intf_ptr : Interface pointer
*
* @return Status of execution
* @retval = BME68X_INTF_RET_SUCCESS -> Success
* @retval != BME68X_INTF_RET_SUCCESS -> Failure Info
*
*/
BME68X_INTF_RET_TYPE bme68x_i2c_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, void *intf_ptr);
/*!
* @brief Function for writing the sensor's registers through I2C bus.
*
* @param[in] reg_addr : Register address.
* @param[in] reg_data : Pointer to the data buffer whose value is to be written.
* @param[in] len : No of bytes to write.
* @param[in] intf_ptr : Interface pointer
*
* @return Status of execution
* @retval = BME68X_INTF_RET_SUCCESS -> Success
* @retval != BME68X_INTF_RET_SUCCESS -> Failure Info
*
*/
BME68X_INTF_RET_TYPE bme68x_i2c_write(uint8_t reg_addr, const uint8_t *reg_data, uint32_t len, void *intf_ptr);
/*!
* @brief Function for reading the sensor's registers through SPI bus.
*
* @param[in] reg_addr : Register address.
* @param[out] reg_data : Pointer to the data buffer to store the read data.
* @param[in] len : No of bytes to read.
* @param[in] intf_ptr : Interface pointer
*
* @return Status of execution
* @retval = BME68X_INTF_RET_SUCCESS -> Success
* @retval != BME68X_INTF_RET_SUCCESS -> Failure Info
*
*/
BME68X_INTF_RET_TYPE bme68x_spi_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, void *intf_ptr);
/*!
* @brief Function for writing the sensor's registers through SPI bus.
*
* @param[in] reg_addr : Register address.
* @param[in] reg_data : Pointer to the data buffer whose data has to be written.
* @param[in] len : No of bytes to write.
* @param[in] intf_ptr : Interface pointer
*
* @return Status of execution
* @retval = BME68X_INTF_RET_SUCCESS -> Success
* @retval != BME68X_INTF_RET_SUCCESS -> Failure Info
*
*/
BME68X_INTF_RET_TYPE bme68x_spi_write(uint8_t reg_addr, const uint8_t *reg_data, uint32_t len, void *intf_ptr);
/*!
* @brief This function provides the delay for required time (Microsecond) as per the input provided in some of the
* APIs.
*
* @param[in] period : The required wait time in microsecond.
* @param[in] intf_ptr : Interface pointer
*
* @return void.
*
*/
void bme68x_delay_us(uint32_t period, void *intf_ptr);
/*!
* @brief Prints the execution status of the APIs.
*
* @param[in] api_name : Name of the API whose execution status has to be printed.
* @param[in] rslt : Error code returned by the API whose execution status has to be printed.
*
* @return void.
*/
void bme68x_check_rslt(const char api_name[], int8_t rslt);
#ifdef __cplusplus
}
#endif /*__cplusplus */