LibDriver BMP388
Loading...
Searching...
No Matches
driver_bmp388.h
Go to the documentation of this file.
1
37
38#ifndef DRIVER_BMP388_H
39#define DRIVER_BMP388_H
40
41#include <stdint.h>
42#include <stdio.h>
43#include <string.h>
44
45#ifdef __cplusplus
46extern "C"{
47#endif
48
54
59
68
72typedef enum
73{
74 BMP388_ADDRESS_ADO_LOW = (0x76 << 1),
77
81typedef enum
82{
86
90typedef enum
91{
92 BMP388_ERROR_FATAL = (1 << 0),
93 BMP388_ERROR_CMD = (1 << 1),
94 BMP388_ERROR_CONF = (1 << 2),
96
106
115
124
134
143
152
156typedef enum
157{
161
170
180
193
218
233
243
253
257typedef struct bmp388_handle_s
258{
259 uint8_t iic_addr;
260 uint8_t buf[512 + 1];
261 uint8_t (*iic_init)(void);
262 uint8_t (*iic_deinit)(void);
263 uint8_t (*iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
264 uint8_t (*iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
265 uint8_t (*spi_init)(void);
266 uint8_t (*spi_deinit)(void);
267 uint8_t (*spi_read)(uint8_t reg, uint8_t *buf, uint16_t len);
268 uint8_t (*spi_write)(uint8_t reg, uint8_t *buf, uint16_t len);
269 void (*receive_callback)(uint8_t type);
270 void (*delay_ms)(uint32_t ms);
271 void (*debug_print)(const char *const fmt, ...);
272 uint8_t inited;
273 uint8_t iic_spi;
274 uint16_t t1;
275 uint16_t t2;
276 int8_t t3;
277 int16_t p1;
278 int16_t p2;
279 int8_t p3;
280 int8_t p4;
281 uint16_t p5;
282 uint16_t p6;
283 int8_t p7;
284 int8_t p8;
285 int16_t p9;
286 int8_t p10;
287 int8_t p11;
288 int64_t t_fine;
290
306
310
317
324#define DRIVER_BMP388_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
325
332#define DRIVER_BMP388_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
333
340#define DRIVER_BMP388_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
341
348#define DRIVER_BMP388_LINK_IIC_READ(HANDLE, FUC) (HANDLE)->iic_read = FUC
349
356#define DRIVER_BMP388_LINK_IIC_WRITE(HANDLE, FUC) (HANDLE)->iic_write = FUC
357
364#define DRIVER_BMP388_LINK_SPI_INIT(HANDLE, FUC) (HANDLE)->spi_init = FUC
365
372#define DRIVER_BMP388_LINK_SPI_DEINIT(HANDLE, FUC) (HANDLE)->spi_deinit = FUC
373
380#define DRIVER_BMP388_LINK_SPI_READ(HANDLE, FUC) (HANDLE)->spi_read = FUC
381
388#define DRIVER_BMP388_LINK_SPI_WRITE(HANDLE, FUC) (HANDLE)->spi_write = FUC
389
396#define DRIVER_BMP388_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
397
404#define DRIVER_BMP388_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
405
412#define DRIVER_BMP388_LINK_RECEIVE_CALLBACK(HANDLE, FUC) (HANDLE)->receive_callback = FUC
413
417
424
433uint8_t bmp388_info(bmp388_info_t *info);
434
444uint8_t bmp388_set_addr_pin(bmp388_handle_t *handle, bmp388_address_t addr_pin);
445
455uint8_t bmp388_get_addr_pin(bmp388_handle_t *handle, bmp388_address_t *addr_pin);
456
467
477uint8_t bmp388_get_interface(bmp388_handle_t *handle, bmp388_interface_t *interface);
478
489uint8_t bmp388_irq_handler(bmp388_handle_t *handle);
490
504uint8_t bmp388_init(bmp388_handle_t *handle);
505
517uint8_t bmp388_deinit(bmp388_handle_t *handle);
518
533uint8_t bmp388_read_temperature_pressure(bmp388_handle_t *handle, uint32_t *temperature_raw, float *temperature_c,
534 uint32_t *pressure_raw, float *pressure_pa);
535
548uint8_t bmp388_read_temperature(bmp388_handle_t *handle, uint32_t *raw, float *c);
549
562uint8_t bmp388_read_pressure(bmp388_handle_t *handle, uint32_t *raw, float *pa);
563
575uint8_t bmp388_get_error(bmp388_handle_t *handle, uint8_t *err);
576
588uint8_t bmp388_get_status(bmp388_handle_t *handle, uint8_t *status);
589
601uint8_t bmp388_get_sensortime(bmp388_handle_t *handle, uint32_t *t);
602
614uint8_t bmp388_get_event(bmp388_handle_t *handle, bmp388_event_t *event);
615
628
641
654
667
680
693
705uint8_t bmp388_set_pressure(bmp388_handle_t *handle, bmp388_bool_t enable);
706
718uint8_t bmp388_get_pressure(bmp388_handle_t *handle, bmp388_bool_t *enable);
719
732
745
757uint8_t bmp388_set_mode(bmp388_handle_t *handle, bmp388_mode_t mode);
758
770uint8_t bmp388_get_mode(bmp388_handle_t *handle, bmp388_mode_t *mode);
771
784
797
810
823
835uint8_t bmp388_set_odr(bmp388_handle_t *handle, bmp388_odr_t odr);
836
848uint8_t bmp388_get_odr(bmp388_handle_t *handle, bmp388_odr_t *odr);
849
862
875
886uint8_t bmp388_softreset(bmp388_handle_t *handle);
887
899
903
910
922uint8_t bmp388_get_interrupt_status(bmp388_handle_t *handle, uint8_t *status);
923
936
949
962
975
988
1001
1014
1027
1040
1053
1066
1079
1083
1090
1102uint8_t bmp388_get_fifo_length(bmp388_handle_t *handle, uint16_t *length);
1103
1116uint8_t bmp388_get_fifo_data(bmp388_handle_t *handle, uint8_t *data, uint16_t length);
1117
1129uint8_t bmp388_set_fifo_watermark(bmp388_handle_t *handle, uint16_t watermark);
1130
1142uint8_t bmp388_get_fifo_watermark(bmp388_handle_t *handle, uint16_t *watermark);
1143
1155uint8_t bmp388_set_fifo(bmp388_handle_t *handle, bmp388_bool_t enable);
1156
1168uint8_t bmp388_get_fifo(bmp388_handle_t *handle, bmp388_bool_t *enable);
1169
1182
1195
1208
1221
1234
1247
1260
1273
1285uint8_t bmp388_set_fifo_subsampling(bmp388_handle_t *handle, uint8_t subsample);
1286
1298uint8_t bmp388_get_fifo_subsampling(bmp388_handle_t *handle, uint8_t *subsample);
1299
1312
1325
1336uint8_t bmp388_flush_fifo(bmp388_handle_t *handle);
1337
1350uint8_t bmp388_read_fifo(bmp388_handle_t *handle, uint8_t *buf, uint16_t *len);
1351
1366uint8_t bmp388_fifo_parse(bmp388_handle_t *handle, uint8_t *buf, uint16_t buf_len, bmp388_frame_t *frame, uint16_t *frame_len);
1367
1371
1378
1391uint8_t bmp388_set_reg(bmp388_handle_t *handle, uint8_t reg, uint8_t value);
1392
1405uint8_t bmp388_get_reg(bmp388_handle_t *handle, uint8_t reg, uint8_t *value);
1406
1410
1414
1415#ifdef __cplusplus
1416}
1417#endif
1418
1419#endif
bmp388_error_t
bmp388 error enumeration definition
bmp388_oversampling_t
bmp388 oversampling enumeration definition
uint8_t bmp388_get_error(bmp388_handle_t *handle, uint8_t *err)
get the error
uint8_t bmp388_set_odr(bmp388_handle_t *handle, bmp388_odr_t odr)
set the output data rate
uint8_t bmp388_set_pressure(bmp388_handle_t *handle, bmp388_bool_t enable)
enable or disable the pressure
bmp388_interface_t
bmp388 interface enumeration definition
uint8_t bmp388_init(bmp388_handle_t *handle)
initialize the chip
uint8_t bmp388_set_spi_wire(bmp388_handle_t *handle, bmp388_spi_wire_t wire)
set the spi wire
uint8_t bmp388_read_pressure(bmp388_handle_t *handle, uint32_t *raw, float *pa)
read the pressure
bmp388_spi_wire_t
bmp388 spi wire enumeration definition
uint8_t bmp388_get_temperature_oversampling(bmp388_handle_t *handle, bmp388_oversampling_t *oversampling)
get the temperature oversampling
uint8_t bmp388_get_interface(bmp388_handle_t *handle, bmp388_interface_t *interface)
get the interface
uint8_t bmp388_set_iic_watchdog_timer(bmp388_handle_t *handle, bmp388_bool_t enable)
enable or disable the iic watchdog timer
uint8_t bmp388_read_temperature(bmp388_handle_t *handle, uint32_t *raw, float *c)
read the temperature
uint8_t bmp388_get_pressure(bmp388_handle_t *handle, bmp388_bool_t *enable)
get the pressure status
bmp388_frame_type_t
bmp388 frame type enumeration definition
uint8_t bmp388_get_event(bmp388_handle_t *handle, bmp388_event_t *event)
get the event
struct bmp388_handle_s bmp388_handle_t
bmp388 handle structure definition
uint8_t bmp388_set_pressure_oversampling(bmp388_handle_t *handle, bmp388_oversampling_t oversampling)
set the pressure oversampling
struct bmp388_frame_s bmp388_frame_t
bmp388 frame structure definition
uint8_t bmp388_get_iic_watchdog_period(bmp388_handle_t *handle, bmp388_iic_watchdog_period_t *period)
get the iic watchdog period
uint8_t bmp388_get_pressure_oversampling(bmp388_handle_t *handle, bmp388_oversampling_t *oversampling)
get the pressure oversampling
uint8_t bmp388_set_temperature(bmp388_handle_t *handle, bmp388_bool_t enable)
enable or disable the temperature
bmp388_status_t
bmp388 status enumeration definition
uint8_t bmp388_set_filter_coefficient(bmp388_handle_t *handle, bmp388_filter_coefficient_t coefficient)
set the filter coefficient
uint8_t bmp388_irq_handler(bmp388_handle_t *handle)
irq handler
uint8_t bmp388_deinit(bmp388_handle_t *handle)
close the chip
uint8_t bmp388_set_interface(bmp388_handle_t *handle, bmp388_interface_t interface)
set the interface
uint8_t bmp388_get_mode(bmp388_handle_t *handle, bmp388_mode_t *mode)
get the chip mode
uint8_t bmp388_get_status(bmp388_handle_t *handle, uint8_t *status)
get the status
uint8_t bmp388_get_addr_pin(bmp388_handle_t *handle, bmp388_address_t *addr_pin)
get the iic address pin
bmp388_filter_coefficient_t
bmp388 filter coefficient enumeration definition
uint8_t bmp388_get_sensortime(bmp388_handle_t *handle, uint32_t *t)
get the sensor time
uint8_t bmp388_set_iic_watchdog_period(bmp388_handle_t *handle, bmp388_iic_watchdog_period_t period)
set the iic watchdog period
uint8_t bmp388_read_temperature_pressure(bmp388_handle_t *handle, uint32_t *temperature_raw, float *temperature_c, uint32_t *pressure_raw, float *pressure_pa)
read the temperature and pressure
bmp388_event_t
bmp388 event enumeration definition
uint8_t bmp388_set_mode(bmp388_handle_t *handle, bmp388_mode_t mode)
set the chip mode
uint8_t bmp388_softreset(bmp388_handle_t *handle)
soft reset
bmp388_odr_t
bmp388 output data rate enumeration definition
uint8_t bmp388_set_temperature_oversampling(bmp388_handle_t *handle, bmp388_oversampling_t oversampling)
set the temperature oversampling
uint8_t bmp388_get_temperature(bmp388_handle_t *handle, bmp388_bool_t *enable)
get the temperature status
uint8_t bmp388_extmode_en_middle(bmp388_handle_t *handle)
extmode enable middle
bmp388_interrupt_active_level_t
bmp388 interrupt active level enumeration definition
uint8_t bmp388_get_iic_watchdog_timer(bmp388_handle_t *handle, bmp388_bool_t *enable)
get the iic watchdog timer status
uint8_t bmp388_set_addr_pin(bmp388_handle_t *handle, bmp388_address_t addr_pin)
set the iic address pin
bmp388_bool_t
bmp388 bool enumeration definition
bmp388_interrupt_status_t
bmp388 interrupt status enumeration definition
bmp388_fifo_data_source_t
bmp388 fifo data source enumeration definition
bmp388_mode_t
bmp388 mode enumeration definition
struct bmp388_info_s bmp388_info_t
bmp388 information structure definition
uint8_t bmp388_info(bmp388_info_t *info)
get chip's information
bmp388_interrupt_pin_type_t
bmp388 interrupt pin type enumeration definition
bmp388_address_t
bmp388 address enumeration definition
uint8_t bmp388_get_spi_wire(bmp388_handle_t *handle, bmp388_spi_wire_t *wire)
get the spi wire
uint8_t bmp388_get_odr(bmp388_handle_t *handle, bmp388_odr_t *odr)
get the output data rate
bmp388_iic_watchdog_period_t
bmp388 iic watchdog period enumeration definition
uint8_t bmp388_get_filter_coefficient(bmp388_handle_t *handle, bmp388_filter_coefficient_t *coefficient)
get the filter coefficient
@ BMP388_ERROR_CONF
@ BMP388_ERROR_FATAL
@ BMP388_ERROR_CMD
@ BMP388_OVERSAMPLING_x4
@ BMP388_OVERSAMPLING_x32
@ BMP388_OVERSAMPLING_x1
@ BMP388_OVERSAMPLING_x8
@ BMP388_OVERSAMPLING_x2
@ BMP388_OVERSAMPLING_x16
@ BMP388_INTERFACE_SPI
@ BMP388_INTERFACE_IIC
@ BMP388_SPI_WIRE_3
@ BMP388_SPI_WIRE_4
@ BMP388_FRAME_TYPE_SENSORTIME
@ BMP388_FRAME_TYPE_TEMPERATURE
@ BMP388_FRAME_TYPE_PRESSURE
@ BMP388_STATUS_PRESS_READY
@ BMP388_STATUS_TEMP_READY
@ BMP388_STATUS_COMMAND_READY
@ BMP388_FILTER_COEFFICIENT_1
@ BMP388_FILTER_COEFFICIENT_3
@ BMP388_FILTER_COEFFICIENT_15
@ BMP388_FILTER_COEFFICIENT_0
@ BMP388_FILTER_COEFFICIENT_7
@ BMP388_FILTER_COEFFICIENT_127
@ BMP388_FILTER_COEFFICIENT_31
@ BMP388_FILTER_COEFFICIENT_63
@ BMP388_EVENT_POWER_UP_OR_SOFTRESET
@ BMP388_EVENT_NONE
@ BMP388_ODR_1P5_HZ
@ BMP388_ODR_0P006_HZ
@ BMP388_ODR_0P02_HZ
@ BMP388_ODR_200_HZ
@ BMP388_ODR_0P2_HZ
@ BMP388_ODR_12P5_HZ
@ BMP388_ODR_6P25_HZ
@ BMP388_ODR_0P0015_HZ
@ BMP388_ODR_25_HZ
@ BMP388_ODR_0P003_HZ
@ BMP388_ODR_50_HZ
@ BMP388_ODR_0P78_HZ
@ BMP388_ODR_0P05_HZ
@ BMP388_ODR_0P1_HZ
@ BMP388_ODR_100_HZ
@ BMP388_ODR_0P01_HZ
@ BMP388_ODR_3P1_HZ
@ BMP388_ODR_0P39_HZ
@ BMP388_INTERRUPT_ACTIVE_LEVEL_LOWER
@ BMP388_INTERRUPT_ACTIVE_LEVEL_HIGHER
@ BMP388_BOOL_TRUE
@ BMP388_BOOL_FALSE
@ BMP388_INTERRUPT_STATUS_FIFO_FULL
@ BMP388_INTERRUPT_STATUS_DATA_READY
@ BMP388_INTERRUPT_STATUS_FIFO_WATERMARK
@ BMP388_FIFO_DATA_SOURCE_FILTERED
@ BMP388_FIFO_DATA_SOURCE_UNFILTERED
@ BMP388_MODE_SLEEP_MODE
@ BMP388_MODE_NORMAL_MODE
@ BMP388_MODE_FORCED_MODE
@ BMP388_INTERRUPT_PIN_TYPE_PUSH_PULL
@ BMP388_INTERRUPT_PIN_TYPE_OPEN_DRAIN
@ BMP388_ADDRESS_ADO_HIGH
@ BMP388_ADDRESS_ADO_LOW
@ BMP388_IIC_WATCHDOG_PERIOD_1P25_MS
@ BMP388_IIC_WATCHDOG_PERIOD_40_MS
uint8_t bmp388_get_reg(bmp388_handle_t *handle, uint8_t reg, uint8_t *value)
get the chip register
uint8_t bmp388_set_reg(bmp388_handle_t *handle, uint8_t reg, uint8_t value)
set the chip register
uint8_t bmp388_get_fifo_data(bmp388_handle_t *handle, uint8_t *data, uint16_t length)
get the fifo data
uint8_t bmp388_get_fifo_subsampling(bmp388_handle_t *handle, uint8_t *subsample)
get the fifo subsampling
uint8_t bmp388_get_fifo_sensortime_on(bmp388_handle_t *handle, bmp388_bool_t *enable)
get the fifo sensor time on status
uint8_t bmp388_read_fifo(bmp388_handle_t *handle, uint8_t *buf, uint16_t *len)
read the fifo
uint8_t bmp388_set_fifo_temperature_on(bmp388_handle_t *handle, bmp388_bool_t enable)
enable or disable the fifo temperature on
uint8_t bmp388_fifo_parse(bmp388_handle_t *handle, uint8_t *buf, uint16_t buf_len, bmp388_frame_t *frame, uint16_t *frame_len)
parse the fifo data
uint8_t bmp388_get_fifo_length(bmp388_handle_t *handle, uint16_t *length)
get the fifo length
uint8_t bmp388_set_fifo_watermark(bmp388_handle_t *handle, uint16_t watermark)
set the fifo watermark
uint8_t bmp388_set_fifo_subsampling(bmp388_handle_t *handle, uint8_t subsample)
set the fifo subsampling
uint8_t bmp388_get_fifo_stop_on_full(bmp388_handle_t *handle, bmp388_bool_t *enable)
get the fifo stopping on full status
uint8_t bmp388_get_fifo_pressure_on(bmp388_handle_t *handle, bmp388_bool_t *enable)
get the fifo pressure on status
uint8_t bmp388_get_fifo_data_source(bmp388_handle_t *handle, bmp388_fifo_data_source_t *source)
get the fifo data source
uint8_t bmp388_set_fifo_data_source(bmp388_handle_t *handle, bmp388_fifo_data_source_t source)
set the fifo data source
uint8_t bmp388_get_fifo_watermark(bmp388_handle_t *handle, uint16_t *watermark)
get the fifo watermark
uint8_t bmp388_set_fifo_stop_on_full(bmp388_handle_t *handle, bmp388_bool_t enable)
enable or disable the fifo stopping on full
uint8_t bmp388_set_fifo_sensortime_on(bmp388_handle_t *handle, bmp388_bool_t enable)
enable or disable the fifo sensor time on
uint8_t bmp388_get_fifo_temperature_on(bmp388_handle_t *handle, bmp388_bool_t *enable)
get the fifo temperature on status
uint8_t bmp388_set_fifo_pressure_on(bmp388_handle_t *handle, bmp388_bool_t enable)
enable or disable the fifo pressure on
uint8_t bmp388_set_fifo(bmp388_handle_t *handle, bmp388_bool_t enable)
enable or disable the fifo
uint8_t bmp388_get_fifo(bmp388_handle_t *handle, bmp388_bool_t *enable)
get the fifo status
uint8_t bmp388_flush_fifo(bmp388_handle_t *handle)
flush the fifo
uint8_t bmp388_get_interrupt_fifo_watermark(bmp388_handle_t *handle, bmp388_bool_t *enable)
get the interrupt fifo watermark
uint8_t bmp388_get_interrupt_data_ready(bmp388_handle_t *handle, bmp388_bool_t *enable)
get the interrupt data ready status
uint8_t bmp388_get_interrupt_active_level(bmp388_handle_t *handle, bmp388_interrupt_active_level_t *level)
get the interrupt active level
uint8_t bmp388_get_latch_interrupt_pin_and_interrupt_status(bmp388_handle_t *handle, bmp388_bool_t *enable)
get latching interrupt pin and interrupt status
uint8_t bmp388_set_interrupt_fifo_full(bmp388_handle_t *handle, bmp388_bool_t enable)
enable or disable the fifo full interrupt
uint8_t bmp388_get_interrupt_fifo_full(bmp388_handle_t *handle, bmp388_bool_t *enable)
get the interrupt fifo full
uint8_t bmp388_set_interrupt_fifo_watermark(bmp388_handle_t *handle, bmp388_bool_t enable)
enable or disable the fifo watermark interrupt
uint8_t bmp388_get_interrupt_status(bmp388_handle_t *handle, uint8_t *status)
get the interrupt status
uint8_t bmp388_get_interrupt_pin_type(bmp388_handle_t *handle, bmp388_interrupt_pin_type_t *pin_type)
get the interrupt pin type
uint8_t bmp388_set_interrupt_data_ready(bmp388_handle_t *handle, bmp388_bool_t enable)
enable or disable the data ready interrupt
uint8_t bmp388_set_interrupt_active_level(bmp388_handle_t *handle, bmp388_interrupt_active_level_t level)
set the interrupt active level
uint8_t bmp388_set_interrupt_pin_type(bmp388_handle_t *handle, bmp388_interrupt_pin_type_t pin_type)
set the interrupt pin type
uint8_t bmp388_set_latch_interrupt_pin_and_interrupt_status(bmp388_handle_t *handle, bmp388_bool_t enable)
enable or disable latching interrupt pin and interrupt status
bmp388 frame structure definition
bmp388_frame_type_t type
bmp388 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)
bmp388 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]