53#include <linux/types.h>
54#include <linux/kernel.h>
62#if !defined(UINT8_C) && !defined(INT8_C)
63#define INT8_C(x) S8_C(x)
64#define UINT8_C(x) U8_C(x)
67#if !defined(UINT16_C) && !defined(INT16_C)
68#define INT16_C(x) S16_C(x)
69#define UINT16_C(x) U16_C(x)
72#if !defined(INT32_C) && !defined(UINT32_C)
73#define INT32_C(x) S32_C(x)
74#define UINT32_C(x) U32_C(x)
77#if !defined(INT64_C) && !defined(UINT64_C)
78#define INT64_C(x) S64_C(x)
79#define UINT64_C(x) U64_C(x)
88#define NULL ((void *) 0)
93#define TRUE UINT8_C(1)
97#define FALSE UINT8_C(0)
103#ifndef BMP3_64BIT_COMPENSATION
104#ifndef BMP3_FLOAT_COMPENSATION
106#define BMP3_FLOAT_COMPENSATION
116#ifndef BMP3_INTF_RET_TYPE
117#define BMP3_INTF_RET_TYPE int8_t
123#ifndef BMP3_INTF_RET_SUCCESS
124#define BMP3_INTF_RET_SUCCESS INT8_C(0)
128#define BMP3_ADDR_I2C_PRIM UINT8_C(0x76)
129#define BMP3_ADDR_I2C_SEC UINT8_C(0x77)
132#define BMP3_CHIP_ID UINT8_C(0x50)
133#define BMP390_CHIP_ID UINT8_C(0x60)
136#define BMP3_SETTLE_TIME_PRESS UINT16_C(392)
139#define BMP3_SETTLE_TIME_TEMP UINT16_C(313)
142#define BMP3_ADC_CONV_TIME UINT16_C(2000)
145#define BMP3_REG_CHIP_ID UINT8_C(0x00)
146#define BMP3_REG_ERR UINT8_C(0x02)
147#define BMP3_REG_SENS_STATUS UINT8_C(0x03)
148#define BMP3_REG_DATA UINT8_C(0x04)
149#define BMP3_REG_EVENT UINT8_C(0x10)
150#define BMP3_REG_INT_STATUS UINT8_C(0x11)
151#define BMP3_REG_FIFO_LENGTH UINT8_C(0x12)
152#define BMP3_REG_FIFO_DATA UINT8_C(0x14)
153#define BMP3_REG_FIFO_WM UINT8_C(0x15)
154#define BMP3_REG_FIFO_CONFIG_1 UINT8_C(0x17)
155#define BMP3_REG_FIFO_CONFIG_2 UINT8_C(0x18)
156#define BMP3_REG_INT_CTRL UINT8_C(0x19)
157#define BMP3_REG_IF_CONF UINT8_C(0x1A)
158#define BMP3_REG_PWR_CTRL UINT8_C(0x1B)
159#define BMP3_REG_OSR UINT8_C(0X1C)
160#define BMP3_REG_ODR UINT8_C(0x1D)
161#define BMP3_REG_CONFIG UINT8_C(0x1F)
162#define BMP3_REG_CALIB_DATA UINT8_C(0x31)
163#define BMP3_REG_CMD UINT8_C(0x7E)
166#define BMP3_ERR_FATAL UINT8_C(0x01)
167#define BMP3_ERR_CMD UINT8_C(0x02)
168#define BMP3_ERR_CONF UINT8_C(0x04)
171#define BMP3_CMD_RDY UINT8_C(0x10)
172#define BMP3_DRDY_PRESS UINT8_C(0x20)
173#define BMP3_DRDY_TEMP UINT8_C(0x40)
176#define BMP3_MODE_SLEEP UINT8_C(0x00)
177#define BMP3_MODE_FORCED UINT8_C(0x01)
178#define BMP3_MODE_NORMAL UINT8_C(0x03)
182#define BMP3_ENABLE UINT8_C(0x01)
183#define BMP3_DISABLE UINT8_C(0x00)
187#define BMP3_INT_PIN_OPEN_DRAIN UINT8_C(0x01)
188#define BMP3_INT_PIN_PUSH_PULL UINT8_C(0x00)
191#define BMP3_INT_PIN_ACTIVE_HIGH UINT8_C(0x01)
192#define BMP3_INT_PIN_ACTIVE_LOW UINT8_C(0x00)
195#define BMP3_INT_PIN_LATCH UINT8_C(0x01)
196#define BMP3_INT_PIN_NON_LATCH UINT8_C(0x00)
200#define BMP3_I2C_WDT_SHORT_1_25_MS UINT8_C(0x00)
201#define BMP3_I2C_WDT_LONG_40_MS UINT8_C(0x01)
204#define BMP3_FIFO_NO_SUBSAMPLING UINT8_C(0x00)
205#define BMP3_FIFO_SUBSAMPLING_2X UINT8_C(0x01)
206#define BMP3_FIFO_SUBSAMPLING_4X UINT8_C(0x02)
207#define BMP3_FIFO_SUBSAMPLING_8X UINT8_C(0x03)
208#define BMP3_FIFO_SUBSAMPLING_16X UINT8_C(0x04)
209#define BMP3_FIFO_SUBSAMPLING_32X UINT8_C(0x05)
210#define BMP3_FIFO_SUBSAMPLING_64X UINT8_C(0x06)
211#define BMP3_FIFO_SUBSAMPLING_128X UINT8_C(0x07)
214#define BMP3_NO_OVERSAMPLING UINT8_C(0x00)
215#define BMP3_OVERSAMPLING_2X UINT8_C(0x01)
216#define BMP3_OVERSAMPLING_4X UINT8_C(0x02)
217#define BMP3_OVERSAMPLING_8X UINT8_C(0x03)
218#define BMP3_OVERSAMPLING_16X UINT8_C(0x04)
219#define BMP3_OVERSAMPLING_32X UINT8_C(0x05)
222#define BMP3_IIR_FILTER_DISABLE UINT8_C(0x00)
223#define BMP3_IIR_FILTER_COEFF_1 UINT8_C(0x01)
224#define BMP3_IIR_FILTER_COEFF_3 UINT8_C(0x02)
225#define BMP3_IIR_FILTER_COEFF_7 UINT8_C(0x03)
226#define BMP3_IIR_FILTER_COEFF_15 UINT8_C(0x04)
227#define BMP3_IIR_FILTER_COEFF_31 UINT8_C(0x05)
228#define BMP3_IIR_FILTER_COEFF_63 UINT8_C(0x06)
229#define BMP3_IIR_FILTER_COEFF_127 UINT8_C(0x07)
232#define BMP3_ODR_200_HZ UINT8_C(0x00)
233#define BMP3_ODR_100_HZ UINT8_C(0x01)
234#define BMP3_ODR_50_HZ UINT8_C(0x02)
235#define BMP3_ODR_25_HZ UINT8_C(0x03)
236#define BMP3_ODR_12_5_HZ UINT8_C(0x04)
237#define BMP3_ODR_6_25_HZ UINT8_C(0x05)
238#define BMP3_ODR_3_1_HZ UINT8_C(0x06)
239#define BMP3_ODR_1_5_HZ UINT8_C(0x07)
240#define BMP3_ODR_0_78_HZ UINT8_C(0x08)
241#define BMP3_ODR_0_39_HZ UINT8_C(0x09)
242#define BMP3_ODR_0_2_HZ UINT8_C(0x0A)
243#define BMP3_ODR_0_1_HZ UINT8_C(0x0B)
244#define BMP3_ODR_0_05_HZ UINT8_C(0x0C)
245#define BMP3_ODR_0_02_HZ UINT8_C(0x0D)
246#define BMP3_ODR_0_01_HZ UINT8_C(0x0E)
247#define BMP3_ODR_0_006_HZ UINT8_C(0x0F)
248#define BMP3_ODR_0_003_HZ UINT8_C(0x10)
249#define BMP3_ODR_0_001_HZ UINT8_C(0x11)
252#define BMP3_SOFT_RESET UINT8_C(0xB6)
255#define BMP3_FIFO_FLUSH UINT8_C(0xB0)
258#define BMP3_OK INT8_C(0)
261#define BMP3_E_NULL_PTR INT8_C(-1)
262#define BMP3_E_COMM_FAIL INT8_C(-2)
263#define BMP3_E_INVALID_ODR_OSR_SETTINGS INT8_C(-3)
264#define BMP3_E_CMD_EXEC_FAILED INT8_C(-4)
265#define BMP3_E_CONFIGURATION_ERR INT8_C(-5)
266#define BMP3_E_INVALID_LEN INT8_C(-6)
267#define BMP3_E_DEV_NOT_FOUND INT8_C(-7)
268#define BMP3_E_FIFO_WATERMARK_NOT_REACHED INT8_C(-8)
271#define BMP3_W_SENSOR_NOT_ENABLED INT8_C(1)
272#define BMP3_W_INVALID_FIFO_REQ_FRAME_CNT INT8_C(2)
273#define BMP3_W_MIN_TEMP INT8_C(3)
274#define BMP3_W_MAX_TEMP INT8_C(4)
275#define BMP3_W_MIN_PRES INT8_C(5)
276#define BMP3_W_MAX_PRES INT8_C(6)
281#define BMP3_SEL_PRESS_EN UINT16_C(1 << 1)
282#define BMP3_SEL_TEMP_EN UINT16_C(1 << 2)
283#define BMP3_SEL_DRDY_EN UINT16_C(1 << 3)
284#define BMP3_SEL_PRESS_OS UINT16_C(1 << 4)
285#define BMP3_SEL_TEMP_OS UINT16_C(1 << 5)
286#define BMP3_SEL_IIR_FILTER UINT16_C(1 << 6)
287#define BMP3_SEL_ODR UINT16_C(1 << 7)
288#define BMP3_SEL_OUTPUT_MODE UINT16_C(1 << 8)
289#define BMP3_SEL_LEVEL UINT16_C(1 << 9)
290#define BMP3_SEL_LATCH UINT16_C(1 << 10)
291#define BMP3_SEL_I2C_WDT_EN UINT16_C(1 << 11)
292#define BMP3_SEL_I2C_WDT UINT16_C(1 << 12)
293#define BMP3_SEL_ALL UINT16_C(0x7FF)
298#define BMP3_SEL_FIFO_MODE UINT16_C(1 << 1)
299#define BMP3_SEL_FIFO_STOP_ON_FULL_EN UINT16_C(1 << 2)
300#define BMP3_SEL_FIFO_TIME_EN UINT16_C(1 << 3)
301#define BMP3_SEL_FIFO_PRESS_EN UINT16_C(1 << 4)
302#define BMP3_SEL_FIFO_TEMP_EN UINT16_C(1 << 5)
303#define BMP3_SEL_FIFO_DOWN_SAMPLING UINT16_C(1 << 6)
304#define BMP3_SEL_FIFO_FILTER_EN UINT16_C(1 << 7)
305#define BMP3_SEL_FIFO_FWTM_EN UINT16_C(1 << 8)
306#define BMP3_SEL_FIFO_FULL_EN UINT16_C(1 << 9)
311#define BMP3_PRESS UINT8_C(1)
312#define BMP3_TEMP UINT8_C(2)
313#define BMP3_PRESS_TEMP UINT8_C(3)
316#define BMP3_MIN_TEMP_INT INT64_C(-4000)
317#define BMP3_MAX_TEMP_INT INT64_C(8500)
318#define BMP3_MIN_TEMP_DOUBLE -40.0f
319#define BMP3_MAX_TEMP_DOUBLE 85.0f
322#define BMP3_MIN_PRES_INT UINT64_C(3000000)
323#define BMP3_MAX_PRES_INT UINT64_C(12500000)
324#define BMP3_MIN_PRES_DOUBLE 30000.0f
325#define BMP3_MAX_PRES_DOUBLE 125000.0f
328#define BMP3_ERR_FATAL_MSK UINT8_C(0x01)
330#define BMP3_ERR_CMD_MSK UINT8_C(0x02)
331#define BMP3_ERR_CMD_POS UINT8_C(0x01)
333#define BMP3_ERR_CONF_MSK UINT8_C(0x04)
334#define BMP3_ERR_CONF_POS UINT8_C(0x02)
336#define BMP3_STATUS_CMD_RDY_MSK UINT8_C(0x10)
337#define BMP3_STATUS_CMD_RDY_POS UINT8_C(0x04)
339#define BMP3_STATUS_DRDY_PRESS_MSK UINT8_C(0x20)
340#define BMP3_STATUS_DRDY_PRESS_POS UINT8_C(0x05)
342#define BMP3_STATUS_DRDY_TEMP_MSK UINT8_C(0x40)
343#define BMP3_STATUS_DRDY_TEMP_POS UINT8_C(0x06)
345#define BMP3_OP_MODE_MSK UINT8_C(0x30)
346#define BMP3_OP_MODE_POS UINT8_C(0x04)
348#define BMP3_PRESS_EN_MSK UINT8_C(0x01)
350#define BMP3_TEMP_EN_MSK UINT8_C(0x02)
351#define BMP3_TEMP_EN_POS UINT8_C(0x01)
353#define BMP3_IIR_FILTER_MSK UINT8_C(0x0E)
354#define BMP3_IIR_FILTER_POS UINT8_C(0x01)
356#define BMP3_ODR_MSK UINT8_C(0x1F)
358#define BMP3_PRESS_OS_MSK UINT8_C(0x07)
360#define BMP3_TEMP_OS_MSK UINT8_C(0x38)
361#define BMP3_TEMP_OS_POS UINT8_C(0x03)
363#define BMP3_FIFO_MODE_MSK UINT8_C(0x01)
365#define BMP3_FIFO_STOP_ON_FULL_MSK UINT8_C(0x02)
366#define BMP3_FIFO_STOP_ON_FULL_POS UINT8_C(0x01)
368#define BMP3_FIFO_TIME_EN_MSK UINT8_C(0x04)
369#define BMP3_FIFO_TIME_EN_POS UINT8_C(0x02)
371#define BMP3_FIFO_PRESS_EN_MSK UINT8_C(0x08)
372#define BMP3_FIFO_PRESS_EN_POS UINT8_C(0x03)
374#define BMP3_FIFO_TEMP_EN_MSK UINT8_C(0x10)
375#define BMP3_FIFO_TEMP_EN_POS UINT8_C(0x04)
377#define BMP3_FIFO_FILTER_EN_MSK UINT8_C(0x18)
378#define BMP3_FIFO_FILTER_EN_POS UINT8_C(0x03)
380#define BMP3_FIFO_DOWN_SAMPLING_MSK UINT8_C(0x07)
382#define BMP3_FIFO_FWTM_EN_MSK UINT8_C(0x08)
383#define BMP3_FIFO_FWTM_EN_POS UINT8_C(0x03)
385#define BMP3_FIFO_FULL_EN_MSK UINT8_C(0x10)
386#define BMP3_FIFO_FULL_EN_POS UINT8_C(0x04)
388#define BMP3_INT_OUTPUT_MODE_MSK UINT8_C(0x01)
390#define BMP3_INT_LEVEL_MSK UINT8_C(0x02)
391#define BMP3_INT_LEVEL_POS UINT8_C(0x01)
393#define BMP3_INT_LATCH_MSK UINT8_C(0x04)
394#define BMP3_INT_LATCH_POS UINT8_C(0x02)
396#define BMP3_INT_DRDY_EN_MSK UINT8_C(0x40)
397#define BMP3_INT_DRDY_EN_POS UINT8_C(0x06)
399#define BMP3_I2C_WDT_EN_MSK UINT8_C(0x02)
400#define BMP3_I2C_WDT_EN_POS UINT8_C(0x01)
402#define BMP3_I2C_WDT_SEL_MSK UINT8_C(0x04)
403#define BMP3_I2C_WDT_SEL_POS UINT8_C(0x02)
405#define BMP3_INT_STATUS_FWTM_MSK UINT8_C(0x01)
407#define BMP3_INT_STATUS_FFULL_MSK UINT8_C(0x02)
408#define BMP3_INT_STATUS_FFULL_POS UINT8_C(0x01)
410#define BMP3_INT_STATUS_DRDY_MSK UINT8_C(0x08)
411#define BMP3_INT_STATUS_DRDY_POS UINT8_C(0x03)
414#define BMP3_SET_LOW_BYTE UINT16_C(0x00FF)
415#define BMP3_SET_HIGH_BYTE UINT16_C(0xFF00)
418#define BMP3_CONCAT_BYTES(msb, lsb) (((uint16_t)msb << 8) | (uint16_t)lsb)
420#define BMP3_SET_BITS(reg_data, bitname, data) \
421 ((reg_data & ~(bitname##_MSK)) | \
422 ((data << bitname##_POS) & bitname##_MSK))
425#define BMP3_SET_BITS_POS_0(reg_data, bitname, data) \
426 ((reg_data & ~(bitname##_MSK)) | \
427 (data & bitname##_MSK))
429#define BMP3_GET_BITS(reg_data, bitname) ((reg_data & (bitname##_MSK)) >> \
433#define BMP3_GET_BITS_POS_0(reg_data, bitname) (reg_data & (bitname##_MSK))
435#define BMP3_GET_LSB(var) (uint8_t)(var & BMP3_SET_LOW_BYTE)
436#define BMP3_GET_MSB(var) (uint8_t)((var & BMP3_SET_HIGH_BYTE) >> 8)
439#define BMP3_LEN_CALIB_DATA UINT8_C(21)
440#define BMP3_LEN_P_AND_T_HEADER_DATA UINT8_C(7)
441#define BMP3_LEN_P_OR_T_HEADER_DATA UINT8_C(4)
442#define BMP3_LEN_P_T_DATA UINT8_C(6)
443#define BMP3_LEN_GEN_SETT UINT8_C(7)
444#define BMP3_LEN_P_DATA UINT8_C(3)
445#define BMP3_LEN_T_DATA UINT8_C(3)
446#define BMP3_LEN_SENSOR_TIME UINT8_C(3)
447#define BMP3_FIFO_MAX_FRAMES UINT8_C(73)
450#define BMP3_POWER_CNTL UINT16_C(0x0006)
453#define BMP3_ODR_FILTER UINT16_C(0x00F0)
456#define BMP3_INT_CTRL UINT16_C(0x0708)
459#define BMP3_ADV_SETT UINT16_C(0x1800)
465#define BMP3_FIFO_CONFIG_1 UINT16_C(0x003E)
468#define BMP3_FIFO_CONFIG_2 UINT16_C(0x00C0)
471#define BMP3_FIFO_INT_CTRL UINT16_C(0x0300)
475#define BMP3_FIFO_TEMP_PRESS_FRAME UINT8_C(0x94)
478#define BMP3_FIFO_TEMP_FRAME UINT8_C(0x90)
481#define BMP3_FIFO_PRESS_FRAME UINT8_C(0x84)
484#define BMP3_FIFO_TIME_FRAME UINT8_C(0xA0)
487#define BMP3_FIFO_ERROR_FRAME UINT8_C(0x44)
490#define BMP3_FIFO_CONFIG_CHANGE UINT8_C(0x48)
493#define BMP3_FIFO_EMPTY_FRAME UINT8_C(0x80)
496#define BMP3_SENSORTIME_OVERHEAD_BYTES UINT8_C(20)
796#ifdef BMP3_FLOAT_COMPENSATION
BMP3_INTF_RET_TYPE(* bmp3_write_fptr_t)(uint8_t reg_addr, const uint8_t *read_data, uint32_t len, void *intf_ptr)
Bus communication function pointer which should be mapped to the platform specific write functions of...
#define BMP3_INTF_RET_TYPE
bmp3_intf
Interface selection Enums.
void(* bmp3_delay_us_fptr_t)(uint32_t period, void *intf_ptr)
Delay function pointer which should be mapped to delay function of the user.
BMP3_INTF_RET_TYPE(* bmp3_read_fptr_t)(uint8_t reg_addr, uint8_t *read_data, uint32_t len, void *intf_ptr)
Type definitions.
struct bmp3_reg_calib_data reg_calib_data
struct bmp3_quantized_calib_data quantized_calib_data
bmp3 sensor structure which comprises of temperature and pressure data.
BMP3_INTF_RET_TYPE intf_rslt
struct bmp3_calib_data calib_data
bmp3_delay_us_fptr_t delay_us
uint8_t frame_not_available
bmp3 interrupt pin settings
bmp3 interrupt status flags
bmp3 odr and filter settings
Quantized Trim Variables.
struct bmp3_int_ctrl_settings int_settings
struct bmp3_adv_settings adv_settings
struct bmp3_odr_filter_settings odr_filter
struct bmp3_sens_status sensor
struct bmp3_err_status err
struct bmp3_int_status intr
bmp3 sensor structure which comprises of un-compensated temperature and pressure data.