Started reorganizing the code. Put everything existing to OLD and began with a new main.cppy
This commit is contained in:
@@ -0,0 +1,168 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
/// \file bme280.h
|
||||
/// \brief File description
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// vbchaos software design
|
||||
//
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
/// $Revision: $
|
||||
/// $Author: $
|
||||
/// $Date: $
|
||||
// (c) 2023 vbchaos
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef MAIN_INC_BMP280_H_
|
||||
#define MAIN_INC_BMP280_H_
|
||||
|
||||
/**
|
||||
* bme280 implementation
|
||||
* \defgroup bme280
|
||||
* \brief {group_description}
|
||||
* \addtogroup {Layer}
|
||||
*
|
||||
* Detailed description
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Include files
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
// CompilerIncludes
|
||||
// All include files that are provided by the compiler directly
|
||||
|
||||
|
||||
|
||||
// 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.
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
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);
|
||||
|
||||
int getTemperature(void);
|
||||
|
||||
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 t_sb: 3;
|
||||
uint8_t filter: 3;
|
||||
uint8_t unused: 1;
|
||||
uint8_t spi3w_en: 1;
|
||||
} config;
|
||||
struct
|
||||
{
|
||||
uint8_t mode : 2;
|
||||
uint8_t oversampling_pressure : 3;
|
||||
uint8_t oversampling_temp : 3;
|
||||
} 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 setSensorControlMeasurement(void);
|
||||
void setSensorConfiguration(void);
|
||||
|
||||
void getCompensationValues(void);
|
||||
|
||||
void compensateTemperature(void);
|
||||
|
||||
void getPreasureValues(void);
|
||||
void getTemperatureValues(void);
|
||||
|
||||
};
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif /* MAIN_INC_BMP280_H_ */
|
||||
Reference in New Issue
Block a user