Skip to content

Class daisy::Dps310

template <typename Transport>

ClassList > daisy > Dps310

Device support for DPS310 Barometric Pressure and Altitude Sensor. More...

  • #include <dps310.h>

Classes

Type Name
struct Config

Public Types

Type Name
enum Result
enum dps310_mode_t
enum dps310_oversample_t
enum dps310_rate_t

Public Attributes

Type Name
int32_t oversample_scalefactor = {524288, 1572864, 3670016, 7864320, 253952, 516096, 1040384, 2088960}

Public Functions

Type Name
Dps310 ()
float GetAltitude (float seaLevelhPa)
float GetPressure ()
float GetTemperature ()
Result GetTransportError ()
Result Init (Config config)
void Process (void)
uint16_t Read16 (uint8_t reg)
uint16_t Read16_LE (uint8_t reg)
uint32_t Read24 (uint8_t reg)
uint8_t Read8 (uint8_t reg)
uint8_t ReadBits (uint8_t reg, uint8_t bits, uint8_t shift)
void ReadReg (uint8_t reg, uint8_t * buff, uint8_t size)
int16_t ReadS16 (uint8_t reg)
int16_t ReadS16_LE (uint8_t reg)
void Write8 (uint8_t reg, uint8_t value)
void WriteBits (uint8_t reg, uint8_t data, uint8_t bits, uint8_t shift)
void _readCalibration (void)
void configurePressure (dps310_rate_t rate, dps310_oversample_t os)
void configureTemperature (dps310_rate_t rate, dps310_oversample_t os)
bool pressureAvailable (void)
void reset (void)
void setMode (dps310_mode_t mode)
bool temperatureAvailable (void)
~Dps310 ()

Public Static Functions

Type Name
int32_t twosComplement (int32_t val, uint8_t bits)

Detailed Description

Author:

beserge

Date:

January 2022

Public Types Documentation

enum Result

enum daisy::Dps310::Result {
    OK = 0,
    ERR
};

enum dps310_mode_t

enum daisy::Dps310::dps310_mode_t {
    DPS310_IDLE = 0b000,
    DPS310_ONE_PRESSURE = 0b001,
    DPS310_ONE_TEMPERATURE = 0b010,
    DPS310_CONT_PRESSURE = 0b101,
    DPS310_CONT_TEMP = 0b110,
    DPS310_CONT_PRESTEMP = 0b111
};

The oversample rate ranges


enum dps310_oversample_t

enum daisy::Dps310::dps310_oversample_t {
    DPS310_1SAMPLE,
    DPS310_2SAMPLES,
    DPS310_4SAMPLES,
    DPS310_8SAMPLES,
    DPS310_16SAMPLES,
    DPS310_32SAMPLES,
    DPS310_64SAMPLES,
    DPS310_128SAMPLES
};

The oversample rate ranges


enum dps310_rate_t

enum daisy::Dps310::dps310_rate_t {
    DPS310_1HZ,
    DPS310_2HZ,
    DPS310_4HZ,
    DPS310_8HZ,
    DPS310_16HZ,
    DPS310_32HZ,
    DPS310_64HZ,
    DPS310_128HZ
};

The measurement rate ranges


Public Attributes Documentation

variable oversample_scalefactor

int32_t daisy::Dps310< Transport >::oversample_scalefactor[8];

Public Functions Documentation

function Dps310

inline daisy::Dps310::Dps310 () 

function GetAltitude

inline float daisy::Dps310::GetAltitude (
    float seaLevelhPa
) 

Calculates the approximate altitude using barometric pressure and the supplied sea level hPa as a reference.

Parameters:

  • seaLevelhPa The current hPa at sea level.

Returns:

The approximate altitude above sea level in meters.


function GetPressure

inline float daisy::Dps310::GetPressure () 

Get the last pressure reading

Returns:

Pressure in hPa


function GetTemperature

inline float daisy::Dps310::GetTemperature () 

Get last temperature reading

Returns:

temp in degrees Centigrade


function GetTransportError

inline Result daisy::Dps310::GetTransportError () 

Get and reset the transport error flag

Returns:

Whether the transport has errored since the last check


function Init

inline Result daisy::Dps310::Init (
    Config config
) 

Initialize the Dps310 device

Parameters:

  • config Configuration settings

function Process

inline void daisy::Dps310::Process (
    void
) 

Read the XYZ data from the sensor and store in the internal raw_pressure, raw_temperature, _pressure and _temperature variables.


function Read16

inline uint16_t daisy::Dps310::Read16 (
    uint8_t reg
) 

Reads a 16 bit value over I2C or SPI

Parameters:

  • reg the register address to read from

Returns:

the 16 bit data value read from the device


function Read16_LE

inline uint16_t daisy::Dps310::Read16_LE (
    uint8_t reg
) 

Reads a signed 16 bit little endian value over I2C or SPI

Parameters:

  • reg the register address to read from

Returns:

the 16 bit data value read from the device


function Read24

inline uint32_t daisy::Dps310::Read24 (
    uint8_t reg
) 

Reads a 24 bit value

Parameters:

  • reg the register address to read from

Returns:

the 24 bit data value read from the device


function Read8

inline uint8_t daisy::Dps310::Read8 (
    uint8_t reg
) 

Reads an 8 bit value

Parameters:

  • reg the register address to read from

Returns:

the data uint8_t read from the device


function ReadBits

inline uint8_t daisy::Dps310::ReadBits (
    uint8_t reg,
    uint8_t bits,
    uint8_t shift
) 

function ReadReg

inline void daisy::Dps310::ReadReg (
    uint8_t reg,
    uint8_t * buff,
    uint8_t size
) 

Read from a reg address a defined number of bytes


function ReadS16

inline int16_t daisy::Dps310::ReadS16 (
    uint8_t reg
) 

Reads a signed 16 bit value over I2C or SPI

Parameters:

  • reg the register address to read from

Returns:

the 16 bit data value read from the device


function ReadS16_LE

inline int16_t daisy::Dps310::ReadS16_LE (
    uint8_t reg
) 

Reads a signed little endian 16 bit value over I2C or SPI

Parameters:

  • reg the register address to read from

Returns:

the 16 bit data value read from the device


function Write8

inline void daisy::Dps310::Write8 (
    uint8_t reg,
    uint8_t value
) 

Writes an 8 bit value

Parameters:

  • reg the register address to write to
  • value the value to write to the register

function WriteBits

inline void daisy::Dps310::WriteBits (
    uint8_t reg,
    uint8_t data,
    uint8_t bits,
    uint8_t shift
) 

function _readCalibration

inline void daisy::Dps310::_readCalibration (
    void
) 

function configurePressure

inline void daisy::Dps310::configurePressure (
    dps310_rate_t rate,
    dps310_oversample_t os
) 

Set the sample rate and oversampling averaging for pressure

Parameters:

  • rate How many samples per second to take
  • os How many oversamples to average

function configureTemperature

inline void daisy::Dps310::configureTemperature (
    dps310_rate_t rate,
    dps310_oversample_t os
) 

Set the sample rate and oversampling averaging for temperature

Parameters:

  • rate How many samples per second to take
  • os How many oversamples to average

function pressureAvailable

inline bool daisy::Dps310::pressureAvailable (
    void
) 

Whether new pressure data is available

Returns:

True if new data available to read


function reset

inline void daisy::Dps310::reset (
    void
) 

Performs a software reset


function setMode

inline void daisy::Dps310::setMode (
    dps310_mode_t mode
) 

Set the operational mode of the sensor (continuous or one-shot)

Parameters:

  • mode can be DPS310_IDLE, one shot: DPS310_ONE_PRESSURE or DPS310_ONE_TEMPERATURE, continuous: DPS310_CONT_PRESSURE, DPS310_CONT_TEMP, DPS310_CONT_PRESTEMP

function temperatureAvailable

inline bool daisy::Dps310::temperatureAvailable (
    void
) 

Whether new temperature data is available

Returns:

True if new data available to read


function ~Dps310

inline daisy::Dps310::~Dps310 () 

Public Static Functions Documentation

function twosComplement

static inline int32_t daisy::Dps310::twosComplement (
    int32_t val,
    uint8_t bits
) 


The documentation for this class was generated from the following file external-docs/libDaisy/src/dev/dps310.h