98 lines
2.3 KiB
C
98 lines
2.3 KiB
C
#ifndef ims_bme280_DHT_H
|
|
#define ims_bme280_DHT_H
|
|
|
|
#include "imsensors/sensors_common.h"
|
|
|
|
typedef enum {
|
|
IMS_BME280_MODE_SLEEP,
|
|
IMS_BME280_MODE_FORCED,
|
|
IMS_BME280_MODE_NORMAL,
|
|
} ims_bme280_mode_t;
|
|
|
|
typedef enum {
|
|
IMS_BME280_OSRS_SKIP,
|
|
IMS_BME280_OSRS_1,
|
|
IMS_BME280_OSRS_2,
|
|
IMS_BME280_OSRS_4,
|
|
IMS_BME280_OSRS_8,
|
|
IMS_BME280_OSRS_16,
|
|
} ims_bme280_osrs_config_t;
|
|
|
|
typedef enum {
|
|
IMS_BME280_FILTER_OFF,
|
|
IMS_BME280_FILTER_2,
|
|
IMS_BME280_FILTER_4,
|
|
IMS_BME280_FILTER_8,
|
|
IMS_BME280_FILTER_16,
|
|
} ims_bme280_fiter_config_t;
|
|
|
|
typedef enum {
|
|
IMS_BME280_PRESET_WEATHER,
|
|
IMS_BME280_PRESET_HUMIDITY,
|
|
IMS_BME280_PRESET_INDOOR_NAV,
|
|
IMS_BME280_PRESET_GAMING,
|
|
} ims_bme280_mode_preset_t;
|
|
|
|
typedef struct {
|
|
uint16_t dig_T1;
|
|
int16_t dig_T2;
|
|
int16_t dig_T3;
|
|
uint16_t dig_P1;
|
|
int16_t dig_P2;
|
|
int16_t dig_P3;
|
|
int16_t dig_P4;
|
|
int16_t dig_P5;
|
|
int16_t dig_P6;
|
|
int16_t dig_P7;
|
|
int16_t dig_P8;
|
|
int16_t dig_P9;
|
|
uint8_t dig_H1;
|
|
int16_t dig_H2;
|
|
uint8_t dig_H3;
|
|
int16_t dig_H4;
|
|
int16_t dig_H5;
|
|
int8_t dig_H6;
|
|
} ims_bme280_trim_t;
|
|
|
|
typedef struct {
|
|
ims_bme280_mode_t mode;
|
|
ims_bme280_osrs_config_t osrs_t;
|
|
ims_bme280_osrs_config_t osrs_p;
|
|
ims_bme280_osrs_config_t osrs_h;
|
|
uint8_t t_sb;
|
|
ims_bme280_fiter_config_t filter;
|
|
} ims_bme280_config_t;
|
|
|
|
/* Result is multiplied by 10000. */
|
|
typedef struct {
|
|
int32_t temperature;
|
|
uint32_t pressure;
|
|
int32_t humidity;
|
|
} ims_bme280_result_int32_t;
|
|
|
|
typedef struct {
|
|
double temperature;
|
|
double pressure;
|
|
double humidity;
|
|
} ims_bme280_result_float_t;
|
|
|
|
typedef struct {
|
|
ims_i2c_xfer_t i2c_xfer;
|
|
ims_delay_t delay;
|
|
} ims_bme280_cb_t;
|
|
|
|
typedef struct {
|
|
void *user_data;
|
|
ims_bme280_trim_t trim;
|
|
ims_bme280_cb_t cb;
|
|
uint8_t i2c_addr;
|
|
int32_t t_fine;
|
|
} ims_bme280_t;
|
|
|
|
ims_ret_t ims_bme280_init(ims_bme280_t *bme);
|
|
ims_ret_t ims_bme280_preset_config(ims_bme280_config_t *config, ims_bme280_mode_preset_t preset);
|
|
ims_ret_t ims_bme280_apply_config(ims_bme280_t *bme, ims_bme280_config_t *config);
|
|
ims_ret_t ims_bme280_measure_int32(ims_bme280_t *bme, ims_bme280_result_int32_t *result);
|
|
ims_ret_t ims_bme280_measure_float(ims_bme280_t *bme, ims_bme280_result_float_t *result);
|
|
|
|
#endif |