1-Wire and ENS210 driver stack
ENS210.hpp
1 /*
2  * ENS210.hpp - I2C Temperature and Humidity sensor driver
3  *
4  * Created on: Oct 27, 2023
5  * Author: Dave Nadler
6  */
7 
8 #ifndef ENS210_HPP_INCLUDED
9 #define ENS210_HPP_INCLUDED
10 
11 #include <stdint.h>
12 
13 #include "ENS210_Result.hpp"
14 #include "1wire/one_wire_address.h"
15 
16 class ENS210_T {
17  bool initOK = false;
18  uint8_t soldercorrection = 0; // Correction due to soldering (in 1/64K); subtracted from rawTemperature by measure function.
19  uint32_t crc7( uint32_t val ); // calculate ENS210 checksum for a raw temperature or humidity value
20  // *** Following members are specific to the DS28E18 controlling this ENS210 on a 1-Wire bus ***
21  OneWire_ROM_ID_T OneWireAddress; ///< Address of the DS28E18 controlling this ENS210 on the 1-Wire bus.
22  // Append a write to the command sequence under construction
23  // dataStream first byte is starting register, followed by register value(s)
24  void writeRegisters(const uint8_t *dataStream, int len);
25  // Append a read to the command sequence under construction
26  // Return value is the index of the result in the readback command sequence
27  int readRegisters(uint8_t firstRegister, int len);
28 public:
29  uint16_t PART_ID; // looking for 0x0210
30  bool PART_ID_Valid() const { return PART_ID == 0x0210; };
31  uint8_t SYS_STAT; // must be 1 in active state
32  bool SYS_STAT_Valid() const { return SYS_STAT == 1; };
33  uint16_t dieRevision = 0;
34  uint64_t uniqueDeviceID = 0;
35  ENS210_T() : OneWireAddress() {}; // ctor does NOT do device initialization; permits static allocation...
36  bool Init();
37  bool InitOK() const { return initOK; };
38  static void QwikTest();
39  ENS210_Result_T Measure();
40 };
41 
42 #endif /* ENS210_HPP_INCLUDED */
Definition: ENS210.hpp:16
Address of a device on a 1-Wire bus. Separate file to allow inclusion by high-level functions without...
Measurement result from ENS210.
Definition: ENS210_Result.hpp:19
OneWire_ROM_ID_T type stores a 1-Wire address.
Definition: one_wire_address.h:15