Added basic bmp280 structure - functional
temperature readout must be added and compensation must be checked
This commit is contained in:
+87
-1
@@ -39,12 +39,14 @@
|
||||
|
||||
// ProjectIncludes
|
||||
// All include files that are provided by the project
|
||||
#include "i2c.h"
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#define BMP280_DEVICE_ID ((uint8_t)0x58)
|
||||
#define BMP280_RESET_VALUE ((uint8_t)0xB6)
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Type definitions.
|
||||
@@ -59,9 +61,93 @@
|
||||
class BMP280
|
||||
{
|
||||
public:
|
||||
BMP280(I2C* bus, uint8_t slaveAddress);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
STANDBY = 0,
|
||||
FORCED = 1,
|
||||
NORMAL = 3
|
||||
} BMP280_Mode_t;
|
||||
typedef enum
|
||||
{
|
||||
SKIPPED = 0,
|
||||
X1 = 1,
|
||||
X2 = 2,
|
||||
X4 = 3,
|
||||
X8 = 4,
|
||||
X16 = 5
|
||||
} BMP280_Oversampling_t;
|
||||
|
||||
void resetSensor(void);
|
||||
bool initialize(void);
|
||||
bool setSensorMode(BMP280_Mode_t mode);
|
||||
bool setSensorTemperatureOversampling(BMP280_Oversampling_t oversampling);
|
||||
|
||||
private:
|
||||
|
||||
struct CompensationParameters
|
||||
{
|
||||
// Temperature compensation parameters
|
||||
uint16_t dig_T1;
|
||||
int16_t dig_T2;
|
||||
int16_t dig_T3;
|
||||
// Pressure compensation parameters
|
||||
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;
|
||||
} compensationParameters;
|
||||
|
||||
struct memorymap
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint8_t msb;
|
||||
uint8_t lsb;
|
||||
uint8_t xlsb;
|
||||
} temperature_raw;
|
||||
struct
|
||||
{
|
||||
uint8_t msb;
|
||||
uint8_t lsb;
|
||||
uint8_t xlsb;
|
||||
} pressure_raw;
|
||||
struct
|
||||
{
|
||||
uint8_t mode : 2;
|
||||
uint8_t oversampling_pressure : 3;
|
||||
uint8_t oversampling_temp : 3;
|
||||
} config;
|
||||
uint8_t ctrl_meas;
|
||||
uint8_t status;
|
||||
uint8_t reset;
|
||||
uint8_t id;
|
||||
} memorymap;
|
||||
|
||||
int t_fine;
|
||||
int temperature;
|
||||
|
||||
I2C* bus;
|
||||
uint8_t slaveAddress;
|
||||
BMP280_Mode_t mode;
|
||||
|
||||
void resetDriver(void);
|
||||
|
||||
// Communication with Device
|
||||
void resetDevice(void);
|
||||
void getDeviceID(void);
|
||||
void setSensorConfiguration(void);
|
||||
|
||||
void getCompensationValues(void);
|
||||
|
||||
void compensateTemperature(void);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user