Skyward boardcore
Loading...
Searching...
No Matches
Boardcore::BMP280 Class Reference

#include <BMP280.h>

Inheritance diagram for Boardcore::BMP280:
Collaboration diagram for Boardcore::BMP280:

Classes

union  BMP280Comp
 
union  BMP280Config
 

Public Types

enum  Oversampling {
  SKIPPED = 0x0 , OVERSAMPLING_1 = 0x1 , OVERSAMPLING_2 = 0x2 , OVERSAMPLING_4 = 0x3 ,
  OVERSAMPLING_8 = 0x4 , OVERSAMPLING_16 = 0x5
}
 
enum  Mode { SLEEP_MODE = 0x0 , FORCED_MODE = 0x1 , NORMAL_MODE = 0x3 }
 
enum  StandbyTime {
  STB_TIME_0_5 = 0x0 , STB_TIME_62_5 = 0x1 , STB_TIME_125 = 0x2 , STB_TIME_250 = 0x3 ,
  STB_TIME_500 = 0x4 , STB_TIME_1000 = 0x5 , STB_TIME_20 = 0x6 , STB_TIME_40 = 0x7
}
 
enum  FilterCoeff {
  FILTER_OFF = 0x0 , FILTER_COEFF_2 = 0x1 , FILTER_COEFF_4 = 0x2 , FILTER_COEFF_8 = 0x3 ,
  FILTER_COEFF_16 = 0x4
}
 
- Public Types inherited from Boardcore::Sensor< BMP280Data >
using DataType
 

Public Member Functions

 BMP280 (SPISlave spiSlave, BMP280Config config=BMP280_CONFIG_ALL_ENABLED)
 
bool init () override
 Initialize the device with the specified configuration.
 
void setSensorMode (Mode mode)
 Sets the sensor mode.
 
void setPressureOversampling (Oversampling oversampling)
 Sets the oversampling for pressure readings, use SKIPPED to disable pressure sampling.
 
void setTemperatureOversampling (Oversampling oversampling)
 Sets the oversampling for temperature readings, use SKIPPED to disable temperature sampling.
 
void setFilterCoeff (FilterCoeff filterCoeff)
 Sets the coefficient for the IIR filter (applied to temperature and pressure)
 
void setStandbyTime (StandbyTime standbyTime)
 Sets the standby time between readings in normal mode.
 
PressureData readPressure ()
 Reads only the pressure, does not set the configuration.
 
TemperatureData readTemperature ()
 Reads only the temperature, does not set the configuration.
 
unsigned int getMaxMeasurementTime ()
 
bool selfTest () override
 Reads the WHO AM I register.
 
- Public Member Functions inherited from Boardcore::Sensor< BMP280Data >
 Sensor ()
 
 Sensor (Sensor &&other)
 
virtual ~Sensor ()
 
void sample () override
 Sample the sensor.
 
virtual BMP280Data getLastSample ()
 
- Public Member Functions inherited from Boardcore::AbstractSensor
virtual ~AbstractSensor ()
 
SensorErrors getLastError ()
 Get last error for debugging purposes. Avoid silent fails.
 

Static Public Member Functions

static unsigned int calculateMaxMeasurementTime (BMP280Config config)
 Maximum measurement time formula from datasheet page 51.
 

Static Public Attributes

static constexpr uint8_t REG_ID_VAL = 0x58
 Who am I value.
 
static const BMP280Config BMP280_DEFAULT_CONFIG
 Datasheet values for indoor navigation.
 
static const BMP280Config BMP280_CONFIG_ALL_ENABLED
 Temperature enabled in forced mode.
 
static const BMP280Config BMP280_CONFIG_TEMP_SINGLE
 

Protected Member Functions

BMP280Data sampleImpl () override
 Read a data sample from the sensor. In case of errors, the method should return the last available correct sample.
 

Additional Inherited Members

- Protected Attributes inherited from Boardcore::Sensor< BMP280Data >
DataType lastSample
 
miosix::FastMutex mutex
 
- Protected Attributes inherited from Boardcore::AbstractSensor
SensorErrors lastError = SensorErrors::NO_ERRORS
 

Detailed Description

Definition at line 34 of file BMP280.h.

Member Enumeration Documentation

◆ FilterCoeff

Enumerator
FILTER_OFF 

Filter off.

FILTER_COEFF_2 

Filter coefficient = 2.

FILTER_COEFF_4 

Filter coefficient = 4.

FILTER_COEFF_8 

Filter coefficient = 8.

FILTER_COEFF_16 

Filter coefficient = 16.

Definition at line 66 of file BMP280.h.

◆ Mode

Enumerator
SLEEP_MODE 

Sleep mode.

FORCED_MODE 

Forced mode.

NORMAL_MODE 

Normal mode.

Definition at line 47 of file BMP280.h.

◆ Oversampling

Enumerator
SKIPPED 

Skipped (output set to 0x8000)

OVERSAMPLING_1 

Oversampling x1.

OVERSAMPLING_2 

Oversampling x2.

OVERSAMPLING_4 

Oversampling x4.

OVERSAMPLING_8 

Oversampling x8.

OVERSAMPLING_16 

Oversampling x16.

Definition at line 37 of file BMP280.h.

◆ StandbyTime

Enumerator
STB_TIME_0_5 

0.5 ms

STB_TIME_62_5 

62.5 ms

STB_TIME_125 

125 ms

STB_TIME_250 

250 ms

STB_TIME_500 

500 ms

STB_TIME_1000 

1000 ms

STB_TIME_20 

20 ms

STB_TIME_40 

40 ms

Definition at line 54 of file BMP280.h.

Constructor & Destructor Documentation

◆ BMP280()

Boardcore::BMP280::BMP280 ( SPISlave spiSlave,
BMP280Config config = BMP280_CONFIG_ALL_ENABLED )
explicit

Definition at line 48 of file BMP280.cpp.

Member Function Documentation

◆ calculateMaxMeasurementTime()

unsigned int Boardcore::BMP280::calculateMaxMeasurementTime ( BMP280Config config)
static

Maximum measurement time formula from datasheet page 51.

Returns
Time in milliseconds

Definition at line 174 of file BMP280.cpp.

◆ getMaxMeasurementTime()

unsigned int Boardcore::BMP280::getMaxMeasurementTime ( )

Definition at line 182 of file BMP280.cpp.

◆ init()

bool Boardcore::BMP280::init ( )
overridevirtual

Initialize the device with the specified configuration.

Implements Boardcore::AbstractSensor.

Definition at line 53 of file BMP280.cpp.

◆ readPressure()

PressureData Boardcore::BMP280::readPressure ( )

Reads only the pressure, does not set the configuration.

Definition at line 128 of file BMP280.cpp.

◆ readTemperature()

TemperatureData Boardcore::BMP280::readTemperature ( )

Reads only the temperature, does not set the configuration.

Definition at line 150 of file BMP280.cpp.

◆ sampleImpl()

BMP280Data Boardcore::BMP280::sampleImpl ( )
overrideprotectedvirtual

Read a data sample from the sensor. In case of errors, the method should return the last available correct sample.

Returns
sensor data sample

Implements Boardcore::Sensor< BMP280Data >.

Definition at line 189 of file BMP280.cpp.

◆ selfTest()

bool Boardcore::BMP280::selfTest ( )
overridevirtual

Reads the WHO AM I register.

Returns
True if everything ok

Implements Boardcore::AbstractSensor.

Definition at line 187 of file BMP280.cpp.

◆ setFilterCoeff()

void Boardcore::BMP280::setFilterCoeff ( FilterCoeff filterCoeff)

Sets the coefficient for the IIR filter (applied to temperature and pressure)

Definition at line 114 of file BMP280.cpp.

◆ setPressureOversampling()

void Boardcore::BMP280::setPressureOversampling ( Oversampling oversampling)

Sets the oversampling for pressure readings, use SKIPPED to disable pressure sampling.

Definition at line 100 of file BMP280.cpp.

◆ setSensorMode()

void Boardcore::BMP280::setSensorMode ( Mode mode)

Sets the sensor mode.

Values:

  • SLEEP_MODE: No measurements are performed
  • FORCED_MODE: A single measurement is performed when this function writes the configuration, after the measurement the sensor return to sleep mode
  • NORMAL_MODE: Automated cycling between measurements, standby time can be set using setStandbyTime()

Definition at line 93 of file BMP280.cpp.

◆ setStandbyTime()

void Boardcore::BMP280::setStandbyTime ( StandbyTime standbyTime)

Sets the standby time between readings in normal mode.

Definition at line 121 of file BMP280.cpp.

◆ setTemperatureOversampling()

void Boardcore::BMP280::setTemperatureOversampling ( Oversampling oversampling)

Sets the oversampling for temperature readings, use SKIPPED to disable temperature sampling.

Definition at line 107 of file BMP280.cpp.

Member Data Documentation

◆ BMP280_CONFIG_ALL_ENABLED

const BMP280::BMP280Config Boardcore::BMP280::BMP280_CONFIG_ALL_ENABLED
static
Initial value:
= {0,
0,
0,
@ STB_TIME_0_5
0.5 ms
Definition BMP280.h:56
@ FILTER_COEFF_16
Filter coefficient = 16.
Definition BMP280.h:72
@ NORMAL_MODE
Normal mode.
Definition BMP280.h:51
@ OVERSAMPLING_16
Oversampling x16.
Definition BMP280.h:44
@ OVERSAMPLING_2
Oversampling x2.
Definition BMP280.h:41

Temperature enabled in forced mode.

Definition at line 144 of file BMP280.h.

◆ BMP280_CONFIG_TEMP_SINGLE

const BMP280::BMP280Config Boardcore::BMP280::BMP280_CONFIG_TEMP_SINGLE
static
Initial value:
= {
@ FILTER_OFF
Filter off.
Definition BMP280.h:68
@ FORCED_MODE
Forced mode.
Definition BMP280.h:50
@ OVERSAMPLING_1
Oversampling x1.
Definition BMP280.h:40
@ SKIPPED
Skipped (output set to 0x8000)
Definition BMP280.h:39

Definition at line 147 of file BMP280.h.

◆ BMP280_DEFAULT_CONFIG

const BMP280::BMP280Config Boardcore::BMP280::BMP280_DEFAULT_CONFIG
static
Initial value:
= {
@ SLEEP_MODE
Sleep mode.
Definition BMP280.h:49

Datasheet values for indoor navigation.

Definition at line 141 of file BMP280.h.

◆ REG_ID_VAL

constexpr uint8_t Boardcore::BMP280::REG_ID_VAL = 0x58
staticconstexpr

Who am I value.

Default register values

Definition at line 138 of file BMP280.h.


The documentation for this class was generated from the following files: