SparkFun Spectral UV Sensor - AS7331  v2.1.2-21-g3e22fb4
Library for the SparkFun Spectral UV Sensor - AS7331
Loading...
Searching...
No Matches
sfDevAS7331.h
Go to the documentation of this file.
1
45#pragma once
46
47#include <stdint.h>
48
49// include the sparkfun toolkit headers
50#include <sfTk/sfToolkit.h>
51
52// Bus interfaces
53#include <sfTk/sfTkII2C.h>
55// I2C Addressing
57// 7-bit address defined as [1, 1, 1, 0, 1, A1, A0] where A1/A0 are the
58// physical address pins tied high or low
59const uint8_t kDefaultAS7331Addr = 0x74; // A1 = 0, A0 = 0
60const uint8_t kSecondaryAS7331Addr = 0x75; // A1 = 0, A1 = 1
61const uint8_t kTertiaryAS7331Addr = 0x76; // A1 = 1, A0 = 0
62const uint8_t kQuaternaryAS7331Addr = 0x77; // A1 = 1, A0 = 1
63
64const uint8_t kDefaultAS7331DeviceID = 0x21; // When polling the AGEN register, this should be returned on boot.
65const uint8_t kAS7331DeviceIDTopNibble = 0x2; // Top nibble of the AGEN byte, always the same.
66
68// Enum Definitions
70
71// Device Operating Mode
72typedef enum
73{
74 // 0b00X invalid
77 // 0b1XX invalid
79
80// Sensor gain, able to be read as (1 << (11 - gain)) aka 2^(11-gain).
81typedef enum
82{
83 GAIN_2048 = 0x0000,
94 GAIN_1
96
97// Conversion Clock Frequency available settings, read as (1024 * (1 << cclk))
98// aka 1024*2^cclk.
99typedef enum
100{
106
107// Measurement Mode types
108typedef enum
109{
110 MEAS_MODE_CONT = 0x0, // Continuous mode
111 MEAS_MODE_CMD, // Command/OneShot mode
112 MEAS_MODE_SYNS, // SYNchronous Start mode
113 MEAS_MODE_SYND // SYNchronous start and enD mode
115
116// Time conversion values in CONT, CMD, SYNS modes. Read as (1 << tconv) aka
117// 2^tconv.
118typedef enum
119{
120 TIME_1MS = 0x0,
136
137// Predivider values. Read as (1 << (1+div)) aka 2^(1+div).
138typedef enum
139{
140 DIV_2 = 0x0,
147 DIV_256
149
150// Type of UV to pick.
151typedef enum
152{
157
159// Configuration Register Descriptions
160//
161// Can only be accessed in the Configuration operation state. All 8 bits long.
162//
163// The following registers map to the underlying registers of the device.
165
166const uint8_t kSfeAS7331RegCfgOsr = 0x00; // Register address
167
168// A union is used here so that individual values from the register can be
169// accessed or the whole register can be accessed.
170typedef union {
171 struct
172 {
173 uint8_t dos : 3; // Device Operating State - OSR[2:0]
174 uint8_t sw_res : 1; // Software Reset - OSR[3]
175 uint8_t reserved : 2; // Reserved, don't write. - OSR[4:5]
176 uint8_t pd : 1; // Power Down Enabled - OSR[6]
177 uint8_t ss : 1; // Start State - OSR[7]
178 };
179 uint8_t byte;
181
182const uint8_t kSfeAS7331RegCfgAgen = 0x02; // Register address
183
184// A union is used here so that individual values from the register can be
185// accessed or the whole register can be accessed.
186typedef union {
187 struct
188 {
189 uint8_t mut : 4; // Increments when changes are made to the control
190 // registers. Defaults to 0b0001 aka 0x1.
191 uint8_t devid : 4; // Always equals 0b0010 aka 0x2.
192 };
193 uint8_t byte;
195
196const uint8_t kSfeAS7331RegCfgCreg1 = 0x06; // Register address
197
198// A union is used here so that individual values from the register can be
199// accessed or the whole register can be accessed.
200typedef union {
201 struct
202 {
203 uint8_t time : 4; // Conversion time - CREG1[3:0]
204 uint8_t gain : 4; // Sensor gain - CREG1[7:4]
205 };
206 uint8_t byte;
208
209const uint8_t kSfeAS7331RegCfgCreg2 = 0x07; // Register address
210
211// A union is used here so that individual values from the register can be
212// accessed or the whole register can be accessed.
213typedef union {
214 struct
215 {
216 uint8_t div : 3; // Digital Divider value - CREG2[2:0]
217 uint8_t en_div : 1; // Whether the digital divider is enabled - CREG2[3]
218 uint8_t reserved : 2; // Reserved, don't write. - CREG2[5:4]
219 uint8_t en_tm : 1; // Whether temperature is calculated in SYND mode. - CREG2[6]
220 uint8_t reserved1 : 1; // Reserved, don't write. - CREG2[7]
221 };
222 uint8_t byte;
224
225const uint8_t kSfeAS7331RegCfgCreg3 = 0x08; // Register Address
226
227// A union is used here so that individual values from the register can be
228// accessed or the whole register can be accessed.
229typedef union {
230 struct
231 {
232 uint8_t cclk : 2; // Conversion clock selection. - CREG3[1:0]
233 uint8_t reserved : 1; // Reserved, don't write. - CREG3[2]
234 uint8_t rdyod : 1; // Output mode of the ready pin. - CREG3[3]
235 uint8_t sb : 1; // Standby mode bit. - CREG3[4]
236 uint8_t reserved1 : 1; // Reserved, don't write. - CREG3[5]
237 uint8_t mmode : 2; // Measurement mode selection. - CREG3[7:6]
238 };
239 uint8_t byte;
241
242const uint8_t kSfeAS7331RegCfgBreak = 0x09; // Register address, register is a single uint8_t.
243
244const uint8_t kSfeAS7331RegCfgEdges = 0x0A; // Register address, register is a single uint8_t.
245
246const uint8_t kSfeAS7331RegCfgOptReg = 0x0B; // Register address
247
248// A union is used here so that individual values from the register can be
249// accessed or the whole register can be accessed.
250typedef union {
251 struct
252 {
253 uint8_t init_idx : 1; // I2C repeat start mode flag. - OPTREG[0]
254 uint8_t reserved : 7; // Reserved, don't write. - OPTREG[7:1]
255 };
256 uint8_t byte;
258
260// Measurement Register Descriptions
261//
262// Can only be accessed in the Measure operation state. All 16 bits long. They
263// are all read-only except the bottom byte of the OSR/STATUS register.
264//
265// The following registers map to the underlying registers of the device.
267
268const uint8_t kSfeAS7331RegMeasOsrStatus = 0x00; // Register address
269
270// A union is used here so that individual values from the register can be
271// accessed or the whole register can be accessed.
272typedef union {
273 struct
274 {
275 sfe_as7331_reg_cfg_osr_t osr; // See OSR configuration register above. - OSRSTAT[7:0]
276 uint8_t powerstate : 1; // Power down state. - OSRSTAT[8]
277 uint8_t standbystate : 1; // Standby mode state. - OSRSTAT[9]
278 uint8_t notready : 1; // Inverted value of the ready pin. - OSRSTAT[10]
279 uint8_t ndata : 1; // Indicates new data available. - OSRSTAT[11]
280 uint8_t ldata : 1; // Indicates data overwrite prior to retrieval. - OSRSTAT[12]
281 uint8_t adcof : 1; // OVF of at least one ADC channel. - OSRSTAT[13]
282 uint8_t mresof : 1; // OVF of at least one of the MRES registers. - OSRSTAT[14]
283 uint8_t outconvof : 1; // OVF of the internal 24-bit time reference. - OSRSTAT[15]
284 };
285 uint16_t word;
287
288// Output result registers. 16-bit values unless noted otherwise.
289const uint8_t kSfeAS7331RegMeasTemp = 0x01; // 12-bit temperature, MS 4-bits 0.
290const uint8_t kSfeAS7331RegMeasMres1 = 0x02;
291const uint8_t kSfeAS7331RegMeasMres2 = 0x03;
292const uint8_t kSfeAS7331RegMeasMres3 = 0x04;
293const uint8_t kSfeAS7331RegMeasOutConvL = 0x05; // First 16-bits of 24-bit OUTCONV.
294const uint8_t kSfeAS7331RegMeasOutConvH = 0x06; // LSB is MSB of OUTCONV, MSB is 0.
295
297
299{
300 public:
301 // Default initialization values based on the datasheet. See SfeAS7331Driver::setDefaultSettings for
302 // an explanation of the values.
304 : _theBus{nullptr}, _breakTime{25}, _numEdges{1}, _readyPinMode{false}, _dividerEnabled{false},
305 _tempConvEnabled{true}, _indexMode{true}, _standbyState{false}, _startState{false},
306 _powerDownEnableState{true}, _opMode{DEVICE_MODE_CFG}, _sensorGain{GAIN_2}, _cclk{CCLK_1_024_MHZ},
307 _mmode{MEAS_MODE_CMD}, _conversionTime{TIME_64MS}, _dividerRange{DIV_2}, _uva{0.0f}, _uvb{0.0f}, _uvc{0.0f},
308 _temperature{0.0f}, _outputConversionTime{0U}, _conversionA{0.0f}, _conversionB{0.0f}, _conversionC{0.0f}
309 {
310 }
311
316 bool begin(sfTkIBus *theBus = nullptr);
317
320 uint8_t getDeviceID(void);
321
324 void setCommunicationBus(sfTkIBus *theBus);
325
331 bool runDefaultSetup(const bool &runSoftReset = false);
332
337 bool prepareMeasurement(const as7331_meas_mode_t &measMode = MEAS_MODE_CONT, const bool &startMeasure = false);
338
341 bool reset(void);
342
346 sfTkError_t readTemp(void);
347
351 sfTkError_t readUVA(void);
352
356 sfTkError_t readUVB(void);
357
361 sfTkError_t readUVC(void);
362
366 sfTkError_t readAllUV(void);
367
372 sfTkError_t readAll(void);
373
377 sfTkError_t readOutConv(void);
378
381 float getUVA(void);
382
385 float getUVB(void);
386
389 float getUVC(void);
390
393 float getTemp(void);
394
397 uint32_t getOutConv(void);
398
402
405 uint16_t getGainValue(void);
406
410 sfTkError_t setGain(const as7331_gain_t &gain);
411
415
418 uint16_t getCClkKHz(void);
419
423 sfTkError_t setCClk(const as7331_conv_clk_freq_t &cclk);
424
428
431 uint16_t getConversionTimeMillis(void);
432
436 sfTkError_t setConversionTime(const as7331_conv_time_t &convTime);
437
440 bool getReadyPinMode(void);
441
445 sfTkError_t setReadyPinMode(const bool &pinMode);
446
449 bool getDigitalDividerEnabled(void);
450
454 sfTkError_t setDigitalDividerEnabled(const bool &isEnabled);
455
459
464 sfTkError_t setDigitalDividerRange(const as7331_divider_val_t &divider, const bool &enableDiv = true);
465
469
473 sfTkError_t setSyndTempConversionEnabled(const bool &isEnabled);
474
477 bool getIndexMode(void);
478
483 sfTkError_t setIndexMode(const bool &indexMode);
484
488 uint8_t getBreakTime(void);
489
494 sfTkError_t setBreakTime(const uint8_t &breakTime);
495
499 uint8_t getNumEdges(void);
500
506 sfTkError_t setNumEdges(const uint8_t &numEdges);
507
510 bool getPowerDownState(void);
511
515 sfTkError_t setPowerDownState(const bool &pd);
516
520
524 sfTkError_t setOperationMode(const as7331_dev_op_state_t &opMode);
525
529
533 sfTkError_t setMeasurementMode(const as7331_meas_mode_t &measMode);
534
537 bool getStandbyState(void);
538
542 sfTkError_t setStandbyState(const bool &standby);
543
546 bool getStartState(void);
547
551 sfTkError_t setStartState(const bool &startState);
552
557 sfTkError_t getStatus(sfe_as7331_reg_meas_osr_status_t &statusReg);
558
564 sfTkError_t getOSR(sfe_as7331_reg_cfg_osr_t &osrReg);
565
571 sfTkError_t setOSR(const sfe_as7331_reg_cfg_osr_t &osrReg);
572
578 sfTkError_t getCReg1(sfe_as7331_reg_cfg_creg1_t &creg1);
579
585 sfTkError_t setCReg1(const sfe_as7331_reg_cfg_creg1_t &creg1);
586
592 sfTkError_t getCReg2(sfe_as7331_reg_cfg_creg2_t &creg2);
593
599 sfTkError_t setCReg2(const sfe_as7331_reg_cfg_creg2_t &creg2);
600
606 sfTkError_t getCReg3(sfe_as7331_reg_cfg_creg3_t &creg3);
607
613 sfTkError_t setCReg3(const sfe_as7331_reg_cfg_creg3_t &creg3);
614
619 sfTkError_t getBreak(uint8_t &breakReg);
620
625 sfTkError_t setBreak(const uint8_t &breakReg);
626
631 sfTkError_t getEdges(uint8_t &edgesReg);
632
637 sfTkError_t setEdges(const uint8_t &edgesReg);
638
643 sfTkError_t getOptIndex(sfe_as7331_reg_cfg_optreg_t &optReg);
644
649 sfTkError_t setOptIndex(const sfe_as7331_reg_cfg_optreg_t &optReg);
650
651 private:
656 sfTkError_t readRawUV(const as7331_uv_type &uv_type);
657
661 float convertRawTempToTempC(const uint16_t &inputVal);
662
668 float convertRawUVVal(const uint16_t &rawVal, const float &convFactor);
669
672 void calculateConversionFactors(void);
673
675 void setDefaultSettings(void);
676
677 sfTkIBus *_theBus; // Pointer to bus device.
678
679 uint8_t _breakTime; // Local config value. Value is in us/8. EX: _breakTime = 20 means 20*8 = 160us.
680 uint8_t _numEdges; // Local config value. Edges seen on SYN pin before ending conversion in SYND mode.
681
682 bool _readyPinMode; // Local config value. False is Push/Pull True is Open/Drain.
683 bool _dividerEnabled; // Local config value. False is disabled, True is enabled.
684 bool _tempConvEnabled; // Local config value. False is disabled, True is enabled.
685 bool _indexMode; // Local config value. False is for controllers without repeat start.
686 bool _standbyState; // Local state value. False means the device is not in standby mode.
687 bool _startState; // Local state value. False means the device is not allowed to measure.
688 bool _powerDownEnableState; // Local state value. False means the device is NOT POWERED DOWN. This is inverse.
689
690 as7331_dev_op_state_t _opMode; // Local state value. Configuration or Measure operating mode.
691 as7331_gain_t _sensorGain; // Local config value. Sensor gain stored as (1 << (11 - gain)).
692 as7331_conv_clk_freq_t _cclk; // Local config value. Sensor's conversion clock stored as 1024*(1 << cclk) kHz.
693 as7331_meas_mode_t _mmode; // Local state value. Details the device's measurement mode as CONT, CMD, SYNS, or SYND.
694 as7331_conv_time_t _conversionTime; // Local config value. Contains the conversion time stored as (1 << time) ms.
695 as7331_divider_val_t _dividerRange; // Local config value. Contains the predivider value stored as (1 << 1 + range).
696
697 float _uva; // Last valid UVA result in uW/cm2.
698 float _uvb; // Last valid UVB result in uW/cm2.
699 float _uvc; // Last valid UVC result in uW/cm2.
700 float _temperature; // Last valid temperature result in degC.
701
702 uint32_t _outputConversionTime; // Last valid output conversion time result in of clock cycle count.
703
704 float _conversionA; // Internal conversion factor for the UVA sensor.
705 float _conversionB; // Internal conversion factor for the UVB sensor.
706 float _conversionC; // Internal conversion factor for the UVC sensor.
707
708 const float _fsrA = 348160.0; // Full Scale Resolution for the UVA sensor.
709 const float _fsrB = 387072.0; // Full Scale Resolution for the UVB sensor.
710 const float _fsrC = 169984.0; // Full Scale Resolution for the UVC sensor.
711};
Definition: sfDevAS7331.h:299
sfTkError_t setCReg1(const sfe_as7331_reg_cfg_creg1_t &creg1)
Sets the configuration register #1 when in configuration operation mode.
Definition: sfDevAS7331.cpp:902
sfTkError_t setCReg3(const sfe_as7331_reg_cfg_creg3_t &creg3)
Sets the configuration register #3 when in configuration operation mode.
Definition: sfDevAS7331.cpp:938
sfTkError_t setDigitalDividerEnabled(const bool &isEnabled)
Enables or disables the internal UV result divider.
Definition: sfDevAS7331.cpp:565
uint32_t getOutConv(void)
Returns the last valid output conversion.
Definition: sfDevAS7331.cpp:427
sfDevAS7331()
Definition: sfDevAS7331.h:303
sfTkError_t readAll(void)
Read the sensor's temperature, UV, and external time conversion clock counts, converts them,...
Definition: sfDevAS7331.cpp:337
sfTkError_t getBreak(uint8_t &breakReg)
Gets the break register when in configuration operation mode.
Definition: sfDevAS7331.cpp:947
sfTkError_t setOperationMode(const as7331_dev_op_state_t &opMode)
Set the sensor's operating mode.
Definition: sfDevAS7331.cpp:758
as7331_divider_val_t getDigitalDividerRange(void)
Getter for the currently configured divider range.
Definition: sfDevAS7331.cpp:592
sfTkError_t setMeasurementMode(const as7331_meas_mode_t &measMode)
Sets the sensor's measurement mode.
Definition: sfDevAS7331.cpp:784
sfTkError_t readUVB(void)
Reads the sensor's UVB register, converts it to a usable form, and saves it to the internal UVB varia...
Definition: sfDevAS7331.cpp:280
sfTkError_t readTemp(void)
Reads the sensor's temperature, converts it to a usable form, and saves it to the internal temperatur...
Definition: sfDevAS7331.cpp:255
float getUVB(void)
Returns the last valid UVB reading.
Definition: sfDevAS7331.cpp:412
bool begin(sfTkIBus *theBus=nullptr)
This method is called to initialize the AS7331 device through the specified bus.
Definition: sfDevAS7331.cpp:35
sfTkError_t getStatus(sfe_as7331_reg_meas_osr_status_t &statusReg)
Gets the sensor's status when in measurement operation mode.
Definition: sfDevAS7331.cpp:857
sfTkError_t getOSR(sfe_as7331_reg_cfg_osr_t &osrReg)
Gets the operational state register when in configuration operation mode.
Definition: sfDevAS7331.cpp:875
sfTkError_t getEdges(uint8_t &edgesReg)
Gets the edges register when in configuration operation mode.
Definition: sfDevAS7331.cpp:965
sfTkError_t getCReg3(sfe_as7331_reg_cfg_creg3_t &creg3)
Gets the configuration register #3 when in configuration operation mode.
Definition: sfDevAS7331.cpp:929
bool reset(void)
Performs a soft reset of the sensor.
Definition: sfDevAS7331.cpp:233
sfTkError_t readUVA(void)
Reads the sensor's UVA register, converts it to a usable form, and saves it to the internal UVA varia...
Definition: sfDevAS7331.cpp:275
sfTkError_t setReadyPinMode(const bool &pinMode)
Sets the ready pin type to push-pull or open-drain.
Definition: sfDevAS7331.cpp:539
float getUVC(void)
Returns the last valid UVC reading.
Definition: sfDevAS7331.cpp:417
uint16_t getConversionTimeMillis(void)
Getter for the currently configured conversion time.
Definition: sfDevAS7331.cpp:505
sfTkError_t getOptIndex(sfe_as7331_reg_cfg_optreg_t &optReg)
Gets the option register when in configuration operation mode.
Definition: sfDevAS7331.cpp:983
float getTemp(void)
Returns the last valid Temperature reading.
Definition: sfDevAS7331.cpp:422
as7331_conv_clk_freq_t getCClkRaw(void)
Getter for the currently configured conversion clock.
Definition: sfDevAS7331.cpp:466
as7331_dev_op_state_t getOperationMode(void)
Getter for the current operational state.
Definition: sfDevAS7331.cpp:753
sfTkError_t setNumEdges(const uint8_t &numEdges)
Set the minimum number of falling edges required at the SYN input until the conversion is terminated....
Definition: sfDevAS7331.cpp:706
sfTkError_t getCReg2(sfe_as7331_reg_cfg_creg2_t &creg2)
Gets the configuration register #2 when in configuration operation mode.
Definition: sfDevAS7331.cpp:911
float getUVA(void)
Returns the last valid UVA reading.
Definition: sfDevAS7331.cpp:407
as7331_gain_t getGainRaw(void)
Getter for the currently configured gain.
Definition: sfDevAS7331.cpp:432
sfTkError_t setGain(const as7331_gain_t &gain)
Sets the UV sensor's gain.
Definition: sfDevAS7331.cpp:442
uint8_t getBreakTime(void)
Getter for the currently configured minimum break time in CONT, CMD, SYNS modes.
Definition: sfDevAS7331.cpp:675
sfTkError_t setCReg2(const sfe_as7331_reg_cfg_creg2_t &creg2)
Sets the configuration register #2 when in configuration operation mode.
Definition: sfDevAS7331.cpp:920
sfTkError_t setStandbyState(const bool &standby)
Sets the sensor's standby mode.
Definition: sfDevAS7331.cpp:810
void setCommunicationBus(sfTkIBus *theBus)
Sets the communication bus to the specified bus.
Definition: sfDevAS7331.cpp:91
bool getReadyPinMode(void)
Getter for the currently configured pin mode.
Definition: sfDevAS7331.cpp:534
sfTkError_t readAllUV(void)
Read's all three UV registers, converts them to a usable form, then saves them to their respective in...
Definition: sfDevAS7331.cpp:290
bool getIndexMode(void)
Getter for the currently configured I2C compatibility mode.
Definition: sfDevAS7331.cpp:649
sfTkError_t setDigitalDividerRange(const as7331_divider_val_t &divider, const bool &enableDiv=true)
Sets the value of the internal UV result divider.
Definition: sfDevAS7331.cpp:597
sfTkError_t setIndexMode(const bool &indexMode)
Set the index mode for compatibility with I2C controllers that don't support repeated start.
Definition: sfDevAS7331.cpp:654
bool getPowerDownState(void)
Getter for the current power state.
Definition: sfDevAS7331.cpp:727
sfTkError_t readUVC(void)
Reads the sensor's UVC register, converts it to a usable form, and saves it to the internal UVC varia...
Definition: sfDevAS7331.cpp:285
bool getDigitalDividerEnabled(void)
Getter for the currently configured divider status.
Definition: sfDevAS7331.cpp:560
sfTkError_t setBreak(const uint8_t &breakReg)
Sets the break register when in configuration operation mode.
Definition: sfDevAS7331.cpp:956
sfTkError_t getCReg1(sfe_as7331_reg_cfg_creg1_t &creg1)
Gets the configuration register #1 when in configuration operation mode.
Definition: sfDevAS7331.cpp:893
sfTkError_t setStartState(const bool &startState)
Sets the sensor's start state. This begins measurement.
Definition: sfDevAS7331.cpp:836
bool getStartState(void)
Getter for the current start state.
Definition: sfDevAS7331.cpp:831
sfTkError_t setOptIndex(const sfe_as7331_reg_cfg_optreg_t &optReg)
Sets the option register when in configuration operation mode.
Definition: sfDevAS7331.cpp:992
sfTkError_t setCClk(const as7331_conv_clk_freq_t &cclk)
Set the sensor's internal clock speed.
Definition: sfDevAS7331.cpp:476
uint16_t getGainValue(void)
Getter for the currently configured gain.
Definition: sfDevAS7331.cpp:437
as7331_conv_time_t getConversionTimeRaw(void)
Getter for the currently configured conversion time.
Definition: sfDevAS7331.cpp:500
sfTkError_t setEdges(const uint8_t &edgesReg)
Sets the edges register when in configuration operation mode.
Definition: sfDevAS7331.cpp:974
sfTkError_t setOSR(const sfe_as7331_reg_cfg_osr_t &osrReg)
Sets the operational state register when in configuration operation mode.
Definition: sfDevAS7331.cpp:884
sfTkError_t setBreakTime(const uint8_t &breakTime)
Set the minimum time between measurements in CONT, SYNS, SYND modes.
Definition: sfDevAS7331.cpp:680
uint8_t getNumEdges(void)
Getter for the currently configured minimum number of edges to end conversion when in SYND mode.
Definition: sfDevAS7331.cpp:701
sfTkError_t readOutConv(void)
Read the conversion clock counts register and saves it to the internal output conversion time variabl...
Definition: sfDevAS7331.cpp:385
sfTkError_t setSyndTempConversionEnabled(const bool &isEnabled)
Enables or disables temperature conversion when in SYND mode.
Definition: sfDevAS7331.cpp:628
sfTkError_t setPowerDownState(const bool &pd)
Sets the power state of the sensor.
Definition: sfDevAS7331.cpp:732
bool runDefaultSetup(const bool &runSoftReset=false)
Helper class that sets up the sensor and state in the POR configuration.
Definition: sfDevAS7331.cpp:96
bool getSyndTempConversionEnabled(void)
Getter for the SYND temperature conversion status.
Definition: sfDevAS7331.cpp:623
bool getStandbyState(void)
Getter for the current standby state.
Definition: sfDevAS7331.cpp:805
uint8_t getDeviceID(void)
Requests the device ID from the sensor.
Definition: sfDevAS7331.cpp:49
uint16_t getCClkKHz(void)
Getter for the currently configured conversion clock.
Definition: sfDevAS7331.cpp:471
as7331_meas_mode_t getMeasurementMode(void)
Getter for the current measurement state.
Definition: sfDevAS7331.cpp:779
bool prepareMeasurement(const as7331_meas_mode_t &measMode=MEAS_MODE_CONT, const bool &startMeasure=false)
Puts the sensor in the specified measurement mode.
Definition: sfDevAS7331.cpp:187
sfTkError_t setConversionTime(const as7331_conv_time_t &convTime)
Sets the conversion time that the sensor will run to.
Definition: sfDevAS7331.cpp:510
const uint8_t kDefaultAS7331DeviceID
Definition: sfDevAS7331.h:64
const uint8_t kSfeAS7331RegMeasTemp
Definition: sfDevAS7331.h:289
const uint8_t kSfeAS7331RegMeasOutConvL
Definition: sfDevAS7331.h:293
as7331_conv_clk_freq_t
Definition: sfDevAS7331.h:100
@ CCLK_4_096_MHZ
Definition: sfDevAS7331.h:103
@ CCLK_1_024_MHZ
Definition: sfDevAS7331.h:101
@ CCLK_8_192_MHZ
Definition: sfDevAS7331.h:104
@ CCLK_2_048_MHZ
Definition: sfDevAS7331.h:102
const uint8_t kSfeAS7331RegMeasMres3
Definition: sfDevAS7331.h:292
const uint8_t kSfeAS7331RegCfgEdges
Definition: sfDevAS7331.h:244
as7331_divider_val_t
Definition: sfDevAS7331.h:139
@ DIV_2
Definition: sfDevAS7331.h:140
@ DIV_64
Definition: sfDevAS7331.h:145
@ DIV_16
Definition: sfDevAS7331.h:143
@ DIV_8
Definition: sfDevAS7331.h:142
@ DIV_4
Definition: sfDevAS7331.h:141
@ DIV_256
Definition: sfDevAS7331.h:147
@ DIV_32
Definition: sfDevAS7331.h:144
@ DIV_128
Definition: sfDevAS7331.h:146
const uint8_t kSfeAS7331RegMeasOutConvH
Definition: sfDevAS7331.h:294
const uint8_t kSfeAS7331RegMeasMres2
Definition: sfDevAS7331.h:291
const uint8_t kSecondaryAS7331Addr
Definition: sfDevAS7331.h:60
const uint8_t kAS7331DeviceIDTopNibble
Definition: sfDevAS7331.h:65
const uint8_t kTertiaryAS7331Addr
Definition: sfDevAS7331.h:61
const uint8_t kSfeAS7331RegCfgAgen
Definition: sfDevAS7331.h:182
const uint8_t kSfeAS7331RegMeasOsrStatus
Definition: sfDevAS7331.h:268
as7331_uv_type
Definition: sfDevAS7331.h:152
@ AS7331_UVA
Definition: sfDevAS7331.h:153
@ AS7331_UVB
Definition: sfDevAS7331.h:154
@ AS7331_UVC
Definition: sfDevAS7331.h:155
as7331_dev_op_state_t
Definition: sfDevAS7331.h:73
@ DEVICE_MODE_CFG
Definition: sfDevAS7331.h:75
@ DEVICE_MODE_MEAS
Definition: sfDevAS7331.h:76
const uint8_t kSfeAS7331RegMeasMres1
Definition: sfDevAS7331.h:290
const uint8_t kSfeAS7331RegCfgOsr
Definition: sfDevAS7331.h:166
const uint8_t kSfeAS7331RegCfgBreak
Definition: sfDevAS7331.h:242
as7331_gain_t
Definition: sfDevAS7331.h:82
@ GAIN_16
Definition: sfDevAS7331.h:90
@ GAIN_512
Definition: sfDevAS7331.h:85
@ GAIN_1024
Definition: sfDevAS7331.h:84
@ GAIN_2
Definition: sfDevAS7331.h:93
@ GAIN_4
Definition: sfDevAS7331.h:92
@ GAIN_8
Definition: sfDevAS7331.h:91
@ GAIN_128
Definition: sfDevAS7331.h:87
@ GAIN_1
Definition: sfDevAS7331.h:94
@ GAIN_64
Definition: sfDevAS7331.h:88
@ GAIN_256
Definition: sfDevAS7331.h:86
@ GAIN_32
Definition: sfDevAS7331.h:89
@ GAIN_2048
Definition: sfDevAS7331.h:83
const uint8_t kDefaultAS7331Addr
Definition: sfDevAS7331.h:59
const uint8_t kSfeAS7331RegCfgCreg3
Definition: sfDevAS7331.h:225
as7331_meas_mode_t
Definition: sfDevAS7331.h:109
@ MEAS_MODE_CMD
Definition: sfDevAS7331.h:111
@ MEAS_MODE_SYND
Definition: sfDevAS7331.h:113
@ MEAS_MODE_CONT
Definition: sfDevAS7331.h:110
@ MEAS_MODE_SYNS
Definition: sfDevAS7331.h:112
const uint8_t kSfeAS7331RegCfgCreg2
Definition: sfDevAS7331.h:209
const uint8_t kSfeAS7331RegCfgOptReg
Definition: sfDevAS7331.h:246
const uint8_t kSfeAS7331RegCfgCreg1
Definition: sfDevAS7331.h:196
const uint8_t kQuaternaryAS7331Addr
Definition: sfDevAS7331.h:62
as7331_conv_time_t
Definition: sfDevAS7331.h:119
@ TIME_512MS
Definition: sfDevAS7331.h:129
@ TIME_16MS
Definition: sfDevAS7331.h:124
@ TIME_32MS
Definition: sfDevAS7331.h:125
@ TIME_4096MS
Definition: sfDevAS7331.h:132
@ TIME_2MS
Definition: sfDevAS7331.h:121
@ TIME_8192MS
Definition: sfDevAS7331.h:133
@ TIME_16384MS
Definition: sfDevAS7331.h:134
@ TIME_2048MS
Definition: sfDevAS7331.h:131
@ TIME_128MS
Definition: sfDevAS7331.h:127
@ TIME_1MS
Definition: sfDevAS7331.h:120
@ TIME_4MS
Definition: sfDevAS7331.h:122
@ TIME_1024MS
Definition: sfDevAS7331.h:130
@ TIME_8MS
Definition: sfDevAS7331.h:123
@ TIME_256MS
Definition: sfDevAS7331.h:128
@ TIME_64MS
Definition: sfDevAS7331.h:126
Definition: sfDevAS7331.h:186
uint8_t byte
Definition: sfDevAS7331.h:193
uint8_t mut
Definition: sfDevAS7331.h:189
uint8_t devid
Definition: sfDevAS7331.h:191
Definition: sfDevAS7331.h:200
uint8_t time
Definition: sfDevAS7331.h:203
uint8_t byte
Definition: sfDevAS7331.h:206
uint8_t gain
Definition: sfDevAS7331.h:204
Definition: sfDevAS7331.h:213
uint8_t byte
Definition: sfDevAS7331.h:222
uint8_t en_tm
Definition: sfDevAS7331.h:219
uint8_t reserved
Definition: sfDevAS7331.h:218
uint8_t reserved1
Definition: sfDevAS7331.h:220
uint8_t en_div
Definition: sfDevAS7331.h:217
uint8_t div
Definition: sfDevAS7331.h:216
Definition: sfDevAS7331.h:229
uint8_t sb
Definition: sfDevAS7331.h:235
uint8_t reserved1
Definition: sfDevAS7331.h:236
uint8_t byte
Definition: sfDevAS7331.h:239
uint8_t reserved
Definition: sfDevAS7331.h:233
uint8_t cclk
Definition: sfDevAS7331.h:232
uint8_t mmode
Definition: sfDevAS7331.h:237
uint8_t rdyod
Definition: sfDevAS7331.h:234
Definition: sfDevAS7331.h:250
uint8_t init_idx
Definition: sfDevAS7331.h:253
uint8_t byte
Definition: sfDevAS7331.h:256
uint8_t reserved
Definition: sfDevAS7331.h:254
Definition: sfDevAS7331.h:170
uint8_t pd
Definition: sfDevAS7331.h:176
uint8_t dos
Definition: sfDevAS7331.h:173
uint8_t ss
Definition: sfDevAS7331.h:177
uint8_t sw_res
Definition: sfDevAS7331.h:174
uint8_t reserved
Definition: sfDevAS7331.h:175
uint8_t byte
Definition: sfDevAS7331.h:179
Definition: sfDevAS7331.h:272
uint8_t adcof
Definition: sfDevAS7331.h:281
sfe_as7331_reg_cfg_osr_t osr
Definition: sfDevAS7331.h:275
uint8_t powerstate
Definition: sfDevAS7331.h:276
uint8_t notready
Definition: sfDevAS7331.h:278
uint8_t mresof
Definition: sfDevAS7331.h:282
uint8_t standbystate
Definition: sfDevAS7331.h:277
uint8_t ndata
Definition: sfDevAS7331.h:279
uint8_t ldata
Definition: sfDevAS7331.h:280
uint16_t word
Definition: sfDevAS7331.h:285
uint8_t outconvof
Definition: sfDevAS7331.h:283