nrfcxx  0.1.0
C++-17 Framework for Nordic nRF5 Devices
ccs811.hpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0 */
2 /* Copyright 2017-2019 Peter A. Bigot */
3 
8 #ifndef NRFCXX_SENSOR_CCS811_HPP
9 #define NRFCXX_SENSOR_CCS811_HPP
10 #pragma once
11 
12 #include <climits>
13 
14 #include <nrfcxx/gpio.hpp>
15 #include <nrfcxx/lpm.hpp>
16 
17 namespace nrfcxx {
18 namespace sensor {
19 
50 class ccs811 : public lpm::lpsm_capable
51 {
52  using super = lpm::lpsm_capable;
53 
54  // One-shot not available for this sensor.
55  using super::lpsm_sample;
56 
57 public:
59  static constexpr unsigned int APP_START_DELAY_utt = clock::uptime::from_ms(1U);
60 
62  static constexpr unsigned int WAKE_DELAY_us = 50U;
63 
65  static constexpr unsigned int COLD_START_DELAY_utt = clock::uptime::from_ms(20U);
66 
68  static constexpr unsigned int WARM_START_DELAY_utt = clock::uptime::from_ms(2U);
69 
71  static constexpr unsigned int DWAKE_DELAY_us = 20U;
72 
74  static constexpr unsigned int DRESET_DELAY_us = 20U;
75 
77  static constexpr unsigned int RESET_DELAY_us = 15U;
78 
87  static constexpr unsigned int CONDITIONING_DELAY_utt = 20U * 60U * clock::uptime::Frequency_Hz;
88 
90  static constexpr unsigned int BASELINE_CAPTURE_INTERVAL_utt = 24U * 60U * 60U * clock::uptime::Frequency_Hz;
91 
98  {
101 
104 
107 
109  int8_t intn_psel;
110 
112  iface_config_type (const iface_config_type&) = delete;
113  iface_config_type& operator= (const iface_config_type&) = delete;
115  iface_config_type& operator= (iface_config_type&&) = delete;
117  };
118 
121  {
122  return iface_config_;
123  }
124 
131  {
133  using flags_type = uint8_t;
134 
144  uint64_t reset_utt;
145 
151  uint64_t baselined_utt;
152 
160  uint16_t baseline;
161 
164  {
167  FL_REPORTING = 0x01,
168 
177 
183  FL_BASELINED = 0x04,
184 
191 
194  };
195 
209  uint8_t flags;
210  };
211 
215  {
217  uint16_t baseline[4];
218  };
219 
233  int update_persisted (persisted_state_type& ps) const;
234 
252 
255  {
256  return retained_state_;
257  }
258 
265  static void state_setup (const systemState::state_type& ss,
266  bool is_reset,
267  bool retained);
268 
279  ccs811 (notifier_type setter,
280  iface_config_type& ifc,
281  bool addr_sec = false);
282 
285  periph::TWI& twi () const
286  {
287  return iface_config_.twi;
288  }
289 
292  {
293  // ccs811 needs access to construct these things.
294  friend class ccs811;
295 
297  static constexpr uint8_t FL_ENABLE_TWI = 0x01;
298 
300  static constexpr uint8_t FL_ASSERT_WAKEn = 0x02;
301 
303  const gpio::active_low& waken) :
304  twi{twi},
305  waken{waken},
306  flags((twi.enabled() ? 0U : FL_ENABLE_TWI)
307  | (waken.asserted() ? 0U : FL_ASSERT_WAKEn))
308  {
309  if (FL_ENABLE_TWI & flags) {
310  result_ = twi.enable();
311  if (0 <= result_) {
312  result_ = 1;
313  }
314  }
315  // Only assert WAKEn if we don't know that twi enable failed.
316  if ((0 <= result_)
317  && (FL_ASSERT_WAKEn & flags)) {
318  assert();
319  }
320  }
321 
322  periph::TWI& twi;
323  const gpio::active_low& waken;
324  int result_ = 0;
325  const uint8_t flags;
326 
327  public:
328  ~scoped_enabler ()
329  {
330  if (FL_ASSERT_WAKEn & flags) {
331  deassert();
332  }
333  if (FL_ENABLE_TWI & flags) {
334  twi.disable();
335  }
336  }
337 
340  operator bool () const
341  {
342  return 0 <= result_;
343  }
344 
349  int result () const
350  {
351  return result_;
352  }
353 
355  void assert ()
356  {
357  waken.assert();
359  }
360 
362  void deassert ()
363  {
364  waken.deassert();
366  }
367  };
368 
370  bool intn_asserted () const
371  {
372  if (0 > intn_psel_) {
373  return false;
374  }
375  return !((1U << intn_psel_) & nrf5::GPIO->IN);
376  }
377 
398  {
399  return {twi(), waken_};
400  }
401 
403  static constexpr uint8_t HARDWARE_ID = 0x81;
404 
407  struct version_s
408  {
414  uint16_t fw_boot_version;
415 
421  uint16_t fw_app_version;
422 
427  uint8_t hw_id;
428 
433  uint8_t hw_version;
434  };
435 
441  int reset () const;
442 
448  using status_type = uint16_t;
449 
450  enum STATUS_e : uint16_t
451  {
455  ST_ERROR = 0x01,
456 
459 
461  ST_APP_VALID = 0x10,
462 
465 
467  ST_APP_ERASE = 0x40,
468 
471  ST_FW_MODE = 0x80,
472 
475 
478 
482 
485 
487  EI_HEATER_FAULT = 0x1000,
488 
491  };
492 
498  {
501  uint16_t baseline;
502 
504  uint16_t eCO2;
505 
511  uint16_t eTVOC;
512 
520 
523  bool is_ready () const
524  {
525  return (ST_DATA_READY & status);
526  }
527 
529  uint16_t raw;
530  };
531 
537  int id_version (version_s& vid) const;
538 
540  const version_s& id_version() const
541  {
542  return version_;
543  }
544 
547  {
548  return observations_;
549  }
550 
554  {
556  uint32_t active_ds = 0;
557 
561  uint32_t bl_age_ds = 0;
562 
564  uint16_t bl_retained = 0;
565 
567  uint16_t bl_latest = 0;
568 
570  uint16_t app_version = 0;
571 
573  uint8_t hw_version = 0;
574 
576  uint8_t flags = 0;
577 
580  static constexpr size_t SPAN = 4+4+2+2+2+1+1;
581  };
582 
588  int fill_system_beacon (system_beacon_type& fr) const;
589 
597  {
599  uint32_t env_data = -1;
600 
602  uint16_t baseline = 0;
603 
605  uint16_t eCO2 = 0;
606 
608  uint16_t eTVOC = 0;
609 
612  static constexpr size_t SPAN = 4+2+2+2;
613 
624  int16_t status;
625  };
626 
634 
642  struct threshold_s
643  {
645  uint16_t eCO2_ppm = 20;
646 
648  uint16_t eTVOC_ppb = 5;
649 
651  uint8_t temperature_Cel = 1;
652 
655  uint8_t humidity_pph = 2;
656 
671  int env_data_changed (uint32_t ed1,
672  uint32_t ed2) const;
673 
695  const observation_beacon_type& ob2) const;
696  };
697 
699  const lpm::state_machine& machine () const
700  {
701  return machine_;
702  }
703 
710  static constexpr auto PF_REPORTING = lpm::state_machine::PF_APP_BASE << 0;
711 
717  static constexpr auto PF_RESTORED = lpm::state_machine::PF_APP_BASE << 1;
718 
721  static constexpr auto PF_CONDITIONED = lpm::state_machine::PF_APP_BASE << 2;
722 
730  static constexpr auto PF_BASELINED = lpm::state_machine::PF_APP_BASE << 3;
731 
735  static constexpr auto PF_CCS811_ERROR = lpm::state_machine::PF_APP_BASE << 4;
736 
749  static uint32_t encode_env (int16_t temp_cCel,
750  uint16_t rh_pptt);
751 
765  int status () const;
766 
772  int env_data (uint32_t enc);
773 
781  uint32_t env_data () const
782  {
783  return env_data_;
784  }
785 
790  int baseline () const;
791 
798  int baseline (uint16_t value) const;
799 
813  int retain_baseline ();
814 
816  enum DRIVE_MODE_e : uint8_t
817  {
819  DM_IDLE = 0,
821  DM_1_s = 1,
823  DM_10_s = 2,
825  DM_60_s = 3,
826  };
827 
829  static constexpr auto DEFAULT_DRIVE_MODE = DM_10_s;
830 
840  int active_drive_mode () const;
841 
843  int drive_mode () const
844  {
845  return drive_mode_;
846  }
847 
855  int drive_mode (unsigned int dm);
856 
858  unsigned int i2c_address () const
859  {
860  return addr_;
861  }
862 
863 private:
864  int lpsm_process_ (int& delay,
865  process_flags_type& pf) override;
866 
871  int read_u8_ (uint8_t reg) const;
872 
873  /* Other implementations that require enable_scoped(). */
874  int status_ () const;
875  int baseline_ () const;
876  int baseline_ (uint16_t value) const;
877  int fetch_ (observations_type& obs);
878 
879  /* Fetch the retained (expected) drive mode regardless of machine
880  * state. */
881  int active_drive_mode_ () const
882  {
883  const auto rsp = &retained_state_;
885  }
886 
887  void intn_callback_ (const periph::GPIOTE::sense_status_type*);
888 
889  static retained_state_type retained_state_;
890 
891  iface_config_type& iface_config_;
892 
893  gpio::active_low waken_;
894  gpio::active_low resetn_;
895 
896  periph::GPIOTE::sense_listener intn_listener_;
897  observations_type observations_{};
898  version_s version_{};
899  uint64_t baseline_saved_utt_{};
900  uint32_t env_data_ = -1;
901 
902  int8_t intn_psel_;
903  uint8_t addr_;
904  uint8_t drive_mode_ = DEFAULT_DRIVE_MODE;
905 };
906 
907 } // ns sensor
908 } // ns nrfcxx
909 
910 #endif /* NRFCXX_SENSOR_CCS811_HPP */
nrfcxx::sensor::ccs811::retained_state_type::reset_utt
uint64_t reset_utt
The aggregate uptime at which the sensor was last reset.
Definition: ccs811.hpp:144
nrfcxx::sensor::ccs811::threshold_s::eCO2_ppm
uint16_t eCO2_ppm
Threshold for changes in observations_type::eCO2.
Definition: ccs811.hpp:645
nrfcxx::sensor::ccs811::drive_mode
int drive_mode() const
Read the configured drive mode.
Definition: ccs811.hpp:843
nrfcxx::sensor::ccs811::PF_CONDITIONED
static constexpr auto PF_CONDITIONED
Bit set in non-negative lpsm_process() result when the sensor has completed its conditioning period.
Definition: ccs811.hpp:721
nrfcxx::sensor::ccs811::iface_config_type::resetn
gpio::generic_pin & resetn
GPIO pin selector for RESETn signal.
Definition: ccs811.hpp:106
nrfcxx::sensor::ccs811::twi
periph::TWI & twi() const
Directly access the TWI peripheral used to communicate with the device.
Definition: ccs811.hpp:285
nrfcxx::sensor::ccs811::version_s::fw_boot_version
uint16_t fw_boot_version
Native byte order boot firmware version identifier.
Definition: ccs811.hpp:414
nrfcxx::sensor::ccs811::ST_APP_VERIFY
(Boot mode only) Set indicates that a verify operation succeeded.
Definition: ccs811.hpp:464
nrfcxx::sensor::ccs811::retained_state_type::FL_DRIVE_MODE_Msk
Mask to isolate active drive mode in flags.
Definition: ccs811.hpp:193
nrfcxx::sensor::ccs811::CONDITIONING_DELAY_utt
static constexpr unsigned int CONDITIONING_DELAY_utt
Duration of the conditioning period, in uptime ticks.
Definition: ccs811.hpp:87
nrfcxx::sensor::ccs811::observations_type::baseline
uint16_t baseline
The BASELINE register read immediately before the ALG_RESULT_DATA register.
Definition: ccs811.hpp:501
nrfcxx::sensor::ccs811::iface_config
const iface_config_type & iface_config() const
Access the interface configuration for the sensor.
Definition: ccs811.hpp:120
nrfcxx::sensor::ccs811::ST_DATA_READY
If set new data is available in the ALG_RESULT_DATA register.
Definition: ccs811.hpp:458
nrfcxx::sensor::ccs811::iface_config_type::intn_psel
int8_t intn_psel
GPIO pin selector for INTn signal.
Definition: ccs811.hpp:109
nrfcxx::sensor::ccs811::retained_state_type::FL_BASELINED
Flag set when baseline has been set to a valid value.
Definition: ccs811.hpp:183
nrfcxx::sensor::ccs811::persisted_state_type::baseline
uint16_t baseline[4]
Recorded baseline values indexed by MEAS_MODE drive mode.
Definition: ccs811.hpp:217
nrfcxx::sensor::ccs811::PF_BASELINED
static constexpr auto PF_BASELINED
Bit set in non-negative lpsm_process() result when the machine saved the BASELINE register to retaine...
Definition: ccs811.hpp:730
nrfcxx::sensor::ccs811::observations_type::eCO2
uint16_t eCO2
Equivalent CO2 estimate, in ppm.
Definition: ccs811.hpp:504
nrfcxx::sensor::ccs811::scoped_enabler
Class obtained from scoped_enable().
Definition: ccs811.hpp:291
nrfcxx::sensor::ccs811::observation_beacon
observation_beacon_type observation_beacon() const
Populate and return an observation beacon structure from the current state.
nrfcxx::sensor::ccs811::DM_IDLE
Idle mode, no measurements will be produced.
Definition: ccs811.hpp:819
nrfcxx::clock::uptime::Frequency_Hz
constexpr static unsigned int Frequency_Hz
Frequency of the uptime clock as a symbolic constant.
Definition: clock.hpp:247
nrfcxx::sensor::ccs811::env_data
uint32_t env_data() const
Read the last written environment data setting.
Definition: ccs811.hpp:781
nrfcxx::sensor::ccs811::retained_state_type::flags_enum
flags_enum
Defined values for flags.
Definition: ccs811.hpp:163
nrfcxx::sensor::ccs811::i2c_address
unsigned int i2c_address() const
Access the I2C address used for the device.
Definition: ccs811.hpp:858
nrfcxx::sensor::ccs811::EI_WRITE_REG_INVALID
If set an I2C write was attempted to an unwritable register.
Definition: ccs811.hpp:474
nrfcxx::gpio::generic_pin
Class supporting a generic GPIO pin interface.
Definition: gpio.hpp:439
nrfcxx::sensor::ccs811::retained_state_type::baseline
uint16_t baseline
The most recently validated BASELINE register value.
Definition: ccs811.hpp:160
nrfcxx::sensor::ccs811::retained_state
static const retained_state_type & retained_state()
Access the retained state.
Definition: ccs811.hpp:254
nrfcxx::sensor::ccs811::DM_1_s
Constant power, measurements every second.
Definition: ccs811.hpp:821
nrfcxx::sensor::ccs811::version_s
Aggregate identity and version from hardware and firmware registers.
Definition: ccs811.hpp:407
nrfcxx::sensor::ccs811::iface_config_type::twi
periph::TWI & twi
Reference to TWI device used to communicate with sensor.
Definition: ccs811.hpp:100
nrfcxx::gpio::active_signal::asserted
bool asserted() const
Indicate whether the signal is currently asserted.
Definition: gpio.hpp:634
lpm.hpp
Material supporting low-power-mode operations.
nrfcxx::periph::GPIOTE::sense_listener
Object used to manage sense callbacks.
Definition: periph.hpp:854
nrfcxx::sensor::ccs811::observation_beacon_type::eTVOC
uint16_t eTVOC
Copied from observations_type::eTVOC.
Definition: ccs811.hpp:608
nrfcxx::sensor::ccs811::iface_config_type::waken
gpio::generic_pin & waken
GPIO pin selector for WAKEn signal.
Definition: ccs811.hpp:103
nrfcxx::sensor::ccs811::encode_env
static uint32_t encode_env(int16_t temp_cCel, uint16_t rh_pptt)
Convert temperature and humidity to CCS811 ENV_DATA format.
nrfcxx::sensor::ccs811::observations
const observations_type & observations() const
Access the most recent collected observations.
Definition: ccs811.hpp:546
nrfcxx::periph::TWI
Wrapper around the nRF51 TWI peripheral.
Definition: periph.hpp:1528
nrfcxx::sensor::ccs811::observations_type::raw
uint16_t raw
Optional raw data.
Definition: ccs811.hpp:529
nrfcxx::sensor::ccs811::RESET_DELAY_us
static constexpr unsigned int RESET_DELAY_us
Value for minimum t_RESET in microseconds.
Definition: ccs811.hpp:77
gpio.hpp
Core GPIO functionality.
nrfcxx::sensor::ccs811::DRIVE_MODE_e
DRIVE_MODE_e
Allowed drive modes for the MEAS_MODE register.
Definition: ccs811.hpp:816
nrfcxx::sensor::ccs811::ST_ERROR
If set the sensor or I2C bus has produced an error.
Definition: ccs811.hpp:455
nrfcxx::sensor::ccs811::observations_type::eTVOC
uint16_t eTVOC
Equivalent total volatile organic compound estimate, in ppb.
Definition: ccs811.hpp:511
nrfcxx::sensor::ccs811::retained_state_type
Structure holding retained state of the sensor.
Definition: ccs811.hpp:130
nrfcxx::sensor::ccs811::PF_RESTORED
static constexpr auto PF_RESTORED
Bit set in non-negative lpsm_process() result when the machine updated the CCS811 baseline from retai...
Definition: ccs811.hpp:717
nrfcxx::sensor::ccs811::baseline
int baseline() const
Read the current baseline value.
nrfcxx::gpio::active_signal
Wrapper supporting GPIO control of output signals by explicit or scoped assertion.
Definition: gpio.hpp:578
nrfcxx::sensor::ccs811::STATUS_e
STATUS_e
Definition: ccs811.hpp:450
nrfcxx::sensor::ccs811::restore_from_persisted
int restore_from_persisted(const persisted_state_type &ps)
Update the retained state with information from persisted state.
nrfcxx::sensor::ccs811::version_s::hw_version
uint8_t hw_version
Hardware version identifier.
Definition: ccs811.hpp:433
nrfcxx::sensor::ccs811::DM_60_s
Low-pulse model, measurements every 60 seconds.
Definition: ccs811.hpp:825
nrfcxx::sensor::ccs811::EI_MAX_RESISTANCE
If set a the sensor has reached the maximum range.
Definition: ccs811.hpp:484
nrfcxx::periph::TWI::disable
void disable()
Disable the TWI peripheral.
Definition: periph.hpp:1608
nrfcxx::sensor::ccs811::scoped_enabler::result
int result() const
Return the result of invoking periph::TWI::enable() in the constructor.
Definition: ccs811.hpp:349
nrfcxx::sensor::ccs811::persisted_state_type
State that should be persisted in non-volatile memory using the utility::Persist infrastructure.
Definition: ccs811.hpp:214
nrfcxx::sensor::ccs811::threshold_s
Thresholds for detecting significant changes in readings.
Definition: ccs811.hpp:642
nrfcxx::gpio::active_signal::assert
void assert() const
Clear the associated GPIO to assert the active-low signal.
Definition: gpio.hpp:640
nrfcxx::lpm::lpsm_capable::lpsm_sample
virtual int lpsm_sample()
Ask the LPM infrastructure to initiate a new sample.
nrfcxx::sensor::ccs811::HARDWARE_ID
static constexpr uint8_t HARDWARE_ID
The value expected to be read back in version_s::hw_id.
Definition: ccs811.hpp:403
nrfcxx::sensor::ccs811::observation_beacon_type::eCO2
uint16_t eCO2
Copied from observations_type::eCO2.
Definition: ccs811.hpp:605
nrfcxx::sensor::ccs811::reset
int reset() const
Toggle the RESETn line to reset the sensor.
nrfcxx::sensor::ccs811::EI_READ_REG_INVALID
If set an I2C read was attempted from an unreadable register.
Definition: ccs811.hpp:477
nrfcxx::sensor::ccs811::DEFAULT_DRIVE_MODE
static constexpr auto DEFAULT_DRIVE_MODE
Default value for drive_mode()
Definition: ccs811.hpp:829
nrfcxx::sensor::ccs811::status
int status() const
Read the STATUS and, if necessary, ERROR_ID registers.
nrfcxx::sensor::ccs811::scoped_enabler::assert
void assert()
Assert WAKEn and delay until I2C operations are allowed.
Definition: ccs811.hpp:355
nrfcxx::sensor::ccs811::retained_state_type::FL_DRIVE_MODE_Pos
Position in flags where the active drive mode is stored.
Definition: ccs811.hpp:190
nrfcxx::sensor::ccs811::update_persisted
int update_persisted(persisted_state_type &ps) const
Update a persisted state with information from retained state.
nrfcxx::sensor::ccs811::observations_type::is_ready
bool is_ready() const
Test whether the ST_DATA_READY flag is set.
Definition: ccs811.hpp:523
nrfcxx::sensor::ccs811::retained_state_type::flags_type
uint8_t flags_type
Type used to hold state flags.
Definition: ccs811.hpp:133
nrfcxx::sensor::ccs811::retained_state_type::FL_REPORTING
Flag set when the first valid (but unconditioned) observation has been provided to the application.
Definition: ccs811.hpp:167
nrfcxx::sensor::ccs811::BASELINE_CAPTURE_INTERVAL_utt
static constexpr unsigned int BASELINE_CAPTURE_INTERVAL_utt
Duration between retention of the BASELINE register.
Definition: ccs811.hpp:90
nrfcxx::sensor::ccs811::APP_START_DELAY_utt
static constexpr unsigned int APP_START_DELAY_utt
Value for maximum t_APP_START in uptime ticks.
Definition: ccs811.hpp:59
nrfcxx::sensor::ccs811::system_beacon_type::bl_latest
uint16_t bl_latest
The most recently observed value of the BASELINE register.
Definition: ccs811.hpp:567
nrfcxx::sensor::ccs811::EI_MEASMODE_INVALID
If set an I2C write to MEAS_MODE provided an unacceptable value.
Definition: ccs811.hpp:481
nrfcxx::sensor::ccs811::observation_beacon_type::env_data
uint32_t env_data
Copied from ccs811::env_data().
Definition: ccs811.hpp:599
nrfcxx::sensor::ccs811::version_s::hw_id
uint8_t hw_id
Hardware identifer, which should be HARDWARE_ID.
Definition: ccs811.hpp:427
nrfcxx::sensor::ccs811::PF_CCS811_ERROR
static constexpr auto PF_CCS811_ERROR
Bit set in non-negative lpsm_process() result when a new observation identifies a CCS811 error in obs...
Definition: ccs811.hpp:735
nrfcxx::gpio::active_signal::deassert
void deassert() const
Set the associated GPIO to deassert the active-low signal.
Definition: gpio.hpp:646
nrfcxx::sensor::ccs811::status_type
uint16_t status_type
Value for a valid CCS811 status.
Definition: ccs811.hpp:448
nrfcxx::systemState::state_type
The raw data supporting cross-reset state transfer.
Definition: core.hpp:993
nrfcxx::sensor::ccs811::PF_REPORTING
static constexpr auto PF_REPORTING
Bit set in non-negative lpsm_process() result when the sensor has started providing observations.
Definition: ccs811.hpp:710
nrfcxx::periph::GPIOTE::sense_status_type
Structure used to convey information about pin levels to sense_listener callbacks.
Definition: periph.hpp:672
nrfcxx::sensor::ccs811::threshold_s::observation_beacon_changed
int observation_beacon_changed(const observation_beacon_type &ob1, const observation_beacon_type &ob2) const
Assess whether two observations differ significantly.
nrfcxx::sensor::ccs811::ccs811
ccs811(notifier_type setter, iface_config_type &ifc, bool addr_sec=false)
Instantiate the device.
nrfcxx::sensor::ccs811::observation_beacon_type::status
int16_t status
Untransmitted content to simplify change detection.
Definition: ccs811.hpp:624
nrfcxx::sensor::ccs811::threshold_s::humidity_pph
uint8_t humidity_pph
Threshold for changes to the relative humidity value in env_data().
Definition: ccs811.hpp:655
nrfcxx::sensor::ccs811::observations_type::status
status_type status
The combined STATUS and ERROR_ID register values.
Definition: ccs811.hpp:519
nrfcxx::sensor::ccs811::system_beacon_type::active_ds
uint32_t active_ds
How long the sensor has been running, in deciseconds.
Definition: ccs811.hpp:556
nrfcxx::sensor::ccs811::ST_FW_MODE
Clear indicates device is in boot mode; set indicates device is in application mode.
Definition: ccs811.hpp:471
nrfcxx::sensor::ccs811::iface_config_type
Structure providing the system resources necessary to interact with the CCS811.
Definition: ccs811.hpp:97
nrfcxx::sensor::ccs811::observation_beacon_type::baseline
uint16_t baseline
Copied from observations_type::baseline.
Definition: ccs811.hpp:602
nrfcxx::sensor::ccs811::state_setup
static void state_setup(const systemState::state_type &ss, bool is_reset, bool retained)
Function to maintain CCS811 state across resets.
nrfcxx::sensor::ccs811::observation_beacon_type
Structure that can be broadcast as a beacon to provide observation data.
Definition: ccs811.hpp:596
nrfcxx::sensor::ccs811::fill_system_beacon
int fill_system_beacon(system_beacon_type &fr) const
Set the contents of a system beacon frame.
nrfcxx::notifier_type
std::function< void()> notifier_type
Type used to hold a notifier.
Definition: core.hpp:514
nrfcxx::periph::TWI::enable
ssize_type enable()
Enable the TWI peripheral.
Definition: periph.hpp:1602
nrfcxx::sensor::ccs811::EI_HEATER_SUPPLY
If set the heater supply voltage is not correct.
Definition: ccs811.hpp:490
nrfcxx::lpm::lpsm_capable
Base (or mixin) class for anything that supports a state_machine.
Definition: lpm.hpp:426
nrfcxx::sensor::ccs811::active_drive_mode
int active_drive_mode() const
Read the drive mode from the active state.
nrfcxx::lpm::state_machine
State machine abstraction for time-delayed transitions and error captures.
Definition: lpm.hpp:36
nrfcxx::sensor::ccs811::scoped_enable
scoped_enabler scoped_enable() const
Construct and return an RAII object that supports TWI interaction.
Definition: ccs811.hpp:397
nrfcxx::sensor::ccs811
Interface to the ams CCS811 indoor air quality sensor.
Definition: ccs811.hpp:50
nrfcxx::sensor::ccs811::version_s::fw_app_version
uint16_t fw_app_version
Native byte order application firmware version identifier.
Definition: ccs811.hpp:421
nrfcxx::sensor::ccs811::retain_baseline
int retain_baseline()
Record the current baseline in retained state.
nrfcxx::sensor::ccs811::ST_APP_VALID
If set a valid application image is available in the sensor.
Definition: ccs811.hpp:461
nrfcxx::sensor::ccs811::COLD_START_DELAY_utt
static constexpr unsigned int COLD_START_DELAY_utt
Value for maximum t_START after power-on in uptime ticks.
Definition: ccs811.hpp:65
nrfcxx::clock::uptime::from_ms
constexpr static int64_t from_ms(int64_t ms)
Convert integral milliseconds to uptime ticks (rounding down).
Definition: clock.hpp:422
nrfcxx::sensor::ccs811::DWAKE_DELAY_us
static constexpr unsigned int DWAKE_DELAY_us
Value for minimum t_DWAKE in microseconds.
Definition: ccs811.hpp:71
nrfcxx::sensor::ccs811::system_beacon_type::hw_version
uint8_t hw_version
Value from version_s::hw_version.
Definition: ccs811.hpp:573
nrfcxx::sensor::ccs811::DM_10_s
Pulse mode, measurements every 10 seconds.
Definition: ccs811.hpp:823
nrfcxx::sensor::ccs811::EI_HEATER_FAULT
If set the heater supply current is out of range.
Definition: ccs811.hpp:487
nrfcxx::sensor::ccs811::system_beacon_type::app_version
uint16_t app_version
Value from version_s::fw_app_version.
Definition: ccs811.hpp:570
nrfcxx::sensor::ccs811::system_beacon_type
Structure that can be broadcast as a beacon to provide detailed system state.
Definition: ccs811.hpp:553
nrfcxx::lpm::state_machine::PF_APP_BASE
static constexpr process_flags_type PF_APP_BASE
First lpsm_capable::lpsm_process() flag bit available for application-specific result code bits.
Definition: lpm.hpp:255
nrfcxx::sensor::ccs811::system_beacon_type::flags
uint8_t flags
A copy of retained_state_type::flags.
Definition: ccs811.hpp:576
nrfcxx::sensor::ccs811::machine
const lpm::state_machine & machine() const
Gain read-only access to the LPM machine state.
Definition: ccs811.hpp:699
nrfcxx::sensor::ccs811::DRESET_DELAY_us
static constexpr unsigned int DRESET_DELAY_us
Value for minimum t_DRESET in microseconds.
Definition: ccs811.hpp:74
nrfcxx::sensor::ccs811::WAKE_DELAY_us
static constexpr unsigned int WAKE_DELAY_us
Value for maximum t_WAKE in microseconds.
Definition: ccs811.hpp:62
nrfcxx::sensor::ccs811::system_beacon_type::bl_age_ds
uint32_t bl_age_ds
How long since the baseline register was updated, in deciseconds.
Definition: ccs811.hpp:561
nrfcxx::sensor::ccs811::system_beacon_type::bl_retained
uint16_t bl_retained
The most recently retained value of the BASELINE register.
Definition: ccs811.hpp:564
nrfcxx::sensor::ccs811::retained_state_type::flags
uint8_t flags
Flags recording the stage of processing of the device.
Definition: ccs811.hpp:209
nrfcxx::sensor::ccs811::id_version
const version_s & id_version() const
Access the version state managed by the LPM machine.
Definition: ccs811.hpp:540
nrfcxx::sensor::ccs811::threshold_s::eTVOC_ppb
uint16_t eTVOC_ppb
Threshold for changes in observations_type::eTVOC.
Definition: ccs811.hpp:648
nrfcxx::sensor::ccs811::retained_state_type::FL_CONDITIONED
Flag set on the first observation received more than CONDITIONING_DELAY_utt after reset_utt.
Definition: ccs811.hpp:176
nrfcxx::delay_us
void delay_us(unsigned int number_of_us)
Delay for exactly the specified duration.
Definition: core.hpp:292
nrfcxx
Primary namespace for nrfcxx functionality.
Definition: clock.hpp:17
nrfcxx::sensor::ccs811::system_beacon_type::SPAN
static constexpr size_t SPAN
The transmitted length of this structure, excluding trailing padding.
Definition: ccs811.hpp:580
nrfcxx::sensor::ccs811::threshold_s::env_data_changed
int env_data_changed(uint32_t ed1, uint32_t ed2) const
Compare two encoded environmental values for closeness.
nrfcxx::sensor::ccs811::intn_asserted
bool intn_asserted() const
Programmatic test for whether INTn is asserted.
Definition: ccs811.hpp:370
nrfcxx::sensor::ccs811::observation_beacon_type::SPAN
static constexpr size_t SPAN
The transmitted length of this structure, excluding trailing padding and untransmitted status.
Definition: ccs811.hpp:612
nrfcxx::sensor::ccs811::observations_type
Captured results after an observation.
Definition: ccs811.hpp:497
nrfcxx::sensor::ccs811::ST_APP_ERASE
(Boot mode only) Set indicates that an erase operation succeeded.
Definition: ccs811.hpp:467
nrfcxx::sensor::ccs811::threshold_s::temperature_Cel
uint8_t temperature_Cel
Threshold for changes to the temperature value in env_data().
Definition: ccs811.hpp:651
nrfcxx::sensor::ccs811::retained_state_type::baselined_utt
uint64_t baselined_utt
The aggregate uptime at which the BASELINE register was last stored in baseline.
Definition: ccs811.hpp:151
nrfcxx::sensor::ccs811::WARM_START_DELAY_utt
static constexpr unsigned int WARM_START_DELAY_utt
Value for maximum t_START after reset in uptime ticks.
Definition: ccs811.hpp:68
nrfcxx::periph::TWI::enabled
bool enabled() const
Return true iff the device is enabled.
Definition: periph.hpp:1541
nrfcxx::sensor::ccs811::scoped_enabler::deassert
void deassert()
De-assert WAKEn and delay as required.
Definition: ccs811.hpp:362