LibDriver BMP390
Loading...
Searching...
No Matches
driver_bmp390.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_BMP390_H
38#define DRIVER_BMP390_H
39
40#include <stdint.h>
41#include <stdio.h>
42#include <string.h>
43
44#ifdef __cplusplus
45extern "C"{
46#endif
47
53
58
67
71typedef enum
72{
73 BMP390_ADDRESS_ADO_LOW = (0x76 << 1),
76
80typedef enum
81{
85
89typedef enum
90{
91 BMP390_ERROR_FATAL = (1 << 0),
92 BMP390_ERROR_CMD = (1 << 1),
93 BMP390_ERROR_CONF = (1 << 2),
95
105
117
126
136
145
154
158typedef enum
159{
163
172
182
195
220
235
245
255
259typedef struct bmp390_handle_s
260{
261 uint8_t iic_addr;
262 uint8_t buf[512 + 1];
263 uint8_t (*iic_init)(void);
264 uint8_t (*iic_deinit)(void);
265 uint8_t (*iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
266 uint8_t (*iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
267 uint8_t (*spi_init)(void);
268 uint8_t (*spi_deinit)(void);
269 uint8_t (*spi_read)(uint8_t reg, uint8_t *buf, uint16_t len);
270 uint8_t (*spi_write)(uint8_t reg, uint8_t *buf, uint16_t len);
271 void (*receive_callback)(uint8_t type);
272 void (*delay_ms)(uint32_t ms);
273 void (*debug_print)(const char *const fmt, ...);
274 uint8_t inited;
275 uint8_t iic_spi;
276 uint16_t t1;
277 uint16_t t2;
278 int8_t t3;
279 int16_t p1;
280 int16_t p2;
281 int8_t p3;
282 int8_t p4;
283 uint16_t p5;
284 uint16_t p6;
285 int8_t p7;
286 int8_t p8;
287 int16_t p9;
288 int8_t p10;
289 int8_t p11;
290 int64_t t_fine;
292
308
312
319
326#define DRIVER_BMP390_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
327
334#define DRIVER_BMP390_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
335
342#define DRIVER_BMP390_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
343
350#define DRIVER_BMP390_LINK_IIC_READ(HANDLE, FUC) (HANDLE)->iic_read = FUC
351
358#define DRIVER_BMP390_LINK_IIC_WRITE(HANDLE, FUC) (HANDLE)->iic_write = FUC
359
366#define DRIVER_BMP390_LINK_SPI_INIT(HANDLE, FUC) (HANDLE)->spi_init = FUC
367
374#define DRIVER_BMP390_LINK_SPI_DEINIT(HANDLE, FUC) (HANDLE)->spi_deinit = FUC
375
382#define DRIVER_BMP390_LINK_SPI_READ(HANDLE, FUC) (HANDLE)->spi_read = FUC
383
390#define DRIVER_BMP390_LINK_SPI_WRITE(HANDLE, FUC) (HANDLE)->spi_write = FUC
391
398#define DRIVER_BMP390_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
399
406#define DRIVER_BMP390_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
407
414#define DRIVER_BMP390_LINK_RECEIVE_CALLBACK(HANDLE, FUC) (HANDLE)->receive_callback = FUC
415
419
426
435uint8_t bmp390_info(bmp390_info_t *info);
436
446uint8_t bmp390_set_addr_pin(bmp390_handle_t *handle, bmp390_address_t addr_pin);
447
457uint8_t bmp390_get_addr_pin(bmp390_handle_t *handle, bmp390_address_t *addr_pin);
458
469
479uint8_t bmp390_get_interface(bmp390_handle_t *handle, bmp390_interface_t *interface);
480
491uint8_t bmp390_irq_handler(bmp390_handle_t *handle);
492
506uint8_t bmp390_init(bmp390_handle_t *handle);
507
519uint8_t bmp390_deinit(bmp390_handle_t *handle);
520
535uint8_t bmp390_read_temperature_pressure(bmp390_handle_t *handle, uint32_t *temperature_raw, float *temperature_c,
536 uint32_t *pressure_raw, float *pressure_pa);
537
550uint8_t bmp390_read_temperature(bmp390_handle_t *handle, uint32_t *raw, float *c);
551
564uint8_t bmp390_read_pressure(bmp390_handle_t *handle, uint32_t *raw, float *pa);
565
577uint8_t bmp390_get_revision_id(bmp390_handle_t *handle, uint8_t *id);
578
590uint8_t bmp390_get_error(bmp390_handle_t *handle, uint8_t *err);
591
603uint8_t bmp390_get_status(bmp390_handle_t *handle, uint8_t *status);
604
616uint8_t bmp390_get_sensortime(bmp390_handle_t *handle, uint32_t *t);
617
629uint8_t bmp390_get_event(bmp390_handle_t *handle, bmp390_event_t *event);
630
643
656
669
682
695
708
720uint8_t bmp390_set_pressure(bmp390_handle_t *handle, bmp390_bool_t enable);
721
733uint8_t bmp390_get_pressure(bmp390_handle_t *handle, bmp390_bool_t *enable);
734
747
760
772uint8_t bmp390_set_mode(bmp390_handle_t *handle, bmp390_mode_t mode);
773
785uint8_t bmp390_get_mode(bmp390_handle_t *handle, bmp390_mode_t *mode);
786
799
812
825
838
850uint8_t bmp390_set_odr(bmp390_handle_t *handle, bmp390_odr_t odr);
851
863uint8_t bmp390_get_odr(bmp390_handle_t *handle, bmp390_odr_t *odr);
864
877
890
901uint8_t bmp390_softreset(bmp390_handle_t *handle);
902
906
913
925uint8_t bmp390_get_interrupt_status(bmp390_handle_t *handle, uint8_t *status);
926
939
952
965
978
991
1004
1017
1030
1043
1056
1069
1082
1086
1093
1105uint8_t bmp390_get_fifo_length(bmp390_handle_t *handle, uint16_t *length);
1106
1119uint8_t bmp390_get_fifo_data(bmp390_handle_t *handle, uint8_t *data, uint16_t length);
1120
1132uint8_t bmp390_set_fifo_watermark(bmp390_handle_t *handle, uint16_t watermark);
1133
1145uint8_t bmp390_get_fifo_watermark(bmp390_handle_t *handle, uint16_t *watermark);
1146
1158uint8_t bmp390_set_fifo(bmp390_handle_t *handle, bmp390_bool_t enable);
1159
1171uint8_t bmp390_get_fifo(bmp390_handle_t *handle, bmp390_bool_t *enable);
1172
1185
1198
1211
1224
1237
1250
1263
1276
1288uint8_t bmp390_set_fifo_subsampling(bmp390_handle_t *handle, uint8_t subsample);
1289
1301uint8_t bmp390_get_fifo_subsampling(bmp390_handle_t *handle, uint8_t *subsample);
1302
1315
1328
1339uint8_t bmp390_flush_fifo(bmp390_handle_t *handle);
1340
1353uint8_t bmp390_read_fifo(bmp390_handle_t *handle, uint8_t *buf, uint16_t *len);
1354
1369uint8_t bmp390_fifo_parse(bmp390_handle_t *handle, uint8_t *buf, uint16_t buf_len, bmp390_frame_t *frame, uint16_t *frame_len);
1370
1374
1381
1394uint8_t bmp390_set_reg(bmp390_handle_t *handle, uint8_t reg, uint8_t value);
1395
1408uint8_t bmp390_get_reg(bmp390_handle_t *handle, uint8_t reg, uint8_t *value);
1409
1413
1417
1418#ifdef __cplusplus
1419}
1420#endif
1421
1422#endif
uint8_t bmp390_set_temperature_oversampling(bmp390_handle_t *handle, bmp390_oversampling_t oversampling)
set the temperature oversampling
bmp390_status_t
bmp390 status enumeration definition
uint8_t bmp390_get_pressure_oversampling(bmp390_handle_t *handle, bmp390_oversampling_t *oversampling)
get the pressure oversampling
bmp390_interrupt_status_t
bmp390 interrupt status enumeration definition
uint8_t bmp390_get_pressure(bmp390_handle_t *handle, bmp390_bool_t *enable)
get the pressure status
uint8_t bmp390_set_pressure(bmp390_handle_t *handle, bmp390_bool_t enable)
enable or disable the pressure
uint8_t bmp390_set_mode(bmp390_handle_t *handle, bmp390_mode_t mode)
set the chip mode
bmp390_interface_t
bmp390 interface enumeration definition
bmp390_event_t
bmp390 event enumeration definition
uint8_t bmp390_get_odr(bmp390_handle_t *handle, bmp390_odr_t *odr)
get the output data rate
uint8_t bmp390_set_temperature(bmp390_handle_t *handle, bmp390_bool_t enable)
enable or disable the temperature
uint8_t bmp390_get_temperature_oversampling(bmp390_handle_t *handle, bmp390_oversampling_t *oversampling)
get the temperature oversampling
uint8_t bmp390_read_temperature(bmp390_handle_t *handle, uint32_t *raw, float *c)
read the temperature
bmp390_error_t
bmp390 error enumeration definition
bmp390_interrupt_active_level_t
bmp390 interrupt active level enumeration definition
uint8_t bmp390_read_pressure(bmp390_handle_t *handle, uint32_t *raw, float *pa)
read the pressure
bmp390_fifo_data_source_t
bmp390 fifo data source enumeration definition
uint8_t bmp390_info(bmp390_info_t *info)
get chip's information
uint8_t bmp390_get_addr_pin(bmp390_handle_t *handle, bmp390_address_t *addr_pin)
get the iic address pin
bmp390_oversampling_t
bmp390 oversampling enumeration definition
uint8_t bmp390_get_status(bmp390_handle_t *handle, uint8_t *status)
get the status
uint8_t bmp390_get_spi_wire(bmp390_handle_t *handle, bmp390_spi_wire_t *wire)
get the spi wire
uint8_t bmp390_get_mode(bmp390_handle_t *handle, bmp390_mode_t *mode)
get the chip mode
uint8_t bmp390_get_error(bmp390_handle_t *handle, uint8_t *err)
get the error
bmp390_interrupt_pin_type_t
bmp390 interrupt pin type enumeration definition
uint8_t bmp390_set_addr_pin(bmp390_handle_t *handle, bmp390_address_t addr_pin)
set the iic address pin
bmp390_frame_type_t
bmp390 frame type enumeration definition
uint8_t bmp390_get_revision_id(bmp390_handle_t *handle, uint8_t *id)
get the revision id
uint8_t bmp390_get_iic_watchdog_period(bmp390_handle_t *handle, bmp390_iic_watchdog_period_t *period)
get the iic watchdog period
struct bmp390_frame_s bmp390_frame_t
bmp390 frame structure definition
uint8_t bmp390_read_temperature_pressure(bmp390_handle_t *handle, uint32_t *temperature_raw, float *temperature_c, uint32_t *pressure_raw, float *pressure_pa)
read the temperature and pressure
bmp390_bool_t
bmp390 bool enumeration definition
bmp390_filter_coefficient_t
bmp390 filter coefficient enumeration definition
uint8_t bmp390_set_odr(bmp390_handle_t *handle, bmp390_odr_t odr)
set the output data rate
uint8_t bmp390_init(bmp390_handle_t *handle)
initialize the chip
bmp390_odr_t
bmp390 output data rate enumeration definition
uint8_t bmp390_set_iic_watchdog_timer(bmp390_handle_t *handle, bmp390_bool_t enable)
enable or disable the iic watchdog timer
bmp390_iic_watchdog_period_t
bmp390 iic watchdog period enumeration definition
uint8_t bmp390_irq_handler(bmp390_handle_t *handle)
irq handler
bmp390_spi_wire_t
bmp390 spi wire enumeration definition
uint8_t bmp390_set_pressure_oversampling(bmp390_handle_t *handle, bmp390_oversampling_t oversampling)
set the pressure oversampling
uint8_t bmp390_set_iic_watchdog_period(bmp390_handle_t *handle, bmp390_iic_watchdog_period_t period)
set the iic watchdog period
uint8_t bmp390_get_filter_coefficient(bmp390_handle_t *handle, bmp390_filter_coefficient_t *coefficient)
get the filter coefficient
uint8_t bmp390_get_event(bmp390_handle_t *handle, bmp390_event_t *event)
get the event
uint8_t bmp390_deinit(bmp390_handle_t *handle)
close the chip
uint8_t bmp390_get_interface(bmp390_handle_t *handle, bmp390_interface_t *interface)
get the interface
uint8_t bmp390_get_temperature(bmp390_handle_t *handle, bmp390_bool_t *enable)
get the temperature status
uint8_t bmp390_get_sensortime(bmp390_handle_t *handle, uint32_t *t)
get the sensor time
uint8_t bmp390_set_interface(bmp390_handle_t *handle, bmp390_interface_t interface)
set the interface
bmp390_address_t
bmp390 address enumeration definition
uint8_t bmp390_get_iic_watchdog_timer(bmp390_handle_t *handle, bmp390_bool_t *enable)
get the iic watchdog timer status
uint8_t bmp390_softreset(bmp390_handle_t *handle)
soft reset
uint8_t bmp390_set_spi_wire(bmp390_handle_t *handle, bmp390_spi_wire_t wire)
set the spi wire
uint8_t bmp390_set_filter_coefficient(bmp390_handle_t *handle, bmp390_filter_coefficient_t coefficient)
set the filter coefficient
struct bmp390_info_s bmp390_info_t
bmp390 information structure definition
struct bmp390_handle_s bmp390_handle_t
bmp390 handle structure definition
bmp390_mode_t
bmp390 mode enumeration definition
@ BMP390_STATUS_COMMAND_READY
@ BMP390_STATUS_PRESS_READY
@ BMP390_STATUS_TEMP_READY
@ BMP390_INTERRUPT_STATUS_FIFO_FULL
@ BMP390_INTERRUPT_STATUS_DATA_READY
@ BMP390_INTERRUPT_STATUS_FIFO_WATERMARK
@ BMP390_INTERFACE_IIC
@ BMP390_INTERFACE_SPI
@ BMP390_EVENT_BOTH
@ BMP390_EVENT_ITF_ACT_PT
@ BMP390_EVENT_NONE
@ BMP390_EVENT_POWER_UP_OR_SOFTRESET
@ BMP390_ERROR_CONF
@ BMP390_ERROR_FATAL
@ BMP390_ERROR_CMD
@ BMP390_INTERRUPT_ACTIVE_LEVEL_HIGHER
@ BMP390_INTERRUPT_ACTIVE_LEVEL_LOWER
@ BMP390_FIFO_DATA_SOURCE_FILTERED
@ BMP390_FIFO_DATA_SOURCE_UNFILTERED
@ BMP390_OVERSAMPLING_x32
@ BMP390_OVERSAMPLING_x4
@ BMP390_OVERSAMPLING_x16
@ BMP390_OVERSAMPLING_x1
@ BMP390_OVERSAMPLING_x8
@ BMP390_OVERSAMPLING_x2
@ BMP390_INTERRUPT_PIN_TYPE_OPEN_DRAIN
@ BMP390_INTERRUPT_PIN_TYPE_PUSH_PULL
@ BMP390_FRAME_TYPE_TEMPERATURE
@ BMP390_FRAME_TYPE_PRESSURE
@ BMP390_FRAME_TYPE_SENSORTIME
@ BMP390_BOOL_FALSE
@ BMP390_BOOL_TRUE
@ BMP390_FILTER_COEFFICIENT_31
@ BMP390_FILTER_COEFFICIENT_7
@ BMP390_FILTER_COEFFICIENT_0
@ BMP390_FILTER_COEFFICIENT_127
@ BMP390_FILTER_COEFFICIENT_3
@ BMP390_FILTER_COEFFICIENT_15
@ BMP390_FILTER_COEFFICIENT_63
@ BMP390_FILTER_COEFFICIENT_1
@ BMP390_ODR_0P1_HZ
@ BMP390_ODR_200_HZ
@ BMP390_ODR_0P2_HZ
@ BMP390_ODR_12P5_HZ
@ BMP390_ODR_0P02_HZ
@ BMP390_ODR_6P25_HZ
@ BMP390_ODR_1P5_HZ
@ BMP390_ODR_0P003_HZ
@ BMP390_ODR_0P0015_HZ
@ BMP390_ODR_0P05_HZ
@ BMP390_ODR_3P1_HZ
@ BMP390_ODR_0P39_HZ
@ BMP390_ODR_0P78_HZ
@ BMP390_ODR_50_HZ
@ BMP390_ODR_25_HZ
@ BMP390_ODR_100_HZ
@ BMP390_ODR_0P006_HZ
@ BMP390_ODR_0P01_HZ
@ BMP390_IIC_WATCHDOG_PERIOD_1P25_MS
@ BMP390_IIC_WATCHDOG_PERIOD_40_MS
@ BMP390_SPI_WIRE_3
@ BMP390_SPI_WIRE_4
@ BMP390_ADDRESS_ADO_LOW
@ BMP390_ADDRESS_ADO_HIGH
@ BMP390_MODE_FORCED_MODE
@ BMP390_MODE_NORMAL_MODE
@ BMP390_MODE_SLEEP_MODE
uint8_t bmp390_set_reg(bmp390_handle_t *handle, uint8_t reg, uint8_t value)
set the chip register
uint8_t bmp390_get_reg(bmp390_handle_t *handle, uint8_t reg, uint8_t *value)
get the chip register
uint8_t bmp390_fifo_parse(bmp390_handle_t *handle, uint8_t *buf, uint16_t buf_len, bmp390_frame_t *frame, uint16_t *frame_len)
parse the fifo data
uint8_t bmp390_set_fifo_data_source(bmp390_handle_t *handle, bmp390_fifo_data_source_t source)
set the fifo data source
uint8_t bmp390_get_fifo(bmp390_handle_t *handle, bmp390_bool_t *enable)
get the fifo status
uint8_t bmp390_set_fifo_pressure_on(bmp390_handle_t *handle, bmp390_bool_t enable)
enable or disable the fifo pressure on
uint8_t bmp390_get_fifo_pressure_on(bmp390_handle_t *handle, bmp390_bool_t *enable)
get the fifo pressure on status
uint8_t bmp390_set_fifo_temperature_on(bmp390_handle_t *handle, bmp390_bool_t enable)
enable or disable the fifo temperature on
uint8_t bmp390_get_fifo_stop_on_full(bmp390_handle_t *handle, bmp390_bool_t *enable)
get the fifo stopping on full status
uint8_t bmp390_set_fifo(bmp390_handle_t *handle, bmp390_bool_t enable)
enable or disable the fifo
uint8_t bmp390_get_fifo_data_source(bmp390_handle_t *handle, bmp390_fifo_data_source_t *source)
get the fifo data source
uint8_t bmp390_read_fifo(bmp390_handle_t *handle, uint8_t *buf, uint16_t *len)
read the fifo
uint8_t bmp390_get_fifo_watermark(bmp390_handle_t *handle, uint16_t *watermark)
get the fifo watermark
uint8_t bmp390_get_fifo_subsampling(bmp390_handle_t *handle, uint8_t *subsample)
get the fifo subsampling
uint8_t bmp390_set_fifo_sensortime_on(bmp390_handle_t *handle, bmp390_bool_t enable)
enable or disable the fifo sensor time on
uint8_t bmp390_set_fifo_subsampling(bmp390_handle_t *handle, uint8_t subsample)
set the fifo subsampling
uint8_t bmp390_flush_fifo(bmp390_handle_t *handle)
flush the fifo
uint8_t bmp390_set_fifo_stop_on_full(bmp390_handle_t *handle, bmp390_bool_t enable)
enable or disable the fifo stopping on full
uint8_t bmp390_set_fifo_watermark(bmp390_handle_t *handle, uint16_t watermark)
set the fifo watermark
uint8_t bmp390_get_fifo_data(bmp390_handle_t *handle, uint8_t *data, uint16_t length)
get the fifo data
uint8_t bmp390_get_fifo_sensortime_on(bmp390_handle_t *handle, bmp390_bool_t *enable)
get the fifo sensor time on status
uint8_t bmp390_get_fifo_temperature_on(bmp390_handle_t *handle, bmp390_bool_t *enable)
get the fifo temperature on status
uint8_t bmp390_get_fifo_length(bmp390_handle_t *handle, uint16_t *length)
get the fifo length
uint8_t bmp390_get_interrupt_fifo_watermark(bmp390_handle_t *handle, bmp390_bool_t *enable)
get the interrupt fifo watermark
uint8_t bmp390_get_interrupt_fifo_full(bmp390_handle_t *handle, bmp390_bool_t *enable)
get the interrupt fifo full
uint8_t bmp390_set_interrupt_fifo_watermark(bmp390_handle_t *handle, bmp390_bool_t enable)
enable or disable the fifo watermark interrupt
uint8_t bmp390_get_interrupt_active_level(bmp390_handle_t *handle, bmp390_interrupt_active_level_t *level)
get the interrupt active level
uint8_t bmp390_get_interrupt_data_ready(bmp390_handle_t *handle, bmp390_bool_t *enable)
get the interrupt data ready status
uint8_t bmp390_set_interrupt_data_ready(bmp390_handle_t *handle, bmp390_bool_t enable)
enable or disable the data ready interrupt
uint8_t bmp390_get_latch_interrupt_pin_and_interrupt_status(bmp390_handle_t *handle, bmp390_bool_t *enable)
get latching interrupt pin and interrupt status
uint8_t bmp390_get_interrupt_status(bmp390_handle_t *handle, uint8_t *status)
get the interrupt status
uint8_t bmp390_get_interrupt_pin_type(bmp390_handle_t *handle, bmp390_interrupt_pin_type_t *pin_type)
get the interrupt pin type
uint8_t bmp390_set_latch_interrupt_pin_and_interrupt_status(bmp390_handle_t *handle, bmp390_bool_t enable)
enable or disable latching interrupt pin and interrupt status
uint8_t bmp390_set_interrupt_pin_type(bmp390_handle_t *handle, bmp390_interrupt_pin_type_t pin_type)
set the interrupt pin type
uint8_t bmp390_set_interrupt_fifo_full(bmp390_handle_t *handle, bmp390_bool_t enable)
enable or disable the fifo full interrupt
uint8_t bmp390_set_interrupt_active_level(bmp390_handle_t *handle, bmp390_interrupt_active_level_t level)
set the interrupt active level
bmp390 frame structure definition
bmp390_frame_type_t type
bmp390 handle structure definition
uint8_t(* spi_init)(void)
void(* delay_ms)(uint32_t ms)
uint8_t(* spi_read)(uint8_t reg, uint8_t *buf, uint16_t len)
void(* receive_callback)(uint8_t type)
uint8_t(* spi_write)(uint8_t reg, uint8_t *buf, uint16_t len)
void(* debug_print)(const char *const fmt,...)
uint8_t buf[512+1]
uint8_t(* iic_init)(void)
uint8_t(* spi_deinit)(void)
uint8_t(* iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_deinit)(void)
bmp390 information structure definition
float supply_voltage_max_v
uint32_t driver_version
char manufacturer_name[32]
float supply_voltage_min_v
char chip_name[32]