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

Interface to the ST HTS221 capacitive digital sensor for relative humidity and temperature. More...

#include <nrfcxx/sensor/hts221.hpp>

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

Data Structures

struct  calibration_type
 Structure for calibration information. More...
 
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_T_DA = 0x01, SR_H_DA = 0x02, SR_READY = (SR_T_DA | SR_H_DA) }
 Bit fields in the HTS221 STATUS_REG register. More...
 
enum  ODR_e : uint8_t { ODR_OneShot = 0x00, ODR_1_Hz = 0x01, ODR_7_Hz = 0x02, ODR_12p5_Hz = 0x03 }
 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.
 
const calibration_typecalibration () const
 Access the calibration constants. More...
 
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...
 
 hts221 (notifier_type notify, iface_config_type &ifc)
 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_OBSERVATION = 30000
 Value used to indicate that observations are not valid.
 
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 HTS221 capacitive digital sensor for relative humidity and temperature.

Note
The application infrastructure support described in GPIOTE::irq_handler must be provided when using hts221, and the following put in the main routine after the hts221 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_7_Hz 

Observations generated at 7 Hz.

ODR_12p5_Hz 

Observations generated at 12.5 Hz.

◆ STATUS_REG_e

Bit fields in the HTS221 STATUS_REG register.

Enumerator
SR_T_DA 

Bit set to indicate that new temperature data is available.

SR_H_DA 

Bit set to indicate that new humidity data is available.

SR_READY 

Value when all expected data is available.

Constructor & Destructor Documentation

◆ hts221()

nrfcxx::sensor::hts221::hts221 ( notifier_type  notify,
iface_config_type ifc 
)

Instantiate the device.

Parameters
ifcreference to an externally owned struct providing the resources required to communicate with the device.
notifythe mechanism by which the instance notifies the application that lpsm_process() should be invoked.

Member Function Documentation

◆ calibration()

const calibration_type& nrfcxx::sensor::hts221::calibration ( ) const
inline

Access the calibration constants.

This is useful for diagnostics.

◆ odr() [1/2]

uint8_t nrfcxx::sensor::hts221::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::hts221::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.

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