53#include <linux/types.h>
54#include <linux/kernel.h>
63#if !defined(UINT8_C) && !defined(INT8_C)
64#define INT8_C(x) S8_C(x)
65#define UINT8_C(x) U8_C(x)
68#if !defined(UINT16_C) && !defined(INT16_C)
69#define INT16_C(x) S16_C(x)
70#define UINT16_C(x) U16_C(x)
73#if !defined(INT32_C) && !defined(UINT32_C)
74#define INT32_C(x) S32_C(x)
75#define UINT32_C(x) U32_C(x)
78#if !defined(INT64_C) && !defined(UINT64_C)
79#define INT64_C(x) S64_C(x)
80#define UINT64_C(x) U64_C(x)
89#define NULL ((void *) 0)
94#define TRUE UINT8_C(1)
98#define FALSE UINT8_C(0)
104#ifndef BMP3_64BIT_COMPENSATION
105#ifndef BMP3_FLOAT_COMPENSATION
107#define BMP3_FLOAT_COMPENSATION
117#ifndef BMP3_INTF_RET_TYPE
118#define BMP3_INTF_RET_TYPE int8_t
124#ifndef BMP3_INTF_RET_SUCCESS
125#define BMP3_INTF_RET_SUCCESS INT8_C(0)
129#define BMP3_ADDR_I2C_PRIM UINT8_C(0x76)
130#define BMP3_ADDR_I2C_SEC UINT8_C(0x77)
133#define BMP3_CHIP_ID UINT8_C(0x50)
134#define BMP390_CHIP_ID UINT8_C(0x60)
137#define BMP3_SETTLE_TIME_PRESS UINT16_C(392)
140#define BMP3_SETTLE_TIME_TEMP UINT16_C(313)
143#define BMP3_ADC_CONV_TIME UINT16_C(2000)
146#define BMP3_REG_CHIP_ID UINT8_C(0x00)
147#define BMP3_REG_ERR UINT8_C(0x02)
148#define BMP3_REG_SENS_STATUS UINT8_C(0x03)
149#define BMP3_REG_DATA UINT8_C(0x04)
150#define BMP3_REG_EVENT UINT8_C(0x10)
151#define BMP3_REG_INT_STATUS UINT8_C(0x11)
152#define BMP3_REG_FIFO_LENGTH UINT8_C(0x12)
153#define BMP3_REG_FIFO_DATA UINT8_C(0x14)
154#define BMP3_REG_FIFO_WM UINT8_C(0x15)
155#define BMP3_REG_FIFO_CONFIG_1 UINT8_C(0x17)
156#define BMP3_REG_FIFO_CONFIG_2 UINT8_C(0x18)
157#define BMP3_REG_INT_CTRL UINT8_C(0x19)
158#define BMP3_REG_IF_CONF UINT8_C(0x1A)
159#define BMP3_REG_PWR_CTRL UINT8_C(0x1B)
160#define BMP3_REG_OSR UINT8_C(0X1C)
161#define BMP3_REG_ODR UINT8_C(0x1D)
162#define BMP3_REG_CONFIG UINT8_C(0x1F)
163#define BMP3_REG_CALIB_DATA UINT8_C(0x31)
164#define BMP3_REG_CMD UINT8_C(0x7E)
167#define BMP3_ERR_FATAL UINT8_C(0x01)
168#define BMP3_ERR_CMD UINT8_C(0x02)
169#define BMP3_ERR_CONF UINT8_C(0x04)
172#define BMP3_CMD_RDY UINT8_C(0x10)
173#define BMP3_DRDY_PRESS UINT8_C(0x20)
174#define BMP3_DRDY_TEMP UINT8_C(0x40)
177#define BMP3_MODE_SLEEP UINT8_C(0x00)
178#define BMP3_MODE_FORCED UINT8_C(0x01)
179#define BMP3_MODE_NORMAL UINT8_C(0x03)
183#define BMP3_ENABLE UINT8_C(0x01)
184#define BMP3_DISABLE UINT8_C(0x00)
188#define BMP3_INT_PIN_OPEN_DRAIN UINT8_C(0x01)
189#define BMP3_INT_PIN_PUSH_PULL UINT8_C(0x00)
192#define BMP3_INT_PIN_ACTIVE_HIGH UINT8_C(0x01)
193#define BMP3_INT_PIN_ACTIVE_LOW UINT8_C(0x00)
196#define BMP3_INT_PIN_LATCH UINT8_C(0x01)
197#define BMP3_INT_PIN_NON_LATCH UINT8_C(0x00)
201#define BMP3_I2C_WDT_SHORT_1_25_MS UINT8_C(0x00)
202#define BMP3_I2C_WDT_LONG_40_MS UINT8_C(0x01)
205#define BMP3_FIFO_NO_SUBSAMPLING UINT8_C(0x00)
206#define BMP3_FIFO_SUBSAMPLING_2X UINT8_C(0x01)
207#define BMP3_FIFO_SUBSAMPLING_4X UINT8_C(0x02)
208#define BMP3_FIFO_SUBSAMPLING_8X UINT8_C(0x03)
209#define BMP3_FIFO_SUBSAMPLING_16X UINT8_C(0x04)
210#define BMP3_FIFO_SUBSAMPLING_32X UINT8_C(0x05)
211#define BMP3_FIFO_SUBSAMPLING_64X UINT8_C(0x06)
212#define BMP3_FIFO_SUBSAMPLING_128X UINT8_C(0x07)
215#define BMP3_NO_OVERSAMPLING UINT8_C(0x00)
216#define BMP3_OVERSAMPLING_2X UINT8_C(0x01)
217#define BMP3_OVERSAMPLING_4X UINT8_C(0x02)
218#define BMP3_OVERSAMPLING_8X UINT8_C(0x03)
219#define BMP3_OVERSAMPLING_16X UINT8_C(0x04)
220#define BMP3_OVERSAMPLING_32X UINT8_C(0x05)
223#define BMP3_IIR_FILTER_DISABLE UINT8_C(0x00)
224#define BMP3_IIR_FILTER_COEFF_1 UINT8_C(0x01)
225#define BMP3_IIR_FILTER_COEFF_3 UINT8_C(0x02)
226#define BMP3_IIR_FILTER_COEFF_7 UINT8_C(0x03)
227#define BMP3_IIR_FILTER_COEFF_15 UINT8_C(0x04)
228#define BMP3_IIR_FILTER_COEFF_31 UINT8_C(0x05)
229#define BMP3_IIR_FILTER_COEFF_63 UINT8_C(0x06)
230#define BMP3_IIR_FILTER_COEFF_127 UINT8_C(0x07)
233#define BMP3_ODR_200_HZ UINT8_C(0x00)
234#define BMP3_ODR_100_HZ UINT8_C(0x01)
235#define BMP3_ODR_50_HZ UINT8_C(0x02)
236#define BMP3_ODR_25_HZ UINT8_C(0x03)
237#define BMP3_ODR_12_5_HZ UINT8_C(0x04)
238#define BMP3_ODR_6_25_HZ UINT8_C(0x05)
239#define BMP3_ODR_3_1_HZ UINT8_C(0x06)
240#define BMP3_ODR_1_5_HZ UINT8_C(0x07)
241#define BMP3_ODR_0_78_HZ UINT8_C(0x08)
242#define BMP3_ODR_0_39_HZ UINT8_C(0x09)
243#define BMP3_ODR_0_2_HZ UINT8_C(0x0A)
244#define BMP3_ODR_0_1_HZ UINT8_C(0x0B)
245#define BMP3_ODR_0_05_HZ UINT8_C(0x0C)
246#define BMP3_ODR_0_02_HZ UINT8_C(0x0D)
247#define BMP3_ODR_0_01_HZ UINT8_C(0x0E)
248#define BMP3_ODR_0_006_HZ UINT8_C(0x0F)
249#define BMP3_ODR_0_003_HZ UINT8_C(0x10)
250#define BMP3_ODR_0_001_HZ UINT8_C(0x11)
253#define BMP3_SOFT_RESET UINT8_C(0xB6)
256#define BMP3_FIFO_FLUSH UINT8_C(0xB0)
259#define BMP3_OK INT8_C(0)
262#define BMP3_E_NULL_PTR INT8_C(-1)
263#define BMP3_E_COMM_FAIL INT8_C(-2)
264#define BMP3_E_INVALID_ODR_OSR_SETTINGS INT8_C(-3)
265#define BMP3_E_CMD_EXEC_FAILED INT8_C(-4)
266#define BMP3_E_CONFIGURATION_ERR INT8_C(-5)
267#define BMP3_E_INVALID_LEN INT8_C(-6)
268#define BMP3_E_DEV_NOT_FOUND INT8_C(-7)
269#define BMP3_E_FIFO_WATERMARK_NOT_REACHED INT8_C(-8)
272#define BMP3_W_SENSOR_NOT_ENABLED INT8_C(1)
273#define BMP3_W_INVALID_FIFO_REQ_FRAME_CNT INT8_C(2)
274#define BMP3_W_MIN_TEMP INT8_C(3)
275#define BMP3_W_MAX_TEMP INT8_C(4)
276#define BMP3_W_MIN_PRES INT8_C(5)
277#define BMP3_W_MAX_PRES INT8_C(6)
282#define BMP3_SEL_PRESS_EN UINT16_C(1 << 1)
283#define BMP3_SEL_TEMP_EN UINT16_C(1 << 2)
284#define BMP3_SEL_DRDY_EN UINT16_C(1 << 3)
285#define BMP3_SEL_PRESS_OS UINT16_C(1 << 4)
286#define BMP3_SEL_TEMP_OS UINT16_C(1 << 5)
287#define BMP3_SEL_IIR_FILTER UINT16_C(1 << 6)
288#define BMP3_SEL_ODR UINT16_C(1 << 7)
289#define BMP3_SEL_OUTPUT_MODE UINT16_C(1 << 8)
290#define BMP3_SEL_LEVEL UINT16_C(1 << 9)
291#define BMP3_SEL_LATCH UINT16_C(1 << 10)
292#define BMP3_SEL_I2C_WDT_EN UINT16_C(1 << 11)
293#define BMP3_SEL_I2C_WDT UINT16_C(1 << 12)
294#define BMP3_SEL_ALL UINT16_C(0x7FF)
299#define BMP3_SEL_FIFO_MODE UINT16_C(1 << 1)
300#define BMP3_SEL_FIFO_STOP_ON_FULL_EN UINT16_C(1 << 2)
301#define BMP3_SEL_FIFO_TIME_EN UINT16_C(1 << 3)
302#define BMP3_SEL_FIFO_PRESS_EN UINT16_C(1 << 4)
303#define BMP3_SEL_FIFO_TEMP_EN UINT16_C(1 << 5)
304#define BMP3_SEL_FIFO_DOWN_SAMPLING UINT16_C(1 << 6)
305#define BMP3_SEL_FIFO_FILTER_EN UINT16_C(1 << 7)
306#define BMP3_SEL_FIFO_FWTM_EN UINT16_C(1 << 8)
307#define BMP3_SEL_FIFO_FULL_EN UINT16_C(1 << 9)
312#define BMP3_PRESS UINT8_C(1)
313#define BMP3_TEMP UINT8_C(2)
314#define BMP3_PRESS_TEMP UINT8_C(3)
317#define BMP3_MIN_TEMP_INT INT64_C(-4000)
318#define BMP3_MAX_TEMP_INT INT64_C(8500)
319#define BMP3_MIN_TEMP_DOUBLE -40.0f
320#define BMP3_MAX_TEMP_DOUBLE 85.0f
323#define BMP3_MIN_PRES_INT UINT64_C(3000000)
324#define BMP3_MAX_PRES_INT UINT64_C(12500000)
325#define BMP3_MIN_PRES_DOUBLE 30000.0f
326#define BMP3_MAX_PRES_DOUBLE 125000.0f
329#define BMP3_ERR_FATAL_MSK UINT8_C(0x01)
331#define BMP3_ERR_CMD_MSK UINT8_C(0x02)
332#define BMP3_ERR_CMD_POS UINT8_C(0x01)
334#define BMP3_ERR_CONF_MSK UINT8_C(0x04)
335#define BMP3_ERR_CONF_POS UINT8_C(0x02)
337#define BMP3_STATUS_CMD_RDY_MSK UINT8_C(0x10)
338#define BMP3_STATUS_CMD_RDY_POS UINT8_C(0x04)
340#define BMP3_STATUS_DRDY_PRESS_MSK UINT8_C(0x20)
341#define BMP3_STATUS_DRDY_PRESS_POS UINT8_C(0x05)
343#define BMP3_STATUS_DRDY_TEMP_MSK UINT8_C(0x40)
344#define BMP3_STATUS_DRDY_TEMP_POS UINT8_C(0x06)
346#define BMP3_OP_MODE_MSK UINT8_C(0x30)
347#define BMP3_OP_MODE_POS UINT8_C(0x04)
349#define BMP3_PRESS_EN_MSK UINT8_C(0x01)
351#define BMP3_TEMP_EN_MSK UINT8_C(0x02)
352#define BMP3_TEMP_EN_POS UINT8_C(0x01)
354#define BMP3_IIR_FILTER_MSK UINT8_C(0x0E)
355#define BMP3_IIR_FILTER_POS UINT8_C(0x01)
357#define BMP3_ODR_MSK UINT8_C(0x1F)
359#define BMP3_PRESS_OS_MSK UINT8_C(0x07)
361#define BMP3_TEMP_OS_MSK UINT8_C(0x38)
362#define BMP3_TEMP_OS_POS UINT8_C(0x03)
364#define BMP3_FIFO_MODE_MSK UINT8_C(0x01)
366#define BMP3_FIFO_STOP_ON_FULL_MSK UINT8_C(0x02)
367#define BMP3_FIFO_STOP_ON_FULL_POS UINT8_C(0x01)
369#define BMP3_FIFO_TIME_EN_MSK UINT8_C(0x04)
370#define BMP3_FIFO_TIME_EN_POS UINT8_C(0x02)
372#define BMP3_FIFO_PRESS_EN_MSK UINT8_C(0x08)
373#define BMP3_FIFO_PRESS_EN_POS UINT8_C(0x03)
375#define BMP3_FIFO_TEMP_EN_MSK UINT8_C(0x10)
376#define BMP3_FIFO_TEMP_EN_POS UINT8_C(0x04)
378#define BMP3_FIFO_FILTER_EN_MSK UINT8_C(0x18)
379#define BMP3_FIFO_FILTER_EN_POS UINT8_C(0x03)
381#define BMP3_FIFO_DOWN_SAMPLING_MSK UINT8_C(0x07)
383#define BMP3_FIFO_FWTM_EN_MSK UINT8_C(0x08)
384#define BMP3_FIFO_FWTM_EN_POS UINT8_C(0x03)
386#define BMP3_FIFO_FULL_EN_MSK UINT8_C(0x10)
387#define BMP3_FIFO_FULL_EN_POS UINT8_C(0x04)
389#define BMP3_INT_OUTPUT_MODE_MSK UINT8_C(0x01)
391#define BMP3_INT_LEVEL_MSK UINT8_C(0x02)
392#define BMP3_INT_LEVEL_POS UINT8_C(0x01)
394#define BMP3_INT_LATCH_MSK UINT8_C(0x04)
395#define BMP3_INT_LATCH_POS UINT8_C(0x02)
397#define BMP3_INT_DRDY_EN_MSK UINT8_C(0x40)
398#define BMP3_INT_DRDY_EN_POS UINT8_C(0x06)
400#define BMP3_I2C_WDT_EN_MSK UINT8_C(0x02)
401#define BMP3_I2C_WDT_EN_POS UINT8_C(0x01)
403#define BMP3_I2C_WDT_SEL_MSK UINT8_C(0x04)
404#define BMP3_I2C_WDT_SEL_POS UINT8_C(0x02)
406#define BMP3_INT_STATUS_FWTM_MSK UINT8_C(0x01)
408#define BMP3_INT_STATUS_FFULL_MSK UINT8_C(0x02)
409#define BMP3_INT_STATUS_FFULL_POS UINT8_C(0x01)
411#define BMP3_INT_STATUS_DRDY_MSK UINT8_C(0x08)
412#define BMP3_INT_STATUS_DRDY_POS UINT8_C(0x03)
415#define BMP3_SET_LOW_BYTE UINT16_C(0x00FF)
416#define BMP3_SET_HIGH_BYTE UINT16_C(0xFF00)
419#define BMP3_CONCAT_BYTES(msb, lsb) (((uint16_t)msb << 8) | (uint16_t)lsb)
421#define BMP3_SET_BITS(reg_data, bitname, data) \
422 ((reg_data & ~(bitname##_MSK)) | \
423 ((data << bitname##_POS) & bitname##_MSK))
426#define BMP3_SET_BITS_POS_0(reg_data, bitname, data) \
427 ((reg_data & ~(bitname##_MSK)) | \
428 (data & bitname##_MSK))
430#define BMP3_GET_BITS(reg_data, bitname) ((reg_data & (bitname##_MSK)) >> \
434#define BMP3_GET_BITS_POS_0(reg_data, bitname) (reg_data & (bitname##_MSK))
436#define BMP3_GET_LSB(var) (uint8_t)(var & BMP3_SET_LOW_BYTE)
437#define BMP3_GET_MSB(var) (uint8_t)((var & BMP3_SET_HIGH_BYTE) >> 8)
440#define BMP3_LEN_CALIB_DATA UINT8_C(21)
441#define BMP3_LEN_P_AND_T_HEADER_DATA UINT8_C(7)
442#define BMP3_LEN_P_OR_T_HEADER_DATA UINT8_C(4)
443#define BMP3_LEN_P_T_DATA UINT8_C(6)
444#define BMP3_LEN_GEN_SETT UINT8_C(7)
445#define BMP3_LEN_P_DATA UINT8_C(3)
446#define BMP3_LEN_T_DATA UINT8_C(3)
447#define BMP3_LEN_SENSOR_TIME UINT8_C(3)
448#define BMP3_FIFO_MAX_FRAMES UINT8_C(73)
451#define BMP3_POWER_CNTL UINT16_C(0x0006)
454#define BMP3_ODR_FILTER UINT16_C(0x00F0)
457#define BMP3_INT_CTRL UINT16_C(0x0708)
460#define BMP3_ADV_SETT UINT16_C(0x1800)
466#define BMP3_FIFO_CONFIG_1 UINT16_C(0x003E)
469#define BMP3_FIFO_CONFIG_2 UINT16_C(0x00C0)
472#define BMP3_FIFO_INT_CTRL UINT16_C(0x0300)
476#define BMP3_FIFO_TEMP_PRESS_FRAME UINT8_C(0x94)
479#define BMP3_FIFO_TEMP_FRAME UINT8_C(0x90)
482#define BMP3_FIFO_PRESS_FRAME UINT8_C(0x84)
485#define BMP3_FIFO_TIME_FRAME UINT8_C(0xA0)
488#define BMP3_FIFO_ERROR_FRAME UINT8_C(0x44)
491#define BMP3_FIFO_CONFIG_CHANGE UINT8_C(0x48)
494#define BMP3_FIFO_EMPTY_FRAME UINT8_C(0x80)
497#define BMP3_SENSORTIME_OVERHEAD_BYTES UINT8_C(20)
786#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.
: Header for main.c file. This file contains the common defines of the application.
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.