LibDriver BMP384
Loading...
Searching...
No Matches
driver_bmp384.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_BMP384_H
38#define DRIVER_BMP384_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 BMP384_ADDRESS_ADO_LOW = (0x76 << 1),
76
80typedef enum
81{
85
89typedef enum
90{
91 BMP384_ERROR_FATAL = (1 << 0),
92 BMP384_ERROR_CMD = (1 << 1),
93 BMP384_ERROR_CONF = (1 << 2),
95
105
114
123
133
142
151
155typedef enum
156{
160
169
179
192
217
232
242
252
256typedef struct bmp384_handle_s
257{
258 uint8_t iic_addr;
259 uint8_t buf[512 + 1];
260 uint8_t (*iic_init)(void);
261 uint8_t (*iic_deinit)(void);
262 uint8_t (*iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
263 uint8_t (*iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
264 uint8_t (*spi_init)(void);
265 uint8_t (*spi_deinit)(void);
266 uint8_t (*spi_read)(uint8_t reg, uint8_t *buf, uint16_t len);
267 uint8_t (*spi_write)(uint8_t reg, uint8_t *buf, uint16_t len);
268 void (*receive_callback)(uint8_t type);
269 void (*delay_ms)(uint32_t ms);
270 void (*debug_print)(const char *const fmt, ...);
271 uint8_t inited;
272 uint8_t iic_spi;
273 uint16_t t1;
274 uint16_t t2;
275 int8_t t3;
276 int16_t p1;
277 int16_t p2;
278 int8_t p3;
279 int8_t p4;
280 uint16_t p5;
281 uint16_t p6;
282 int8_t p7;
283 int8_t p8;
284 int16_t p9;
285 int8_t p10;
286 int8_t p11;
287 int64_t t_fine;
289
305
309
316
323#define DRIVER_BMP384_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
324
331#define DRIVER_BMP384_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
332
339#define DRIVER_BMP384_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
340
347#define DRIVER_BMP384_LINK_IIC_READ(HANDLE, FUC) (HANDLE)->iic_read = FUC
348
355#define DRIVER_BMP384_LINK_IIC_WRITE(HANDLE, FUC) (HANDLE)->iic_write = FUC
356
363#define DRIVER_BMP384_LINK_SPI_INIT(HANDLE, FUC) (HANDLE)->spi_init = FUC
364
371#define DRIVER_BMP384_LINK_SPI_DEINIT(HANDLE, FUC) (HANDLE)->spi_deinit = FUC
372
379#define DRIVER_BMP384_LINK_SPI_READ(HANDLE, FUC) (HANDLE)->spi_read = FUC
380
387#define DRIVER_BMP384_LINK_SPI_WRITE(HANDLE, FUC) (HANDLE)->spi_write = FUC
388
395#define DRIVER_BMP384_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
396
403#define DRIVER_BMP384_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
404
411#define DRIVER_BMP384_LINK_RECEIVE_CALLBACK(HANDLE, FUC) (HANDLE)->receive_callback = FUC
412
416
423
432uint8_t bmp384_info(bmp384_info_t *info);
433
443uint8_t bmp384_set_addr_pin(bmp384_handle_t *handle, bmp384_address_t addr_pin);
444
454uint8_t bmp384_get_addr_pin(bmp384_handle_t *handle, bmp384_address_t *addr_pin);
455
466
476uint8_t bmp384_get_interface(bmp384_handle_t *handle, bmp384_interface_t *interface);
477
488uint8_t bmp384_irq_handler(bmp384_handle_t *handle);
489
503uint8_t bmp384_init(bmp384_handle_t *handle);
504
516uint8_t bmp384_deinit(bmp384_handle_t *handle);
517
532uint8_t bmp384_read_temperature_pressure(bmp384_handle_t *handle, uint32_t *temperature_raw, float *temperature_c,
533 uint32_t *pressure_raw, float *pressure_pa);
534
547uint8_t bmp384_read_temperature(bmp384_handle_t *handle, uint32_t *raw, float *c);
548
561uint8_t bmp384_read_pressure(bmp384_handle_t *handle, uint32_t *raw, float *pa);
562
574uint8_t bmp384_get_error(bmp384_handle_t *handle, uint8_t *err);
575
587uint8_t bmp384_get_status(bmp384_handle_t *handle, uint8_t *status);
588
600uint8_t bmp384_get_sensortime(bmp384_handle_t *handle, uint32_t *t);
601
613uint8_t bmp384_get_event(bmp384_handle_t *handle, bmp384_event_t *event);
614
627
640
653
666
679
692
704uint8_t bmp384_set_pressure(bmp384_handle_t *handle, bmp384_bool_t enable);
705
717uint8_t bmp384_get_pressure(bmp384_handle_t *handle, bmp384_bool_t *enable);
718
731
744
756uint8_t bmp384_set_mode(bmp384_handle_t *handle, bmp384_mode_t mode);
757
769uint8_t bmp384_get_mode(bmp384_handle_t *handle, bmp384_mode_t *mode);
770
783
796
809
822
834uint8_t bmp384_set_odr(bmp384_handle_t *handle, bmp384_odr_t odr);
835
847uint8_t bmp384_get_odr(bmp384_handle_t *handle, bmp384_odr_t *odr);
848
861
874
885uint8_t bmp384_softreset(bmp384_handle_t *handle);
886
898
902
909
921uint8_t bmp384_get_interrupt_status(bmp384_handle_t *handle, uint8_t *status);
922
935
948
961
974
987
1000
1013
1026
1039
1052
1065
1078
1082
1089
1101uint8_t bmp384_get_fifo_length(bmp384_handle_t *handle, uint16_t *length);
1102
1115uint8_t bmp384_get_fifo_data(bmp384_handle_t *handle, uint8_t *data, uint16_t length);
1116
1128uint8_t bmp384_set_fifo_watermark(bmp384_handle_t *handle, uint16_t watermark);
1129
1141uint8_t bmp384_get_fifo_watermark(bmp384_handle_t *handle, uint16_t *watermark);
1142
1154uint8_t bmp384_set_fifo(bmp384_handle_t *handle, bmp384_bool_t enable);
1155
1167uint8_t bmp384_get_fifo(bmp384_handle_t *handle, bmp384_bool_t *enable);
1168
1181
1194
1207
1220
1233
1246
1259
1272
1284uint8_t bmp384_set_fifo_subsampling(bmp384_handle_t *handle, uint8_t subsample);
1285
1297uint8_t bmp384_get_fifo_subsampling(bmp384_handle_t *handle, uint8_t *subsample);
1298
1311
1324
1335uint8_t bmp384_flush_fifo(bmp384_handle_t *handle);
1336
1349uint8_t bmp384_read_fifo(bmp384_handle_t *handle, uint8_t *buf, uint16_t *len);
1350
1365uint8_t bmp384_fifo_parse(bmp384_handle_t *handle, uint8_t *buf, uint16_t buf_len, bmp384_frame_t *frame, uint16_t *frame_len);
1366
1370
1377
1390uint8_t bmp384_set_reg(bmp384_handle_t *handle, uint8_t reg, uint8_t value);
1391
1404uint8_t bmp384_get_reg(bmp384_handle_t *handle, uint8_t reg, uint8_t *value);
1405
1409
1413
1414#ifdef __cplusplus
1415}
1416#endif
1417
1418#endif
bmp384_error_t
bmp384 error enumeration definition
uint8_t bmp384_read_temperature_pressure(bmp384_handle_t *handle, uint32_t *temperature_raw, float *temperature_c, uint32_t *pressure_raw, float *pressure_pa)
read the temperature and pressure
uint8_t bmp384_get_iic_watchdog_timer(bmp384_handle_t *handle, bmp384_bool_t *enable)
get the iic watchdog timer status
uint8_t bmp384_deinit(bmp384_handle_t *handle)
close the chip
bmp384_event_t
bmp384 event enumeration definition
uint8_t bmp384_get_addr_pin(bmp384_handle_t *handle, bmp384_address_t *addr_pin)
get the iic address pin
uint8_t bmp384_get_spi_wire(bmp384_handle_t *handle, bmp384_spi_wire_t *wire)
get the spi wire
bmp384_mode_t
bmp384 mode enumeration definition
uint8_t bmp384_set_addr_pin(bmp384_handle_t *handle, bmp384_address_t addr_pin)
set the iic address pin
bmp384_interface_t
bmp384 interface enumeration definition
uint8_t bmp384_softreset(bmp384_handle_t *handle)
soft reset
uint8_t bmp384_get_filter_coefficient(bmp384_handle_t *handle, bmp384_filter_coefficient_t *coefficient)
get the filter coefficient
uint8_t bmp384_extmode_en_middle(bmp384_handle_t *handle)
extmode enable middle
uint8_t bmp384_get_pressure_oversampling(bmp384_handle_t *handle, bmp384_oversampling_t *oversampling)
get the pressure oversampling
bmp384_status_t
bmp384 status enumeration definition
bmp384_fifo_data_source_t
bmp384 fifo data source enumeration definition
uint8_t bmp384_get_pressure(bmp384_handle_t *handle, bmp384_bool_t *enable)
get the pressure status
uint8_t bmp384_read_pressure(bmp384_handle_t *handle, uint32_t *raw, float *pa)
read the pressure
uint8_t bmp384_get_status(bmp384_handle_t *handle, uint8_t *status)
get the status
uint8_t bmp384_set_interface(bmp384_handle_t *handle, bmp384_interface_t interface)
set the interface
uint8_t bmp384_set_pressure(bmp384_handle_t *handle, bmp384_bool_t enable)
enable or disable the pressure
uint8_t bmp384_set_temperature(bmp384_handle_t *handle, bmp384_bool_t enable)
enable or disable the temperature
bmp384_spi_wire_t
bmp384 spi wire enumeration definition
bmp384_bool_t
bmp384 bool enumeration definition
uint8_t bmp384_get_sensortime(bmp384_handle_t *handle, uint32_t *t)
get the sensor time
bmp384_frame_type_t
bmp384 frame type enumeration definition
struct bmp384_frame_s bmp384_frame_t
bmp384 frame structure definition
bmp384_interrupt_status_t
bmp384 interrupt status enumeration definition
uint8_t bmp384_read_temperature(bmp384_handle_t *handle, uint32_t *raw, float *c)
read the temperature
bmp384_interrupt_pin_type_t
bmp384 interrupt pin type enumeration definition
uint8_t bmp384_get_temperature_oversampling(bmp384_handle_t *handle, bmp384_oversampling_t *oversampling)
get the temperature oversampling
uint8_t bmp384_set_pressure_oversampling(bmp384_handle_t *handle, bmp384_oversampling_t oversampling)
set the pressure oversampling
uint8_t bmp384_get_interface(bmp384_handle_t *handle, bmp384_interface_t *interface)
get the interface
uint8_t bmp384_set_iic_watchdog_timer(bmp384_handle_t *handle, bmp384_bool_t enable)
enable or disable the iic watchdog timer
uint8_t bmp384_get_event(bmp384_handle_t *handle, bmp384_event_t *event)
get the event
bmp384_odr_t
bmp384 output data rate enumeration definition
bmp384_address_t
bmp384 address enumeration definition
uint8_t bmp384_set_filter_coefficient(bmp384_handle_t *handle, bmp384_filter_coefficient_t coefficient)
set the filter coefficient
uint8_t bmp384_info(bmp384_info_t *info)
get chip's information
bmp384_filter_coefficient_t
bmp384 filter coefficient enumeration definition
uint8_t bmp384_get_mode(bmp384_handle_t *handle, bmp384_mode_t *mode)
get the chip mode
struct bmp384_info_s bmp384_info_t
bmp384 information structure definition
uint8_t bmp384_set_spi_wire(bmp384_handle_t *handle, bmp384_spi_wire_t wire)
set the spi wire
uint8_t bmp384_set_mode(bmp384_handle_t *handle, bmp384_mode_t mode)
set the chip mode
uint8_t bmp384_init(bmp384_handle_t *handle)
initialize the chip
bmp384_iic_watchdog_period_t
bmp384 iic watchdog period enumeration definition
uint8_t bmp384_set_iic_watchdog_period(bmp384_handle_t *handle, bmp384_iic_watchdog_period_t period)
set the iic watchdog period
uint8_t bmp384_get_iic_watchdog_period(bmp384_handle_t *handle, bmp384_iic_watchdog_period_t *period)
get the iic watchdog period
uint8_t bmp384_get_odr(bmp384_handle_t *handle, bmp384_odr_t *odr)
get the output data rate
bmp384_oversampling_t
bmp384 oversampling enumeration definition
uint8_t bmp384_irq_handler(bmp384_handle_t *handle)
irq handler
uint8_t bmp384_set_temperature_oversampling(bmp384_handle_t *handle, bmp384_oversampling_t oversampling)
set the temperature oversampling
struct bmp384_handle_s bmp384_handle_t
bmp384 handle structure definition
uint8_t bmp384_set_odr(bmp384_handle_t *handle, bmp384_odr_t odr)
set the output data rate
uint8_t bmp384_get_temperature(bmp384_handle_t *handle, bmp384_bool_t *enable)
get the temperature status
uint8_t bmp384_get_error(bmp384_handle_t *handle, uint8_t *err)
get the error
bmp384_interrupt_active_level_t
bmp384 interrupt active level enumeration definition
@ BMP384_ERROR_FATAL
@ BMP384_ERROR_CMD
@ BMP384_ERROR_CONF
@ BMP384_EVENT_NONE
@ BMP384_EVENT_POWER_UP_OR_SOFTRESET
@ BMP384_MODE_FORCED_MODE
@ BMP384_MODE_NORMAL_MODE
@ BMP384_MODE_SLEEP_MODE
@ BMP384_INTERFACE_SPI
@ BMP384_INTERFACE_IIC
@ BMP384_STATUS_TEMP_READY
@ BMP384_STATUS_COMMAND_READY
@ BMP384_STATUS_PRESS_READY
@ BMP384_FIFO_DATA_SOURCE_UNFILTERED
@ BMP384_FIFO_DATA_SOURCE_FILTERED
@ BMP384_SPI_WIRE_3
@ BMP384_SPI_WIRE_4
@ BMP384_BOOL_TRUE
@ BMP384_BOOL_FALSE
@ BMP384_FRAME_TYPE_SENSORTIME
@ BMP384_FRAME_TYPE_PRESSURE
@ BMP384_FRAME_TYPE_TEMPERATURE
@ BMP384_INTERRUPT_STATUS_FIFO_WATERMARK
@ BMP384_INTERRUPT_STATUS_FIFO_FULL
@ BMP384_INTERRUPT_STATUS_DATA_READY
@ BMP384_INTERRUPT_PIN_TYPE_PUSH_PULL
@ BMP384_INTERRUPT_PIN_TYPE_OPEN_DRAIN
@ BMP384_ODR_6P25_HZ
@ BMP384_ODR_1P5_HZ
@ BMP384_ODR_100_HZ
@ BMP384_ODR_50_HZ
@ BMP384_ODR_0P003_HZ
@ BMP384_ODR_0P78_HZ
@ BMP384_ODR_0P05_HZ
@ BMP384_ODR_12P5_HZ
@ BMP384_ODR_0P006_HZ
@ BMP384_ODR_25_HZ
@ BMP384_ODR_0P02_HZ
@ BMP384_ODR_200_HZ
@ BMP384_ODR_0P39_HZ
@ BMP384_ODR_3P1_HZ
@ BMP384_ODR_0P2_HZ
@ BMP384_ODR_0P1_HZ
@ BMP384_ODR_0P01_HZ
@ BMP384_ODR_0P0015_HZ
@ BMP384_ADDRESS_ADO_LOW
@ BMP384_ADDRESS_ADO_HIGH
@ BMP384_FILTER_COEFFICIENT_31
@ BMP384_FILTER_COEFFICIENT_63
@ BMP384_FILTER_COEFFICIENT_127
@ BMP384_FILTER_COEFFICIENT_7
@ BMP384_FILTER_COEFFICIENT_15
@ BMP384_FILTER_COEFFICIENT_0
@ BMP384_FILTER_COEFFICIENT_3
@ BMP384_FILTER_COEFFICIENT_1
@ BMP384_IIC_WATCHDOG_PERIOD_1P25_MS
@ BMP384_IIC_WATCHDOG_PERIOD_40_MS
@ BMP384_OVERSAMPLING_x1
@ BMP384_OVERSAMPLING_x32
@ BMP384_OVERSAMPLING_x2
@ BMP384_OVERSAMPLING_x16
@ BMP384_OVERSAMPLING_x4
@ BMP384_OVERSAMPLING_x8
@ BMP384_INTERRUPT_ACTIVE_LEVEL_LOWER
@ BMP384_INTERRUPT_ACTIVE_LEVEL_HIGHER
uint8_t bmp384_set_reg(bmp384_handle_t *handle, uint8_t reg, uint8_t value)
set the chip register
uint8_t bmp384_get_reg(bmp384_handle_t *handle, uint8_t reg, uint8_t *value)
get the chip register
uint8_t bmp384_fifo_parse(bmp384_handle_t *handle, uint8_t *buf, uint16_t buf_len, bmp384_frame_t *frame, uint16_t *frame_len)
parse the fifo data
uint8_t bmp384_get_fifo_pressure_on(bmp384_handle_t *handle, bmp384_bool_t *enable)
get the fifo pressure on status
uint8_t bmp384_set_fifo_pressure_on(bmp384_handle_t *handle, bmp384_bool_t enable)
enable or disable the fifo pressure on
uint8_t bmp384_set_fifo_data_source(bmp384_handle_t *handle, bmp384_fifo_data_source_t source)
set the fifo data source
uint8_t bmp384_get_fifo_length(bmp384_handle_t *handle, uint16_t *length)
get the fifo length
uint8_t bmp384_set_fifo_stop_on_full(bmp384_handle_t *handle, bmp384_bool_t enable)
enable or disable the fifo stopping on full
uint8_t bmp384_set_fifo_sensortime_on(bmp384_handle_t *handle, bmp384_bool_t enable)
enable or disable the fifo sensor time on
uint8_t bmp384_get_fifo_temperature_on(bmp384_handle_t *handle, bmp384_bool_t *enable)
get the fifo temperature on status
uint8_t bmp384_read_fifo(bmp384_handle_t *handle, uint8_t *buf, uint16_t *len)
read the fifo
uint8_t bmp384_set_fifo(bmp384_handle_t *handle, bmp384_bool_t enable)
enable or disable the fifo
uint8_t bmp384_get_fifo(bmp384_handle_t *handle, bmp384_bool_t *enable)
get the fifo status
uint8_t bmp384_get_fifo_stop_on_full(bmp384_handle_t *handle, bmp384_bool_t *enable)
get the fifo stopping on full status
uint8_t bmp384_get_fifo_sensortime_on(bmp384_handle_t *handle, bmp384_bool_t *enable)
get the fifo sensor time on status
uint8_t bmp384_flush_fifo(bmp384_handle_t *handle)
flush the fifo
uint8_t bmp384_set_fifo_temperature_on(bmp384_handle_t *handle, bmp384_bool_t enable)
enable or disable the fifo temperature on
uint8_t bmp384_get_fifo_data_source(bmp384_handle_t *handle, bmp384_fifo_data_source_t *source)
get the fifo data source
uint8_t bmp384_get_fifo_watermark(bmp384_handle_t *handle, uint16_t *watermark)
get the fifo watermark
uint8_t bmp384_set_fifo_watermark(bmp384_handle_t *handle, uint16_t watermark)
set the fifo watermark
uint8_t bmp384_get_fifo_data(bmp384_handle_t *handle, uint8_t *data, uint16_t length)
get the fifo data
uint8_t bmp384_set_fifo_subsampling(bmp384_handle_t *handle, uint8_t subsample)
set the fifo subsampling
uint8_t bmp384_get_fifo_subsampling(bmp384_handle_t *handle, uint8_t *subsample)
get the fifo subsampling
uint8_t bmp384_set_interrupt_pin_type(bmp384_handle_t *handle, bmp384_interrupt_pin_type_t pin_type)
set the interrupt pin type
uint8_t bmp384_get_interrupt_active_level(bmp384_handle_t *handle, bmp384_interrupt_active_level_t *level)
get the interrupt active level
uint8_t bmp384_set_interrupt_active_level(bmp384_handle_t *handle, bmp384_interrupt_active_level_t level)
set the interrupt active level
uint8_t bmp384_get_interrupt_fifo_full(bmp384_handle_t *handle, bmp384_bool_t *enable)
get the interrupt fifo full
uint8_t bmp384_get_interrupt_status(bmp384_handle_t *handle, uint8_t *status)
get the interrupt status
uint8_t bmp384_set_interrupt_data_ready(bmp384_handle_t *handle, bmp384_bool_t enable)
enable or disable the data ready interrupt
uint8_t bmp384_get_interrupt_pin_type(bmp384_handle_t *handle, bmp384_interrupt_pin_type_t *pin_type)
get the interrupt pin type
uint8_t bmp384_get_interrupt_fifo_watermark(bmp384_handle_t *handle, bmp384_bool_t *enable)
get the interrupt fifo watermark
uint8_t bmp384_set_interrupt_fifo_full(bmp384_handle_t *handle, bmp384_bool_t enable)
enable or disable the fifo full interrupt
uint8_t bmp384_get_latch_interrupt_pin_and_interrupt_status(bmp384_handle_t *handle, bmp384_bool_t *enable)
get latching interrupt pin and interrupt status
uint8_t bmp384_set_interrupt_fifo_watermark(bmp384_handle_t *handle, bmp384_bool_t enable)
enable or disable the fifo watermark interrupt
uint8_t bmp384_set_latch_interrupt_pin_and_interrupt_status(bmp384_handle_t *handle, bmp384_bool_t enable)
enable or disable latching interrupt pin and interrupt status
uint8_t bmp384_get_interrupt_data_ready(bmp384_handle_t *handle, bmp384_bool_t *enable)
get the interrupt data ready status
bmp384 frame structure definition
bmp384_frame_type_t type
bmp384 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)
bmp384 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]