nrfcxx  0.1.0
C++-17 Framework for Nordic nRF5 Devices
sdp8xx.hpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0 */
2 /* Copyright 2018-2019 Peter A. Bigot */
3 
7 #ifndef NRFCXX_SENSOR_SDP8xx_HPP
8 #define NRFCXX_SENSOR_SDP8xx_HPP
9 #pragma once
10 
11 #include <nrfcxx/clock.hpp>
12 #include <nrfcxx/lpm.hpp>
13 #include <nrfcxx/periph.hpp>
14 
15 namespace nrfcxx {
16 namespace sensor {
17 
33 class sdp8xx : public lpm::lpsm_capable
34 {
35  using super = lpm::lpsm_capable;
36 
37 public:
40  constexpr static unsigned int RESET_DELAY_ms = 2;
41 
44  constexpr static unsigned int SAMPLE_DELAY_ms = 50;
45 
48  constexpr static uint8_t CONFIG_OTPRn = 0x02;
49 
52  constexpr static uint8_t CONFIG_HEATER = 0x04;
53 
56  constexpr static uint8_t CONFIG_EOB = 0x40;
57 
62  constexpr static int INVALID_OBSERVATION = -30000;
63 
66  {
70 
74  };
75 
81  {
84 
89  uint8_t address;
90 
92  iface_config_type (const iface_config_type&) = delete;
93  iface_config_type& operator= (const iface_config_type&) = delete;
95  iface_config_type& operator= (iface_config_type&&) = delete;
97  };
98 
101  {
102  return iface_config_;
103  }
104 
106  sdp8xx (notifier_type notify,
107  iface_config_type& ifc);
108 
109  /* No copying or moving. */
110  sdp8xx (const sdp8xx&) = delete;
111  sdp8xx& operator= (const sdp8xx&) = delete;
112  sdp8xx (sdp8xx&& ) = delete;
113  sdp8xx& operator= (sdp8xx&) = delete;
114 
123  int reset ();
124 
127  static constexpr uint32_t SDP800_500Pa_PN = 0x03020100;
128 
131  static constexpr uint32_t SDP810_500Pa_PN = 0x03020A00;
132 
135  static constexpr uint32_t SDP800_125Pa_PN = 0x03020200;
136 
139  static constexpr uint32_t SDP810_125Pa_PN = 0x03020B00;
140 
149  int read_device_info (uint32_t& product,
150  uint64_t& serial);
151 
155  {
156  return observations_;
157  }
158 
159 private:
160  int lpsm_process_ (int& delay,
161  process_flags_type& pf) override;
162 
163  iface_config_type& iface_config_;
164  observations_type observations_;
165  uint16_t scaleFactor_ = 0;
166 };
167 
168 } // ns sensor
169 } // ns nrfcxx
170 
171 #endif /* NRFCXX_SENSOR_SDP8xx_HPP */
nrfcxx::sensor::sdp8xx
Abstraction around SDP8xx differential pressure sensor.
Definition: sdp8xx.hpp:33
nrfcxx::sensor::sdp8xx::INVALID_OBSERVATION
constexpr static int INVALID_OBSERVATION
Value for observations that are known to be invalid.
Definition: sdp8xx.hpp:62
nrfcxx::sensor::sdp8xx::iface_config_type::twi
periph::TWI & twi
Reference to TWI device used to communicate with sensor.
Definition: sdp8xx.hpp:83
nrfcxx::sensor::sdp8xx::reset
int reset()
Send a soft-reset command to the SDP8xx.
clock.hpp
Core clock-related functionality.
lpm.hpp
Material supporting low-power-mode operations.
nrfcxx::sensor::sdp8xx::CONFIG_EOB
constexpr static uint8_t CONFIG_EOB
Bit set in configure() result indicating Vdd is below 2.25V.
Definition: sdp8xx.hpp:56
nrfcxx::sensor::sdp8xx::SDP810_500Pa_PN
static constexpr uint32_t SDP810_500Pa_PN
Product number matcher for 500 Pa range tube-connection device.
Definition: sdp8xx.hpp:131
nrfcxx::periph::TWI
Wrapper around the nRF51 TWI peripheral.
Definition: periph.hpp:1528
nrfcxx::sensor::sdp8xx::iface_config_type
Information required to communicate with a sensor instance.
Definition: sdp8xx.hpp:80
nrfcxx::sensor::sdp8xx::RESET_DELAY_ms
constexpr static unsigned int RESET_DELAY_ms
The maximum time required by the sensor to stabilize after reset(), in milliseconds.
Definition: sdp8xx.hpp:40
nrfcxx::sensor::sdp8xx::iface_config_type::address
uint8_t address
The I2C address used to communicate with the device.
Definition: sdp8xx.hpp:89
nrfcxx::sensor::sdp8xx::iface_config
const iface_config_type & iface_config() const
Access the interface configuration for the sensor.
Definition: sdp8xx.hpp:100
nrfcxx::sensor::sdp8xx::observations_type::temperature_cCel
int16_t temperature_cCel
A recently retrieved valid temperature_cCel() or INVALID_OBSERVATION.
Definition: sdp8xx.hpp:73
nrfcxx::sensor::sdp8xx::CONFIG_HEATER
constexpr static uint8_t CONFIG_HEATER
Bit set in configure() parameter/result to enable the on-chip heater.
Definition: sdp8xx.hpp:52
nrfcxx::notifier_type
std::function< void()> notifier_type
Type used to hold a notifier.
Definition: core.hpp:514
nrfcxx::sensor::sdp8xx::SDP810_125Pa_PN
static constexpr uint32_t SDP810_125Pa_PN
Product number matcher for 125 Pa range tube-connection device.
Definition: sdp8xx.hpp:139
nrfcxx::lpm::lpsm_capable
Base (or mixin) class for anything that supports a state_machine.
Definition: lpm.hpp:426
nrfcxx::sensor::sdp8xx::observations_type
Storage for cached results.
Definition: sdp8xx.hpp:65
nrfcxx::sensor::sdp8xx::sdp8xx
sdp8xx(notifier_type notify, iface_config_type &ifc)
Construct a sensor interface around a TWI device and events.
nrfcxx::sensor::sdp8xx::SAMPLE_DELAY_ms
constexpr static unsigned int SAMPLE_DELAY_ms
The maximum time required for a one-shot measurement, in milliseconds.
Definition: sdp8xx.hpp:44
nrfcxx::sensor::sdp8xx::CONFIG_OTPRn
constexpr static uint8_t CONFIG_OTPRn
Bit set in configure() parameter/result to disable configuration reset on each measurement.
Definition: sdp8xx.hpp:48
nrfcxx::sensor::sdp8xx::observations
const observations_type & observations() const
Retrieve the most recent observations calculated through the LPM infrastructure.
Definition: sdp8xx.hpp:154
nrfcxx::sensor::sdp8xx::SDP800_500Pa_PN
static constexpr uint32_t SDP800_500Pa_PN
Product number matcher for 500 Pa range manifold-connection device.
Definition: sdp8xx.hpp:127
nrfcxx::sensor::sdp8xx::read_device_info
int read_device_info(uint32_t &product, uint64_t &serial)
Read the device information.
nrfcxx::sensor::sdp8xx::SDP800_125Pa_PN
static constexpr uint32_t SDP800_125Pa_PN
Product number matcher for 125 Pa range manifold-connection device.
Definition: sdp8xx.hpp:135
periph.hpp
Abstraction of Nordic device peripherals.
nrfcxx
Primary namespace for nrfcxx functionality.
Definition: clock.hpp:17
nrfcxx::sensor::sdp8xx::observations_type::diffpres_cPa
int16_t diffpres_cPa
A recently retrieved valid diffpres_cPa() or INVALID_OBSERVATION.
Definition: sdp8xx.hpp:69