66 lines
1.4 KiB
C
66 lines
1.4 KiB
C
|
#ifndef __BME280_H__
|
||
|
#define __BME280_H__
|
||
|
|
||
|
// Einfach mal wieder was in C schreinben oder so
|
||
|
|
||
|
// Use extern C from C++
|
||
|
#ifdef __cplusplus
|
||
|
extern "C" {
|
||
|
#endif
|
||
|
|
||
|
#include "hardware/i2c.h"
|
||
|
|
||
|
#ifndef BME280_ADDR
|
||
|
#define BME280_ADDR 0x76
|
||
|
#endif
|
||
|
|
||
|
// Strcut zum speichern aller kallibrierungsdaten
|
||
|
typedef struct __bme280_callib {
|
||
|
// Temp
|
||
|
uint16_t dig_T1;
|
||
|
int16_t dig_T2;
|
||
|
int16_t dig_T3;
|
||
|
// Luftdruck ??
|
||
|
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;
|
||
|
// Luftfeuchtigkeit
|
||
|
uint8_t dig_H1;
|
||
|
int16_t dig_H2;
|
||
|
uint8_t dig_H3;
|
||
|
int16_t dig_H4;
|
||
|
int16_t dig_H5;
|
||
|
int8_t dig_H6;
|
||
|
} bme280_callib;
|
||
|
|
||
|
// Usally the way how devkitpro members declare
|
||
|
// structs in C
|
||
|
typedef struct bme280_ctx_s {
|
||
|
// Functions
|
||
|
void (*update)(struct bme280_ctx_s* self);
|
||
|
float (*read_temp)(struct bme280_ctx_s* self);
|
||
|
float (*read_humidity)(struct bme280_ctx_s* self);
|
||
|
float (*read_pressure)(struct bme280_ctx_s* self);
|
||
|
/// Nur für bme280.c lesbar
|
||
|
bme280_callib callib;
|
||
|
int32_t raw_temperature;
|
||
|
int32_t raw_humidity;
|
||
|
int32_t raw_pressure;
|
||
|
int32_t t_fine;
|
||
|
i2c_inst_t* i2c;
|
||
|
} bme280_ctx;
|
||
|
|
||
|
// Base functions
|
||
|
bme280_ctx* bme280_init(i2c_inst_t* i2c, uint sda, uint scl);
|
||
|
void bme280_deinit(bme280_ctx* ctx);
|
||
|
|
||
|
#ifdef __cplusplus
|
||
|
}
|
||
|
#endif
|
||
|
#endif
|