nrfcxx  0.1.0
C++-17 Framework for Nordic nRF5 Devices
Data Structures | Public Types | Public Member Functions | Static Public Attributes
nrfcxx::sensor::lps22hb Class Reference

Interface to the ST LPS22HB piezzoresistave absolute pressure sensor. More...

#include <nrfcxx/sensor/lps22hb.hpp>

Inheritance diagram for nrfcxx::sensor::lps22hb:
nrfcxx::lpm::lpsm_capable

Data Structures

struct  iface_config_type
 Information required to communicate with a sensor instance. More...
 
struct  observations_type
 Structure used to return sampled values. More...
 

Public Types

enum  STATUS_REG_e : uint8_t { SR_P_DA = 0x01, SR_T_DA = 0x02, SR_READY = (SR_P_DA | SR_T_DA) }
 Bit fields in the LPS22HB STATUS_REG register. More...
 
enum  ODR_e : uint8_t {
  ODR_OneShot = 0x00, ODR_1_Hz = 0x01, ODR_10_Hz = 0x02, ODR_25_Hz = 0x03,
  ODR_50_Hz = 0x04, ODR_75_Hz = 0x05
}
 Bit field values in CTRL_REG1 for observation data rate. More...
 

Public Member Functions

const iface_config_typeiface_config () const
 Access the interface configuration for the sensor.
 
int status () const
 Return the value of the STATUS register.
 
const observations_typeobservations () const
 Access the most recent completed observation.
 
uint8_t odr () const
 Retrieve the configured output data rate. More...
 
int odr (uint8_t dr)
 Set the output data rate. More...
 
 lps22hb (notifier_type notify, iface_config_type &ifc, unsigned int addr=0)
 Instantiate the device. More...
 
bool drdy_asserted () const
 Programmatic test for whether DRDY is asserted.
 
int lpsm_sample () override
 Post-extend to signal machine if start failed due to undetected drdy.
 
uint16_t lost_drdy () const
 Count of the number of times a DRDY signal was detected to be lost.
 
- Public Member Functions inherited from nrfcxx::lpm::lpsm_capable
virtual int lpsm_start ()
 Validate and prepare to initiate an LPM collection. More...
 
lpm::state_machine::process_flags_type lpsm_process ()
 Make progress on an LPM collection. More...
 
int lpsm_stop ()
 
int lpsm_reset ()
 
int lpsm_process_rc () const
 Get the internal result code from the last invocation of lpsm_process_(). More...
 
const lpm::state_machinemachine () const
 Gain read-only access to the LPM machine state.
 

Static Public Attributes

static constexpr uint16_t INVALID_TEMPHUMID = 30000
 Value used for invalid temperature and humidity observations.
 
static constexpr unsigned int INVALID_PRESSURE = 0x00C00000
 Value used for invalid pressure observations. More...
 
static constexpr auto ODR_DEFAULT = ODR_1_Hz
 The default output data rate.
 

Additional Inherited Members

- Protected Types inherited from nrfcxx::lpm::lpsm_capable
using state_type = state_machine::state_type
 
using process_flags_type = state_machine::process_flags_type
 
- Protected Member Functions inherited from nrfcxx::lpm::lpsm_capable
 lpsm_capable (notifier_type notify)
 Create a state machine that records state and supports delayed transitions. More...
 
virtual int lpsm_process_ (int &delay, process_flags_type &pf)
 Override to implement machine-specific operations of lpsm_process(). More...
 
virtual void lpsm_reset_ ()
 Override to reset state that is held outside the machine.
 
- Protected Attributes inherited from nrfcxx::lpm::lpsm_capable
state_machine machine_
 

Detailed Description

Interface to the ST LPS22HB piezzoresistave absolute pressure sensor.

Note
The application infrastructure support described in GPIOTE::irq_handler must be provided when using lps22hb, and the following put in the main routine after the lps22hb instance has been constructed:
NVIC_EnableIRQ(GPIOTE_IRQn);
periph::GPIOTE::enable_sense();

lpm::lpsm_capable::lpsm_process() for this sensor returns the following flags in addition to the diagnostic flags:

Member Enumeration Documentation

◆ ODR_e

Bit field values in CTRL_REG1 for observation data rate.

These may be configured using odr() when the LPM machine is off.

Enumerator
ODR_OneShot 

On-demand observations.

Invoke lpsm_start() to initiate an observation.

ODR_1_Hz 

Observations generated at 1 Hz.

ODR_10_Hz 

Observations generated at 10 Hz.

ODR_25_Hz 

Observations generated at 25 Hz.

ODR_50_Hz 

Observations generated at 50 Hz.

ODR_75_Hz 

Observations generated at 75 Hz.

◆ STATUS_REG_e

Bit fields in the LPS22HB STATUS_REG register.

Enumerator
SR_P_DA 

Bit set to indicate that new pressure data is available.

SR_T_DA 

Bit set to indicate that new temperature data is available.

SR_READY 

Value when all expected data is available.

Constructor & Destructor Documentation

◆ lps22hb()

nrfcxx::sensor::lps22hb::lps22hb ( notifier_type  notify,
iface_config_type ifc,
unsigned int  addr = 0 
)

Instantiate the device.

Parameters
notifythe mechanism by which the instance notifies the application that lpsm_process() should be invoked.
ifcreference to an externally owned struct providing the resources required to communicate with the device.
addrthe device address as controlled by the SA0 signal, value in the range 0 through 1.

Member Function Documentation

◆ odr() [1/2]

uint8_t nrfcxx::sensor::lps22hb::odr ( ) const
inline

Retrieve the configured output data rate.

Returns
a value from ODR_e.
See also
ODR_DEFAULT

◆ odr() [2/2]

int nrfcxx::sensor::lps22hb::odr ( uint8_t  dr)

Set the output data rate.

Note
This function will error if invoked while the LPM infrastructure is running.
Returns
non-negative on success, or a negative error code.

Field Documentation

◆ INVALID_PRESSURE

constexpr unsigned int nrfcxx::sensor::lps22hb::INVALID_PRESSURE = 0x00C00000
staticconstexpr

Value used for invalid pressure observations.

This is sized to fit in a 24-bit unsigned integer, with a maximum representable value of 1258.2911 hPa.


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